On Mar 26, 2007, at 13:02 , 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

Just to make matters worse:

sage: f=2*x^2+4*x+8
sage: F=factor(f)
sage: len(F)
1
sage: len(f.factor())
1
sage: F
(2) * (x^2 + 2*x + 4)

In my case, I did not predefined the polynomial ring.  Hmmm....this  
probably means that in my case, the '2' is viewed as a unit, not a  
factor, and 'f' is a rational polynomial, not an integer one.  In  
fact, type()' gives
       <class  
'sage.rings.polynomial_element_generic.Polynomial_integer_dense'>
in your case, and
       <class  
'sage.rings.polynomial_element_generic.Polynomial_rational_dense'>
in mine.

Timothy, this illustrates an issue in developing software: you have  
to know what your inputs are.  Here's a case where it's unlikely that  
the average student, with little sophistication in the use of CAS's,  
will know (he can create what appears to be f\in ZZ[x], but in fact,  
it's in QQ[x]; and the reason it's important is kind of subtle).

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Director
Institute for the Enhancement of the Director's Income
--------
"Weaseling out of things is what separates us from the animals.
  Well, except the weasel."
       - Homer J Simpson
--------



--~--~---------~--~----~------------~-------~--~----~
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