# Factoring a polynomial over algebraic numbers?

Actually, what I want is to be able to factor a polynomial over the quadratic closure of the rationals, so that I could factor x^2-3 say, as (x+sqrt(3)*(x-sqrt(3)). I don't know enough about factoring algorithms to know whether this is easy or not, but is this at all possible in Sage?

I know I can build an extension field of the rationals by the use of an irreducible quadratic, but that just gives me access to one square root. So if I added sqrt(3) then I could factorize the example above, but not x^2-5. Is it possible to include all square roots - in other words, can Sage work with the the field of constructible numbers?

edit retag close merge delete

Sort by » oldest newest most voted

Though it is not exactly what you are looking for, an approach may be to work in the so-called Algebraic Real Field which contains the constructible numbers:

sage: AA
Algebraic Real Field
sage: R.<x> = AA[]
sage: p = x^2-3
sage: p.factor()
(x - 1.732050807568878?) * (x + 1.732050807568878?)
sage: q = x^2-5
sage: q.factor()
(x - 2.236067977499790?) * (x + 2.236067977499790?)


Note that even though the printed values contain a limited number of digits, they are internally exactly represented (the ? indicates this fact), and you can for instance compute radical expressions for them like this:

sage: f0 = p.factor()[0][0].constant_coefficient()
sage: f0
-1.732050807568878?
-sqrt(3)


I do not know if it is possible to obtain directly the factorization of p with coefficients expressed as a list of radicals, but you can construct such a representation quite easily (by hand).

more

As it is explicitely mentioned, the OP wants to work with the set of constructible numbers which is much smaller than the set of algebraic numbers.

( 2016-01-21 13:22:48 -0500 )edit

Right, I edited my answer. Hope it helps the OP anyway ;-)

( 2016-01-22 04:42:12 -0500 )edit