Completing the square (source code)

= Completing the square
{wiki}

Completing the square rewrites a quadratic polynomial as a squared linear expression plus a constant. For $a\ne0$,
$$
ax^2+bx+c
=a\left(x+\frac{b}{2a}\right)^2
+c-\frac{b^2}{4a}.
$$