Thanks for the reply!
I will upgrade.
Shing
On Jan 4, 8:46 pm, "John Cremona" <[email protected]> wrote:
> I tried this in 3.2.3.final and it works fine:
>
> sage: a,b = matrix(QQ,[[0,1],[-4,0]]).eigenvalues(); a,b
> (2*I, -2*I)
> sage: a in RR
> False
> sage: b in RR
> False
>
> so perhaps you should upgrade?
>
> John Cremona
>
> 2009/1/4 Shing Hing Man <[email protected]>:
>
>
>
> > Hi,
> > I would like to test if an eigenvalue of a matrix over the
> > rationals is a real number.
> > (or The roots of the characteristic polynomial are all real.)
> > I am using
> > x in RR
>
> > Somehow, when x=2i, 'x in RR' produced the following error.
>
> > Thanks in advance for any assistance!
> > Shing
>
> > PS : I am using Sage 3.2.1.
>
> > {{{id=74|
> > E = matrix(QQ,[[0,1],[-4,0]]);E
> > ///
>
> > [ 0 1]
> > [-4 0]
> > }}}
>
> > {{{id=72|
> > E.eigenvalues()
> > ///
>
> > [2*I, -2*I]
> > }}}
>
> > {{{id=76|
> > type(E.eigenvalues()[0])
> > ///
>
> > <class 'sage.rings.qqbar.AlgebraicNumber'>
> > }}}
>
> > {{{id=73|
> > E.eigenvalues()[0] in RR
> > ///
>
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > File "/home/matmsh/.sage/sage_notebook/worksheets/admin/128/code/
> > 211.py", line 7, in <module>
> > exec compile(ur'E.eigenvalues()[_sage_const_0 ] in RR' + '\n',
> > '', 'single')
> > File "/usr/local/lib/sage-3.2.1/local/lib/python2.5/site-packages/
> > SQLAlchemy-0.4.6-py2.5.egg/", line 1, in <module>
>
> > File "parent.pyx", line 324, in
> > sage.structure.parent.Parent.__contains__ (sage/structure/parent.c:
> > 3925)
> > File "parent.pyx", line 284, in
> > sage.structure.parent.Parent.__call__ (sage/structure/parent.c:3709)
> > File "coerce_maps.pyx", line 146, in
> > sage.structure.coerce_maps.NamedConvertMap._call_ (sage/structure/
> > coerce_maps.c:3589)
> > File "/usr/local/lib/sage-3.2.1/local/lib/python2.5/site-packages/
> > sage/rings/qqbar.py", line 2725, in _mpfr_
> > return AA(self)._mpfr_(field)
> > File "/usr/local/lib/sage-3.2.1/local/lib/python2.5/site-packages/
> > sage/rings/qqbar.py", line 499, in __call__
> > raise ValueError, "Cannot coerce algebraic number with non-zero
> > imaginary part to algebraic real"
> > ValueError: Cannot coerce algebraic number with non-zero imaginary
> > part to algebraic real
> > }}}
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---