On Mar 10, 3:23 am, slabbe <sla...@gmail.com> 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)".)

--
John

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

Reply via email to