Here is a strictly formal way to complete the square. We want to express in the form . We may want to do this for many reasons, for example, to graph a quadratic function (parabola), to solve a quadratic equation, to integrate a rational function or to solve a differential equation.
If we expand , we get . If for all , and we know , we only need to solve two equations. First solve for . Note we already know . Then solve for . Here we already know . Here are two examples.