On Mar 10, 2010, at 10:15 AM, John H Palmieri wrote:

On Mar 10, 3:23 am, slabbe <[email protected]> wrote:
Hi,

A friend of mine wants to factorize symbolicly x^2 - 2 :

sage: p = x^2 - 2
sage: p.factor()
x^2 - 2

Apparently p.roots() gives almost what he wants :

sage: p.roots()
[(-sqrt(2), 1), (sqrt(2), 1)]

Or

sage: p.roots(multiplicities=False)
[-sqrt(2), sqrt(2)]

So, I just proposed him to do :

sage: Factorization([(x-r,m) for r,m in p.roots()])
(x - sqrt(2)) * (x + sqrt(2))

Do any of you have a better solution?

How about:

sage: S.<y> = PolynomialRing(QQ[sqrt(2)])
sage: p = y^2 - 2
sage: p.factor()
(y - sqrt2) * (y + sqrt2)

(I don't know why it says "sqrt2" instead of "sqrt(2)".)

That is because this is a number field, and generator names are supposed to be atomic.

- Robert

--
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
URL: http://www.sagemath.org

Reply via email to