Tell if a polynomial has only two distinct roots

algebra-precalculuspolynomials

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!

Best Answer

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)))
Related Question