On 13 Mrz., 01:24, dmharvey <dmhar...@cims.nyu.edu> wrote:
> ----------------------------------------------------------------------
> | Sage Version 3.4, Release Date: 2009-03-11 |
> | Type notebook() for the GUI, and license() for information. |
> ----------------------------------------------------------------------
> sage: M = matrix([[8585 + O(101^2), 5612 + O(101^2), 5359 + O(101^2)],
> [1616 + O(101^2), 5283 + O(101^2), 2057 + O(101^2)], [8383 + O(101^2),
> 5843 + O(101^2), 7490 + O(101^2)]])
> sage: M
>
> [ 85*101 + O(101^2) 57 + 55*101 + O(101^2) 6 + 53*101 + O(101^2)]
> [ 16*101 + O(101^2) 31 + 52*101 + O(101^2) 37 + 20*101 + O(101^2)]
> [ 83*101 + O(101^2) 86 + 57*101 + O(101^2) 16 + 74*101 + O(101^2)]
> sage: M.charpoly()
> (1 + O(101^2))*x^3 + (54 + O(101))*x^2 + (41 + O(101))*x + (95*101 + O
> (101^2))
>
> Why does my charpoly have some coefficients only mod 101^1?
>
> david
Hi David,
from looking at the source code ("matrix2.pyx") I'd say the reason is,
that first the Hessenberg form H of the matrix M is calculated, and
then the charpoly from that one. That introduces denominators,
however, in your example:
sage: M.hessenberg_form()
[ 85*101 + O(101^2) 25 + O(101) 6 + 53*101 + O(101^2)]
[ 16*101 + O(101^2) 2 + O(101) 37 + 20*101 + O(101^2)]
[ O(101^2) 45 + O(101) 45 + O(101)]
and clearly some entries have lost precision. It seems that once upon
a time there had been matrix code in Sage related to calculating with
p-adics as entries, but there are only traces left. An essentially
empty subdirectory "matrix/padics", and I remember to have seen some
commented out entries in setup.py (before "module_list.py" was
introduced).
The quickest solution to your problem would be to generally make
available one of the standard n^4 algorithms (which do not lose
precision as opposed to the n^3 Hessenberg one) as an alternative. The
signature of charpoly already is designed for that (def charpoly(self,
var='x', algorithm="hessenberg"):), but the argument "algorithm" is
not even evaluated.
Cheers,
gsw
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---