*Completing the square* is a method for rewriting a quadratic expression in a variable such as \(x\) using only one occurrence of the variable, by combining the \(x^2\) and \(x\) terms into a single square.

In general, the expression \(x^2+bx+c\) can be rewritten as \((x+\frac{1}{2}b)^2-\frac{1}{4}b^2+c\), where the \((x+\frac{1}{2}b)^2\) term expands to give both the \(x^2\) and \(bx\) terms.

The expression \(ax^2+bx+c\) can be rewritten similarly by first taking \(a\) out as a factor, giving \[ax^2+bx+c=a\bigl(x^2+\tfrac{b}{a}x+\tfrac{c}{a}\bigr),\] and then rewriting the quadratic expression within the parentheses as above.

This technique can be used to solve quadratic equations and to derive the quadratic formula.