So by only two distinct roots I meant that the polynomial, say $f(x)$, is of the form $f(x) = (x-a)^{p}(x-b)^{q}$. Now, I also wish to know this if $a, b \in \mathbb{C}$. That is it is possible that $a$ has a non-zero imaginary part while $b$ is an integer and vice versa. It would really help if there was some easy method to find it out. Also I would like to know the suitability of the term only two distinct roots. Thank you for the help!

  • $\begingroup$ Some of the questions you ask depend on the coefficients of the polynomial $f(x).$ Do you mean these coefficients to be arbitrary complex numbers? Or arbitrary real numbers? or arbitrary rational numbers, or arbitrary integers? $\endgroup$
    – coffeemath
    Commented Jan 5, 2023 at 15:47
  • $\begingroup$ For real numbers, if $f(x)=(x-a)^p(x-b)^q$ then $a$ and $b$ are the two distinct roots (with multiplicity $p$, $q$ respectively). Assuming $a\neq b$. So if you can factor the polynomial into that form then you know that there are two distinct roots $\endgroup$
    – Alborz
    Commented Jan 5, 2023 at 16:06
  • $\begingroup$ @Sil The question has 3 upvotes, so people think it's a good question. So it ought to have a good answer and your comments would make a good answer. $\endgroup$
    – B. Goddard
    Commented Jan 5, 2023 at 22:20
  • $\begingroup$ @B.Goddard Thank you, it's now converted to an answer. $\endgroup$
    – Sil
    Commented Jan 5, 2023 at 23:42

3 Answers 3


Polynomial $f \in \mathbb{C}[x]$ has exactly $\deg f-\deg (\gcd(f,f'))$ distinct (complex) roots.

Proof (sketch). Write $f(x)=(x-\alpha_1)^{k_1}\cdots(x-\alpha_n)^{k_n}$ where $\alpha_i$ are distinct roots and $k_i\geq 1$ their multiplicities, then you can show $\gcd(f(x),f'(x))=(x-\alpha_1)^{k_1-1}\cdots(x-\alpha_n)^{k_n-1}$ and so $f(x)/\gcd(f(x),f'(x))$ is just $(x-\alpha_1)\cdots(x-\alpha_n)$, also called squarefree part of $f$. Its degree $n$ is number of distinct roots of $f$. $\square$

In your case you need to check $\deg f-\deg (\gcd(f,f'))=2$. For this note that $\gcd(f,f')$ can be computed efficiently using Euclid's algorithm for polynomials. If you need the exact roots $a,b$, you can extract them from $f/\gcd(f,f')$ using the quadratic formula.

Example. Consider $f(x)=x^6-9x^5 + 33x^4 - 63x^3 + 66x^2 - 36x + 8$. Then $$f'(x)=6x^5 - 45x^4 + 132x^3 - 189x^2 + 132x - 36$$ and $\gcd(f(x),f'(x))=x^4 - 6x^3 + 13x^2 - 12x + 4$. Hence $\deg f-\deg \gcd(f,f')=2$ and so $f$ has exactly two distinct roots. Furthemore $f(x)/\gcd(f(x),f'(x))=x^2-3x+2$ and so the two roots are $a=1$ and $b=2$. With a bit more work we can find the exponents. Let $f(x)=(x-a)^p(x-b)^q$, then it can be shown that $$\frac{f'(x)}{\gcd(f(x),f'(x))}=(p+q)x-(qa+pb).$$ In the example $f'(x)/\gcd(f(x),f'(x))=6x-9$ and so by comparing the coefficients we get $p=q=3$, i.e. $f(x)=(x-1)^3(x-2)^3$.

Using for example PARI/GP the number of distinct roots by the above method can be computed as:

