# How to collect a polynomial with a specific power

Suppose I have got this polynomial

u=x^12-3x^8-x^4+3

Now, I am trying to collect this polynomial with x^4 terms. I need to write it like this: (-1+x^4) (-3 + x^4) (1 + x^4)

To evaluate it, I used

Factor[u]

(-1 + x) (1 + x) (1 + x^2) (-3 + x^4) (1 + x^4)

and

Collect[%, x^4, Simplify]

3 - x^4 - 3 x^8 + x^12

But, finally I am not able to reach what I need. Could anyone help me to solve this problem?

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. Jun 14, 2021 at 11:45

Still another option is

Factor[u /. x^n_ -> y^(n/4)] /. y -> x^4

(* (-3 + x^4) (-1 + x^4) (1 + x^4) *)

• Simpler: Factor[u /. x -> y^(1/4)] /. y -> x^4 Jun 14, 2021 at 13:32
• Also, if you want your pattern to match a simple x too (not just higher powers of $x$), you'll need a default pattern: x^n_. -> y^(n/4) (notice the dot after the underscore). Jun 14, 2021 at 14:23
• @Roman In this case there is no need "to match a simple x too". I can imagine other computations in which Default would be useful, however Thanks. Jun 14, 2021 at 14:30

u = x^12 - 3 x^8 - x^4 + 3;

u1 = Factor[u]

(*   (-1 + x) (1 + x) (1 + x^2) (-3 + x^4) (1 + x^4)  *)


Then

Simplify[Drop[u1, -2]]*Drop[u1, 3]

(*  (-3 + x^4) (-1 + x^4) (1 + x^4)  *)


Have fun!

You could do a SolveAlways to get the values a[i] below, provided you know in advance the number of factors:

prod[x_, n_] := Product[x^4 + a[i], {i, n}]
sol = SolveAlways[x^12 - 3 x^8 - x^4 + 3 == prod[x, 3], x];

prod[x, 3] /. sol[]

(* (-3 + x^4) (-1 + x^4) (1 + x^4) *)