# Can Mathematica factor a polynomial over an algebraic number field?

If I input:

Factor[x^2 + x + 1, Extension -> Sqrt[-3]]


Mathematica returns:

1/4 (-I + Sqrt - 2 I x) (I + Sqrt + 2 I x)


The coefficients in the factorization are not in $Q(\sqrt{-3})$. I was expecting something like:

$$(x - z_3)*(x - (z_3)^2)$$

where $z_3$ is a primitive third root of unity.

• A similar output is produced by Factor[x^2 + 2, Extension -> Sqrt[-2]]. Interestingly, the output of Factor[x^2 + 1, Extension -> Sqrt[-1]] is of the form you were originally expecting. – Michael Seifert Mar 15 '16 at 13:53

Mathematica uses FactorTerms to remove content from factors. Since Sqrt[-3] evaluates to I Sqrt, I gets factored out as "content".

FactorTerms[1 + I Sqrt + 2 x]

I (-I + Sqrt - (2 I) x)


You can use AlgebraicNumber to make extension generators atomic.

Factor[x^2 + x + 1, Extension -> AlgebraicNumber[I Sqrt, {0, 1}]]

((2 x + AlgebraicNumber[I Sqrt, {1, -1}])
(2 x + AlgebraicNumber[I Sqrt, {1, 1}])) / 4