On Fri, May 21, 2010 at 5:03 PM, Anne Schilling <a...@math.ucdavis.edu> wrote:
> Hi Simon!
>
> Thank you very much for your answer.
>
>> On May 18, 7:47 am, Anne Schilling <nicolas.thi...@u-psud.fr> wrote:
>>>
>>> sage: LD.<d>=LaurentPolynomialRing(QQ)
>>> sage: P=PolynomialRing(LD,'z',2)
>>
>> Sage tries to use Singular to factor your polynomial. Hence, it needs
>> to convert both your polynomial and its ring to Singular.
>>
>> The problem is that your coefficients are Laurent Polynomials, but
>> Singular can only do the fraction field of the Laurent polynomial
>> ring.
>>
>> So, you can do:
>>
>>  sage: LD.<d>=LaurentPolynomialRing(QQ)
>>  sage: P=PolynomialRing(Frac(LD),'z',2)
>>  sage: z = P.gens()
>>  sage: f = z[0]**2-d**2*z[1]**2
>>  sage: f.factor()
>>  (-z0 + (-d)*z1) * (-z0 + d*z1)
>
> There still seems to be a problem though, since Sage does not
> recognize that the answer is in P. See:
>
> ----------------------------------------------------------------------
> | Sage Version 4.4.1, Release Date: 2010-05-02                       |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> Loading Sage library. Current Mercurial branch is: combinat
> sage: LD.<d>=LaurentPolynomialRing(QQ)
> sage: P=PolynomialRing(Frac(LD),'z',2)
> sage: z=P.gens()
> sage: f=z[0]**2-d**2*z[1]**2
> sage: f in P
> True
> sage: g=f.factor()
> sage: g
> (-z0 + (-d)*z1) * (-z0 + d*z1)
> sage: g in P
> False

This is for the same reason that:

sage: factor(6) in ZZ
False
sage: factor(6)
2 * 3
sage: type(factor(6))
<class 'sage.structure.factorization.Factorization'>


A factorization is not an element, but a formal product -- it is its own class.

You can use .prod(), though:

sage: F = factor(6)
sage: F.prod()
6
sage: F.prod() in ZZ
True



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

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

Reply via email to