f = x^6-9*x^5+33*x^4-63*x^3+66*x^2-36*x+8
n = poldegree(f) - poldegree(gcd(f,deriv(f,x)))
  • $\begingroup$ Hey! I just wanted to ask that are there any end cases or critical points I might have to worry about as I was unable to think of any on my own. Also can you tell the efficiency of this method utilising Euclid's algorithm for large polynomials say of degree 100 and any other thing I might have to keep in mind. Thank you very much! $\endgroup$ Commented Jan 6, 2023 at 8:48
  • $\begingroup$ There are only practical limitations by your programming language and computers such as limited memory, of course you need to be able to multiply and divide the polynomials, so you need to be able store and manipulate its coefficients efficiently (if they are integers or rationals this is mich simpler, this is especially simple if you use computer algebra systems such as parigp, sympy, maple, etc...). You can find something about efficiency of Euclid's algorithm in math.stackexchange.com/questions/2974177, but I am sure this is standard topic that can be searched. $\endgroup$
    – Sil
    Commented Jan 6, 2023 at 13:08
  • $\begingroup$ Yeah, I understand. Thank you for the response! $\endgroup$ Commented Jan 6, 2023 at 14:28

If you compute (by Euclidean Algorithm) $\gcd(f(x),f^{(n)}(x))$ for successive derivatives of $f(x)$ then you'll find out right away whether $f$ is of the desired form. For example, let

$$f(x) = x^5-15x^3+10x^2+60x-72.$$


$$f'(x) = 5x^4-45x^2+20x+60$$

and $\gcd(f(x), f'(x)) = x^3-x^2-8x+12.$ Then

$$f''(x) = 20x^3-90x+20$$

and $\gcd(f(x), f'(x)) = x-2$. That tells me that $(x-2)^3$ exactly divides $f(x)$. So I compute $g(x)=f(x)/(x-2)^3 = x^2+6x+9$. Then repeat the above for $g(x)$:

$$g'(x) = 2x+6$$

and $\gcd(g(x), g'(x)) = (x+3).$ So I know that $(x+3)^2$ exactly divides $g(x)$ and hence $f(x)$. And in fact

$f(x) = (x-2)^3(x+3)^2.$

So you need to know two things here: If a linear factor appears to the $n$th power in a polynomial, then it appears to the $n-1$ power in the derivative. And you need to know how to do the Euclidean Algorithm on polynomials. This will work just fine over the complex numbers.

EDIT: Sil's comment above gives a much faster way, using these same ideas.

  • $\begingroup$ Thank you for the response. It took me sometime to understand your method but it is great nevertheless and provides great insights. $\endgroup$ Commented Jan 6, 2023 at 11:11

There are already some great answers, but let me add some more info in the case where the exponents are fixed beforehand. One can homogenize and turn the single-variable nonhomogeneous polynomial $f(x)$ into a homogeneous polynomial, a.k.a. a binary form, $F(x_1,x_2)=x_2^{p+q}f(x_1/x_2)$. Then for fixed given $p,q$ consider $X_{p,q}$ defined as the set of such polynomials which can be written as $F=K^pL^q$ for some linear forms $K$ and $L$. The previous answers give an algorithmic way, for a given specific $F$, to tell if F is in $X_{p,q}$ or in a union of such sets for $p+q$ fixed. Another approach is to try to find polynomial equations in the coefficients of a generic $F$ which vanish exactly when $F$ is in $X_{p,q}$, namely, finding set-theoretic equations for $X_{p,q}$. A much more difficult problem (which includes the previous one) is to find generators for the ideal of all polynomials in the coefficients of $F$ which vanish on $X_{p,q}$ (ideal-theoretic equations). This latter problem was solved by my colleague Chipalkatti and myself in the two articles:

  1. A. Abdesselam, and J. Chipalkatti, "Brill–Gordan loci, transvectants and an analogue of the Foulkes conjecture." Advances in Mathematics 208, no. 2 (2007): 491-520.
  2. A. Abdesselam, and J. Chipalkatti. "The bipartite Brill-Gordan locus and angular momentum." Transformation groups 11, no. 3 (2006): 341-370.

These respectively concern the $p=q$ and $p\neq q$ cases which are quite different.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .