# How can I find the criteria for a polynomial to have, and only have, double roots?

In the help document of function SolveAlways, I saw the condition that a polynomial has a triple root.

(*Find a condition for a cubic polynomial to have a triple root:*)
f[x_] := x^3 + a x^2 + b x + c;
SolveAlways[Implies[f[x] == 0 && f[y] == 0, x == y], {x, y}]


Now I want to imitate this example to find a condition that a polynomial has only a double root (there aren't any multiple roots higher than quadratic).

A = {{1, 2, -3}, {-1, 4, -3}, {1, a, 5}};
f[λ_] := CharacteristicPolynomial[A, λ]
Reduce[Exists[{x, y}, Implies[f[x] == 0 && f[y] == 0, x == y]], {a}]
Solve[(f[x] /. a -> -2) == 0, x]

SolveAlways[Implies[(f[x] == f'[x] == 0), f''[x] != 0], x]


But the output of the above code is not a judgment condition. What can I do to solve this problem?

• A = {{1, 2, -3}, {-1, 4, -3}, {1, a, 5}}; f[\[Lambda]_] := CharacteristicPolynomial[A, \[Lambda]] SolveAlways[Implies[f[x] == 0 && f[y] == 0, x == y], {x, y}] produces {}. Aug 19, 2020 at 6:50
• @user64494 Obviously, a = -2 satisfies the condition, but this conclusion is not obtained. Aug 19, 2020 at 6:52
• Your code is simply incorrect. A right code Reduce[Exists[{x}, f[x] == 0 && f'[x] == 0], a, Reals] produces a == -2 || a == -(2/3). Aug 19, 2020 at 7:16
• @user64494u Thank you for your answer. Aug 19, 2020 at 7:18

You want to have the discriminant vanish and the discriminant of the derivative not vanish.

mat = {{1, 2, -3}, {-1, 4, -3}, {1, a, 5}};
cpoly = CharacteristicPolynomial[mat, x];
disc1 = Discriminant[cpoly, x]
disc2 = Discriminant[D[cpoly, x], x]

(* Out[616]= -288 - 720 a - 504 a^2 - 108 a^3

Out[617]= -4 (2 + 9 a) *)


Now sort these out.

Reduce[disc1 == 0 && disc2 != 0]

(* Out[618]= a == -2 || a == -(2/3) *)


Making use of the definition of a root of multiplicity 2, one obtains

A = {{1, 2, -3},{-1, 4, -3},{1, a, 5}};f[\[Lambda]_]:= CharacteristicPolynomial[A,\[Lambda]]
Reduce[Exists[x, f[x] == 0 && f'[x] == 0 && f''[x] != 0], a, Reals]
(*a == -2 || a == -(2/3)*)


That approach works not only for polynomials.

This is what the discriminant is usable for:

Reduce[Discriminant[CharacteristicPolynomial[{{1, 2, -3},
{-1, 4, -3},
{1, a, 5}}, x], x] == 0, a]
a == -2 || a == -2/3


Check:

With[{a = -2/3}, Eigenvalues[{{1, 2, -3}, {-1, 4, -3}, {1, a, 5}}]]
{4, 4, 2}

With[{a = -2}, Eigenvalues[{{1, 2, -3}, {-1, 4, -3}, {1, a, 5}}]]
{6, 2, 2}