# How to check if a Polynomial has a specific form

I have a polynomial F[x], for example F[x] = 1 - 2x + x^2. I wanna check whether F[x] has the form of (1 + kx)^n. For the example above, k = -1 and n = 2.

I have searched on several documents but found nowhere has the answer. So can I do this on Mathematica? If yes, how can I get k and n?

-
$n$ is going to be the order of the polynomial f[x]. Then $k^n$ is the coefficient of $x^n$, so $k=coef^{(1/n)}$. Then test to see if f[x] is the same as (1+k x)^n. – bill s Sep 3 '13 at 3:28
@Kuba Oh I thought they are the same, aren't they? I mean it can be represented in that form. – Loi.Luu Sep 3 '13 at 6:07
Just done @Kuba :) – Loi.Luu Sep 3 '13 at 6:12
@bills what I wanna do is that I send the polynomial to Mathematica, simplify it and then check the question above automatically. If Mathematica is not capable of doing that then I will have to put more manual work like your suggestion. Thank you anw. – Loi.Luu Sep 3 '13 at 6:16
Have you tried Factor or Simplify on F[x]? – asterix314 Oct 14 '13 at 3:03

It may be naive but I think the following should work:

If the polynomial has this form this means it has one multiple root which is not 0:

check[f_?PolynomialQ] := Length@DeleteDuplicates@Solve[f[x] == 0, x] == 1 && f[0] != 0

check[f]

True


Notice that I'm not bothering about n and k. Do you want to find them?

It works even for not so exact coefficients:

f[x_] := (1/5 - 1/3 x)^5 // Expand // N
f[x]

0.00032 - 0.00266667 x + 0.00888889 x^2 - 0.0148148 x^3 + 0.0123457 x^4 - 0.00411523 x^5

check[f]

True

f[x_] := (1/5 + 1/3 x)^5 + 2 // Expand // N
check[f]

False

-
It's a good idea. Since Mathematica will return all the roots hence we can check whether they are duplicated roots. Then we can find N consequently. I think K is then easily found since 1/k is the only root of the F[X] == 0 right? – Loi.Luu Sep 3 '13 at 6:24
@Loi.Luu I just have to add that root equal to 0 should be excluded as it does not fit your form. – Kuba Sep 3 '13 at 6:25
Yeah, that's right. – Loi.Luu Sep 3 '13 at 6:27
@Loi.Luu ok it should work now :) – Kuba Sep 3 '13 at 6:29