The completing square method is a way of solving quadratic polynomials by reducing then to the structure
(x+alpha)^2-beta^2 equiv (x+alpha + beta)(x+alpha-beta)(x+α)2−β2≡(x+α+β)(x+α−β)
The right one is the factorized form.
Now giving a polynomial p_2(x)=x^2+a_1x+a_0p2(x)=x2+a1x+a0 the reduction begins by making
x^2+a_1x+a_0 = (x+alpha)^2-beta^2x2+a1x+a0=(x+α)2−β2.
That furnishes
{(a_1 = 2 alpha),(a_0=alpha^2-beta^2):}
Taking alpha = a_1/2 we obtain beta = pm sqrt((a_1/2)^2-a_0) so the result is
x^2+a_1x+a_0 equiv (x+a_1/2)^2-(sqrt((a_1/2)^2)-a_0)^2
If (a_1/2)^2 -a_0< 0 the roots are complex conjugate.
In the present case we have
x^2-5x + 1 = (x-5/2)^2 - (sqrt((5/2)^2)-1)^2
x^2-5x + 1 =(x-5/2-sqrt(21)/2)(x-5/2+sqrt(21)/2)