Re: a fault in the Factor[] function for polynomials?

• To: mathgroup at smc.vnet.net
• Subject: [mg70424] Re: [mg70395] a fault in the Factor[] function for polynomials?
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Mon, 16 Oct 2006 02:34:22 -0400 (EDT)
• References: <200610150419.AAA12686@smc.vnet.net>

```On 15 Oct 2006, at 13:19, Roger Bagula wrote:

> Expand[(x^4 + 2*Sqrt[3]x^2 - 1)(x^4 - 2*Sqrt[3]x^2 - 1)]
> 1 - 14x^4 + x^8
> Factor[%]
> (1 - 4x^2 + x^4)(1 + 4x^2 + x^4)

Factorization is defined only with respect to an algebraic extension.
If you specify no extension Factor attempts only to factor your
polynomial over the rationals. Here is how you specify the algebraic
extension you wish to use:

poly=Expand[(x^4 + 2*Sqrt[3]*x^2 - 1)*(x^4 - 2*Sqrt[3]*x^2 - 1)];

Factor[poly, Extension -> {Sqrt[3]}]

(-x^2 + Sqrt[3] - 2)*(-x^2 + Sqrt[3] + 2)*(x^2 + Sqrt[3] - 2)*
(x^2 + Sqrt[3] + 2)

or

Factor[poly, Extension -> {Sqrt[3], Sqrt[2]}]

(-(1/16))*(-2*x + Sqrt[6] - Sqrt[2])*
(-2*x + Sqrt[6] + Sqrt[2])*(2*x + Sqrt[6] - Sqrt[2])*
(2*x + Sqrt[6] + Sqrt[2])*(-x^2 + Sqrt[3] - 2)*
(x^2 + Sqrt[3] + 2)

or you can get a simple factorization into linear factors over the
complex numbers:

Factor[poly, Extension -> {Sqrt[3], Sqrt[2], I}]

(1/256)*(-2*x + Sqrt[6] - Sqrt[2])*(-2*x + Sqrt[6] + Sqrt[2])*
(-2*I*x + Sqrt[6] - Sqrt[2])*(-2*I*x + Sqrt[6] + Sqrt[2])*
(2*I*x + Sqrt[6] - Sqrt[2])*(2*I*x + Sqrt[6] + Sqrt[2])*
(2*x + Sqrt[6] - Sqrt[2])*(2*x + Sqrt[6] + Sqrt[2])

If you do not wish to enter the Extension manually you might want to
use the following functions that will automatically factor your
polynomial over the complex number or the real numbers.

FactorOverComplexes[poly_, x_] := If[PolynomialQ[poly, x],
Factor[poly, Extension -> (x /. Solve[poly == 0, x])], poly]

FactorOverReals[poly_, x_] := If[PolynomialQ[poly, x],
Factor[poly, Extension -> (x /. {ToRules[Reduce[poly == 0, x,
Reals]]})], poly]

However, although these factorizations are quite correct, they will
in general look much more complicated than the ones you can get by
specifying the extension manually (provided you choose the right
generators). Just compare these two lists:

l1 = List @@ Factor[poly, Extension -> {Sqrt[3], Sqrt[2], I}]

l2 = List @@ FactorOverComplexes[poly, x]

They both have the same number of factors:

In[35]:=
Length/@{l1,l2}

Out[35]=
{9,9}

and you can check they are both valid factorizations:

FullSimplify[Times@@l1-Times@@l2]

0

but it is pretty clear which one is preferable.

In fact one can write programs that will perform automatic
factorizations over the reals or complexes and give simpler factors
by using FactorList instead of Factor and applying FullSimplify

FactorListOverComplexes[poly_, x_] := If[PolynomialQ[poly, x],
(FullSimplify[ FactorList[poly, Extension -> (x /. Solve[poly == 0,
x])]]), poly]

but this will take far to long in all but the simplest cases:

Timing[FactorListOverComplexes[x^2 + x + 1, x]]

{0.012298999999998728*Second, {{-1, 1}, {-x + (-1)^(1/3) - 1, 1}, {x
+ (-1)^(1/3), 1}}}

works fine, but if you try it in your case you will have to be pretty
patient before you see any answer.

So I do not think there is any way to deal with this sort of problems
better than the one currently used Mathematica, which requires you to
specify the extension by hand.

Andrzej Kozlowski

```

• Prev by Date: Re: FourierCosTransform
• Next by Date: Re: FindRoot
• Previous by thread: Re: a fault in the Factor[] function for polynomials?
• Next by thread: Re: a fault in the Factor[] function for polynomials?