On Monday 26 March 2007 1:02 pm, David Harvey wrote:
> On Mar 26, 2007, at 3:57 PM, Timothy Clemans wrote:
> > Apparently I was incorrectly defining x as an integer, however, I did
> > not get an error the first I tried.
> >
> > incorrect way: x = PolynomialRing(ZZ)
> > correct way: g.<x> = PolynomialRing(ZZ)
> >
> > The len method works now. Thanks.
>
> Be careful though:
>
> sage: R.<x> = PolynomialRing(ZZ)
>
> sage: f = 2*x^2 + 4*x + 8
>
> sage: f.factor()
> 2 * (x^2 + 2*x + 4)
>
> sage: len(f.factor())
> 2

Which might actually be what one wants, since indeed your poly f is
not "prime" as an element of ZZ[x], since (2) is a prime ideal
and (x^2+2*x+4) is divisible by other prime ideals. 

Note that there is an is_irreducible() method for polynomials, which
correctly deals with the case of a multiple factor:

sage: f = (x-1)^2
sage: f.is_irreducible()
False
sage: len(f.factor())
1

 -- william

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
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://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to