5
$\begingroup$

What exactly does FactorTermsList do? The documentation is not complete in that it only gives examples, not a precise definition:

  • What exactly is the "overall numerical factor of a polynomial" for Mathematica? From a description on mathworld that I found, I understand that this is supposed to be the content of the polynomial, but how exactly does Mathematica define that when it knows only the polynomial, not the underlying ring of the coefficients? Does it just take the ring generated by the coefficients?
  • What the is second output? Just any arbitrary factor that does not depend on the variables? How is it determined and how does it relate to the content of the polynomial?

And then there is the following strange example:

FactorTermsList[(3 x^4)/(2 Sqrt[Pi]) - (9 x^2 y^2)/(2 Sqrt[Pi]) + (9 y^4)/(  16 Sqrt[Pi]) - (9 x^2 z^2)/(2 Sqrt[Pi]) + (9 y^2 z^2)/(8 Sqrt[Pi]) + (9 z^4)/(16 Sqrt[Pi]),{x,y,z}]

which produces the output

{3/16, (8 x^4)/Sqrt[Pi] - (24 x^2 y^2)/Sqrt[Pi] + (3 y^4)/Sqrt[Pi] - (24 x^2 z^2)/Sqrt[Pi] + (6 y^2 z^2)/Sqrt[Pi] + (3 z^4)/Sqrt[Pi]}
  • Why is this a list with only two entries? From the documentation I understand that FactorTermsList is supposed to output a list with five entries, because I want the input to be considered as a polynomial in three variables. And that's exactly what it does for most other polynomial inputs with three variables.

For example

FactorTermsList[4x+6xy+10xyz,{x,y,z}]

produces

{2, 1, 1, 2 + 3 y + 5 y z, x}

which is still weird (why do the third to fifth entry in the list occur in the order in which they do?) but at least it's a list with five entries.

$\endgroup$
3
  • 3
    $\begingroup$ You are correct that it is supposed to pull out successive contents with respect to decreasing variable lists. It's been a while since I've looked hard at that code*. Possibly the examples you show are bugs.(*A while as in probably the prior millenium.) $\endgroup$ Commented Jun 19, 2020 at 14:11
  • $\begingroup$ While I don't see, how that could affect the result, it may be worth mentioning that all of my example polynomials below are harmonic polynomials, while the examples that seem to work as intended are not... $\endgroup$
    – Andrea
    Commented Jul 23, 2020 at 13:15
  • $\begingroup$ Interestingly enough for the polynomes p[x,y,z] that I am working with, Table[Factor[p[x,y,z]][[l]], {l, 1, Length[Factor[p[x,y,z]]]}] produces consistent output (first two entries are in Q and R/Q, the following entries all are polynomial factors) $\endgroup$
    – Andrea
    Commented Sep 1, 2020 at 15:40

2 Answers 2

1
$\begingroup$
FactorTermsList[4x+6x y+10x y z,{x,y,z}]

(*  {2, 1, 1, 2 + 3 y + 5 y z, x}  *)

List of factors of 4x+6x y+10x y z. The constant factor 2 is the first entry in the result list. The second entry states that x occurs, the third is has the commons factor 1, that is the remaining polynomial listed 2 + 3 y + 5 y z, and the last element of the result list is x, the variable factored.

FactorTermsList stops evaluating if no further variable can be factored.

So in the first example, the y and z are meaningless.

The documentation of FactorTermslist has an example stating:

"Pull out factors that do not depend on x and y and then factors that do not depend on x:"

if as list of variables is given as the second argument.

So the built-in works in the example form the Mathematica documentation FactorTermslist on the part of the given polynomial containing the product of the listed variables and factors that in the fashion described above.

f = 2 a x^2 y + 2 x^2 y + 4 a x^2 + 4 x^2 + 4 a^2 y^2 + 4 a y^2 + 
  8 a^2 y + 2 a y - 6 y - 12 a - 12

(*  -12 - 12 a + 4 x^2 + 4 a x^2 - 6 y + 2 a y + 8 a^2 y + 2 x^2 y + 
     2 a x^2 y + 4 a y^2 + 4 a^2 y^2  *)

FactorTermsList[f, {x, y}]
(*  {2, 1 + a, 2 + y, -3 + x^2 + 2 a y}  *)

has worked only on the last part in the ordered output of f:

2 x^2 y + 2 a x^2 y + 4 a y^2 + 4 a^2 y^2


(2 x^2 y + 2 a x^2 y + 4 a y^2 + 4 a^2 y^2)/2) // Simplify
(*  (1 + a) y (x^2 + 2 a y)  *)

Reverse:

2 (1 + a) (2 + y) (-3 + x^2 + 2 a y) // Expand
(*  -12 x - 12 a x + 4 x^3 + 4 a x^3 - 6 x y + 2 a x y + 8 a^2 x y + 
     2 x^3 y + 2 a x^3 y + 4 a x y^2 + 4 a^2 x y^2  *)

is the original function, polynomial f.

It seems that FactorTermslist does not work on the constant Pi as entered in the fashion you did. Use the Pi - symbol from the palette and it works:

FactorTermsList[\[Pi] x^2 - \[Pi]]
(*  {\[Pi], -1 + x^2}  *)
$\endgroup$
1
$\begingroup$

I tried Steffen's recommendation, i.e. replacing Pi with \[Pi] in Johannes' example above. (see here). However, the result is still the same.

Moreover, FactorTermsList seems to give a number in $\mathbb{Q}$ in the first result and a number in $\mathbb{R}/\mathbb{Q}$ in the second result for most polynomials I have tried, for instance

1/2 Sqrt[7/Pi] x^3 - 3/4 Sqrt[7/Pi] x y^2 - 3/4 Sqrt[7/Pi] x z^2

gives

{1/4, Sqrt[7/Pi], 1, 1, 2 x^3 - 3 x y^2 - 3 x z^2}

So, unfortunately, the issue is not solved by entering $\pi$ in a different way.

Edit: I just realized that you could factor out x in the given example, so I guess one would expect a result like this (maybe with different ordering):

{1/4, Sqrt[7/Pi], 1, 2 x^2 - 3 y^2 - 3 z^2,x}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.