Ask Your Question

Revision history [back]

You can also get exact results by using the Algebraic Field QQbar, which avoids the need of manually constructing a splitting field.

In Sage 8.4, I'd also suggest setting QQbar's display option to radical instead of decimal (the default). Try both and see the difference; it's the simplest way I know how to explain it!

sage: QQbar.options.display_format = 'radical'
sage: R.<x> = PolynomialRing(QQbar)
sage: f = x^2*((x+1/x)^2-1)
sage: f.factor()
(x - 1/2*I*sqrt(3) - 1/2) * (x + 1/2*I*sqrt(3) - 1/2) * (x - 1/2*I*sqrt(3) + 1/2) * (x + 1/2*I*sqrt(3) + 1/2)
sage: mul([p.constant_coefficient() for p,m in f.factor()])
1

You can also get exact results by using the Algebraic Field QQbar, which avoids the need of manually constructing a splitting field.field (like rburing shows in his answer).

In Sage 8.4, I'd also suggest setting QQbar's display option to radical instead of decimal (the default). Try both and see the difference; it's the simplest way I know how to explain it!

sage: QQbar.options.display_format = 'radical'
sage: R.<x> = PolynomialRing(QQbar)
sage: f = x^2*((x+1/x)^2-1)
sage: f.factor()
(x - 1/2*I*sqrt(3) - 1/2) * (x + 1/2*I*sqrt(3) - 1/2) * (x - 1/2*I*sqrt(3) + 1/2) * (x + 1/2*I*sqrt(3) + 1/2)
sage: mul([p.constant_coefficient() for p,m in f.factor()])
1