Completing the square (source code)

= Completing the square
{title2=$a(x-h)^2+k$}
{wiki}

Completing the square rewrites a <quadratic polynomial> so that its <minimum> or <maximum> and its <roots of a polynomial> become easy to read. The linear term is absorbed into a shift of the <variable>; the resulting <polynomial identity> changes the description, rather than the values of the <polynomial>.

For <coefficients> $a,b,c$ in the <real numbers>, with $a\ne0$,
$$
\boxed{ax^2+bx+c
=a\left(x+\frac{b}{2a}\right)^2
+c-\frac{b^2}{4a}.}
$$
First factor out the <leading coefficient> from $ax^2+bx$, then add and subtract $(b/(2a))^2$ inside the bracket. The cross term in $(x+b/(2a))^2$ is $(b/a)x$, exactly the term needed. Multiplication by $a$ restores $bx$. Thus the half-coefficient is $b/(2a)$, rather than $b/2$ unless the <quadratic polynomial> is a <monic polynomial>. Expanding the right-hand side verifies the <polynomial identity> directly.<Intermediate Algebra 2e by Lynn Marecek and Andrea Honeycutt Mathis/9.2 Solve Quadratic Equations by Completing the Square>[Intermediate Algebra 2e, §9.2: completing a square and normalizing a nonmonic quadratic]{ref}

For an original example,
$$
x^2+6x+13=(x^2+6x+9)+4=\boxed{(x+3)^2+4}.
$$
For every $x$ in the <real numbers>, $(x+3)^2\geq0$, with equality only at $x=-3$. The <minimum> is therefore $4$, reached at $-3$; no <calculus> is needed, and there are no <roots of a polynomial> in the <real numbers>. The expanded <coefficients> conceal these conclusions more effectively than the completed square does.