The equations $x^3+5x^2+px+q=0$and $x^3+7x^2+px+r=0$ have 2 common roots, then find the third root of both equations
If $x^3 + 5x^2 + px + q = 0$ and $x^3 + 7x^2 + px + r = 0$ have two common roots then there must exists a common monic binomial factor, $F(x)$.
So $F(x)$ must be a divisor of
$$(x^3 + 7x^2 + px + r) - (x^3 + 5x^2 + px + q) = 2x^2 - (q - r) $$
So $F(x) = x^2 - \dfrac 12(q - r)$.
So, for some $s$ \begin{align} x^3 + 7x^2 + px + r &= F(x)(x-s) \\ &= \left[x^2 - \dfrac 12(q - r)\right](x-s)\\ &= x^3 - sx^2 - \dfrac 12(q - r)x + \dfrac 12(q - r)s\\ \hline s &= -7 \\ p &= -\dfrac 12(q - r) \\ r &= -\dfrac 72(q - r) \\ \hline s &= -7 \\ p &= \dfrac 15 q \\ r &= \dfrac 75 q \end{align}
And, for some $t$ \begin{align} x^3 + 5x^2 + px + q &= \left[x^2 - \dfrac 12(q - r)\right](x-t)\\ &= x^3 - tx^2 - \dfrac 12(q - r)x + \dfrac 12(q - r)t\\ \hline t &= -5 \\ p &= -\dfrac 12(q - r) \\ q &= -\dfrac 52(q - r) \\ \hline t &= -5 \\ p &= \dfrac 15 q \\ r &= \dfrac 75 q \end{align}
So the third roots are $-7$ and $-5$.
Reality check:
So, suppose $p = -\dfrac 15 q, r = \dfrac 75 q$. To get rid of the fractions, lets let q = 10k.
Then
- $p = 2k$
- $r = 14k$
- $q = 10k$
- $s = -7$
- $t = -5$
- $F(x) = x^2 + 2k$
- $x^3 + 7x^2 + px + r = x^3 + 7x^2 + 2kx + 14k$
- $x^3 + 5x^2 + px + q = x^3 + 5x^2 + 2kx + 10k$
- $F(x)(x-s) = (x^2 + 2k)(x+7) = x^3 + 7x^2 + 2kx + 14k$
- $F(x)(x-t) = (x^2 + 2k)(x+5) = x^3 + 5x^2 + 2kx + 10k$
The difference between the polynomials is a linear factor. Instead of dividing it out, as you implicitly do when applying the Viete identities, we can cross-multiply it to get $$ (x-δ)(x^3+5x^2+px+q)=(x-γ)(x^3+7x^2+px+r) $$
Comparing the coefficient of the cubic and quadratic terms gives $$ 5-δ=7-γ\\ p-5δ=p-7γ $$ so that $γ=2+δ$ and $5δ=7γ=7(2+δ)$ resulting in $δ=-7$ and $γ=-5$.
$$ P(x) = x^3+5x^2+p x+q = (x-x_1)b(x)\\ Q(x) = x^3+7x^2+p x+r = (x-x_2)b(x) $$
then
$$ Q(x)-P(x) = (x_1-x_2)b(x) = 2x^2+r-q $$
and finally
$$ (x-x_1) = \frac{P(x)}{b(x)} = (x_1-x_2)\frac{x^3+5x^2+p x+q}{2x^2+r-q}\\ (x-x_2) = \frac{Q(x)}{b(x)} = (x_1-x_2)\frac{x^3+7x^2+p x+r}{2x^2+r-q}\ $$
so from any of those equations, equating to $0$ the polynomial coefficients we have
$$ 2-x_1+x_2 = 0\\ 5(x_1-x_2)+2x_1 = 0 $$
or
$$ 2-x_1+x_2 = 0\\ 7(x_1-x_2)+2x_2 = 0 $$
giving
$$ x_1 = -5,\ \ x_2 = -7 $$