Re: [sage-support] How can I tell if an algebraic number is rational?

2011-06-01 Thread D. S. McNeil
 PolynomialRing(ZZ, 'x')

This is only an aside, but I should probably warn that (unlike var,
say) this doesn't change x, so it might not do what you're thinking.

x is still an Expression, an element of the Symbolic Ring, and so f is
also an Expression.  You probably want to use something like

sage: R.x = PolynomialRing(ZZ)
sage: parent(x)
Univariate Polynomial Ring in x over Integer Ring
sage: f=x^3 + A*x +B
sage: parent(f)
Univariate Polynomial Ring in x over Integer Ring

or R.x = ZZ[] or something.


Doug

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] How can I tell if an algebraic number is rational?

2011-06-01 Thread Robert Bradshaw
On Wed, Jun 1, 2011 at 7:30 AM, zsharon zacherysha...@gmail.com wrote:
 Hi,

 I need to determine if a given algebraic number is rational.  Here is
 the setup:

 PolynomialRing(ZZ, 'x')
 A=-2
 B=5
 f=x^3 + A*x +B
 D=-4*A^3-27*B^2
 L.c = NumberField(f)

 Then I need to know if a given number beta=b0+b1*c+b2*c^2 is rational
 or not.  It tried using

 K.s=QQ.extension(beta.minpoly())
 K==QQ

 but I'm not sure if this is reliable.

To test membership, just do

sage: beta in QQ

- Robert

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org