Completing the square
, animated GIF version) In elementary algebra, completing the square is a technique for converting a quadratic polynomial of the form to the form for some values of and .[src] In terms of a new quantity , this expression is a quadratic polynomial with no linear term.[src] By subsequently isolating and taking the square root, a quadratic problem can be reduced to a linear problem.[src] The name completing the square comes from a geometrical picture in which represents an unknown length.[src] Then the quantity represents the area of a square of side and the quantity represents the area of a pair of congruent rectangles with sides and .[src] To this square and pair of rectangles, one more square is added, of side length .[src] This crucial step completes a larger square of side length .[src] Completing the square is the oldest method of solving general quadratic equations, used in Old Babylonian clay tablets dating from 1800–1600 BCE.[src] It was formalised and popularised by mathematician Al-Khwarizmi in his work Al-Jabr, and is still taught in elementary algebra courses today.[src] It is also used for graphing quadratic functions, deriving the quadratic formula, and more generally in computations involving quadratic polynomials, for example in calculus evaluating Gaussian integrals with a linear term in the exponent, and finding Laplace transforms.[src]
, animated GIF version) In elementary algebra, completing the square is a technique for converting a quadratic polynomial of the form to the form for some values of and .[src] In terms of a new quantity , this expression is a quadratic polynomial with no linear term.[src] By subsequently isolating and taking the square root, a quadratic problem can be reduced to a linear problem.[src] The name completing the square comes from a geometrical picture in which represents an unknown length.[src] Then the quantity represents the area of a square of side and the quantity represents the area of a pair of congruent rectangles with sides and .[src] To this square and pair of rectangles, one more square is added, of side length .[src] This crucial step completes a larger square of side length .[src] Completing the square is the oldest method of solving general quadratic equations, used in Old Babylonian clay tablets dating from 1800–1600 BCE.[src] It was formalised and popularised by mathematician Al-Khwarizmi in his work Al-Jabr, and is still taught in elementary algebra courses today.[src] It is also used for graphing quadratic functions, deriving the quadratic formula, and more generally in computations involving quadratic polynomials, for example in calculus evaluating Gaussian integrals with a linear term in the exponent, and finding Laplace transforms.[src] ==Overview== ===Background=== The formula in elementary algebra for computing the square of a binomial is: (x + p)^2 \,=\, x^2 + 2px + p^2.[src] For example: \begin{alignat}{2} (x+3)^2 \,&=\, x^2 + 6x + 9 && (p=3)\\[3pt] (x-5)^2 \,&=\, x^2 - 10x + 25\qquad && (p=-5).[src] \end{alignat} In any perfect square, the coefficient of x is twice the number p, and the constant term is equal to p 2 .[src] ===Basic example=== Consider the following quadratic polynomial: x^2 + 10x + 28.[src] This quadratic is not a perfect square, since 28 is not the square of 5: (x+5)^2 \,=\, x^2 + 10x + 25.[src] However, it is possible to write the original quadratic as the sum of this square and a constant: x^2 + 10x + 28 \,=\, (x+5)^2 + 3.[src] This is called completing the square.[src] ===General description=== Given any monic quadratic x^2 + bx + c, it is possible to form a square that has the same first two terms: \left(x+\tfrac{1}{2} b\right)^2 \,=\, x^2 + bx + \tfrac{1}{4}b^2.[src] This square differs from the original quadratic only in the value of the constant term.[src] Therefore, we can write x^2 + bx + c \,=\, \left(x + \tfrac{1}{2}b\right)^2 + k, where k = c - \frac{b^2}{4} .[src] This operation is known as completing the square.[src] For example: \begin{alignat}{1} x^2 + 6x + 11 \,&=\, (x+3)^2 + 2 \\[3pt] x^2 + 14x + 30 \,&=\, (x+7)^2 - 19 \\[3pt] x^2 - 2x + 7 \,&=\, (x-1)^2 + 6.[src] \end{alignat} ===Non-monic case=== Given a quadratic polynomial of the form ax^2 + bx + c it is possible to factor out the coefficient a, and then complete the square for the resulting monic polynomial.[src] Example: \begin{align} 3x^2 + 12x + 27 &= 3[x^2+4x+9]\\ &{}= 3\left[(x+2)^2 + 5\right]\\ &{}= 3(x+2)^2 + 3(5)\\ &{}= 3(x+2)^2 + 15 \end{align} This process of factoring out the coefficient a can further be simplified by only factorising it out of the first 2 terms.[src] The constant term at the end of the polynomial does not have to be included.[src] Example: \begin{align} 3x^2 + 12x + 27 &= 3\left[x^2+4x\right] + 27\\[1ex] &{}= 3\left[(x+2)^2 -4\right] + 27\\[1ex] &{}= 3(x+2)^2 + 3(-4) + 27\\[1ex] &{}= 3(x+2)^2 - 12 + 27\\[1ex] &{}= 3(x+2)^2 + 15 \end{align} This allows the writing of any quadratic polynomial in the form a(x-h)^2 + k.[src] ===Formula=== ====Scalar case==== The result of completing the square may be written as a formula.[src] In the general case, one has ax^2 + bx + c = a(x-h)^2 + k, with h = -\frac{b}{2a} \quad\text{and}\quad k = c - ah^2 = c - \frac{b^2}{4a}.[src] In particular, when , one has x^2 + bx + c = (x-h)^2 + k, with h = -\frac{b}{2} \quad\text{and}\quad k = c - h^2 = c - \frac{b^2}{4}.[src] By solving the equation a(x-h)^2 + k=0 in terms of x-h, and reorganizing the resulting expression, one gets the quadratic formula for the roots of the quadratic equation: x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}.[src] ====Matrix case==== The matrix case looks very similar: x^{\mathrm{T}}Ax + x^{\mathrm{T}}b + c = (x - h)^{\mathrm{T}}A(x - h) + k where h = -\frac{1}{2}A^{-1}b and k = c - \frac{1}{4} b^{\mathrm{T}}A^{-1}b .[src] Note that A has to be symmetric.[src] If A is not symmetric the formulae for h and k have to be generalized to: h = -(A+A^{\mathrm{T}})^{-1}b \quad\text{and}\quad k = c - h^{\mathrm{T}}A h = c - b^{\mathrm{T}} (A+A^{\mathrm{T}})^{-1} A (A+A^{\mathrm{T}})^{-1}b ==Relation to the graph== In analytic geometry, the graph of any quadratic function is a parabola in the xy-plane.[src] Given a quadratic polynomial of the form a(x-h)^2 + k the numbers h and k may be interpreted as the Cartesian coordinates of the vertex (or stationary point) of the parabola.[src] That is, h is the x-coordinate of the axis of symmetry (i.e.[src] the axis of symmetry has equation x = h), and k is the minimum value (or maximum value, if a < 0) of the quadratic function.[src] One way to see this is to note that the graph of the function is a parabola whose vertex is at the origin (0, 0).[src] Therefore, the graph of the function is a parabola shifted to the right by h whose vertex is at (h, 0), as shown in the top figure.[src] In contrast, the graph of the function is a parabola shifted upward by whose vertex is at , as shown in the center figure.[src] Combining both horizontal and vertical shifts yields is a parabola shifted to the right by and upward by whose vertex is at , as shown in the bottom figure.[src] ==Solving quadratic equations== Completing the square may be used to solve any quadratic equation.[src] For example: x^2 + 6x + 5 = 0.[src] The first step is to complete the square: (x+3)^2 - 4 = 0.[src] Next we solve for the squared term: (x+3)^2 = 4.[src] Then either x+3 = -2 \quad\text{or}\quad x+3 = 2, and therefore x = -5 \quad\text{or}\quad x = -1.[src] This can be applied to any quadratic equation.[src] When the x 2 has a coefficient other than 1, the first step is to divide out the equation by this coefficient: for an example see the non-monic case below.[src] ===Irrational and complex roots=== Unlike methods involving factoring the equation, which is reliable only if the roots are rational, completing the square will find the roots of a quadratic equation even when those roots are irrational or complex.[src] For example, consider the equation x^2 - 10x + 18 = 0.[src] Completing the square gives (x-5)^2 - 7 = 0, so (x-5)^2 = 7.[src] Then either x-5 = -\sqrt{7} \quad\text{or}\quad x-5 = \sqrt{7}.[src] In terser language: x-5 = \pm \sqrt{7}, so x = 5 \pm \sqrt{7}.[src] Equations with complex roots can be handled in the same way.[src] For example: \begin{align} x^2 + 4x + 5 &= 0 \\[6pt] (x+2)^2 + 1 &= 0 \\[6pt] (x+2)^2 &= -1 \\[6pt] x+2 &= \pm i \\[6pt] x &= -2 \pm i.[src] \end{align} ==Other applications== ===Integration=== Completing the square may be used to evaluate any integral of the form \int \frac{dx}{ax^2+bx+c} using the basic integrals \int\frac{dx}{x^2 - a^2} = \frac{1}{2a}\ln\left|\frac{x-a}{x+a}\right| +C \quad\text{and}\quad \int\frac{dx}{x^2 + a^2} = \frac{1}{a}\arctan\left(\frac{x}{a}\right) +C.[src] For example, consider the integral \int \frac{dx}{x^2 + 6x + 13}.[src] Completing the square in the denominator gives: \int \frac{dx}{(x+3)^2 + 4} \,=\, \int\frac{dx}{(x+3)^2 + 2^2}.[src] This can now be evaluated by using the substitution u = x + 3, which yields \int\frac{dx}{(x+3)^2 + 4} \,=\, \frac{1}{2}\arctan\left(\frac{x+3}{2}\right)+C.[src] ===Complex numbers=== Consider the expression |z|^2 - b^*z - bz^* + c, where z and b are complex numbers, z * and b * are the complex conjugates of z and b, respectively, and c is a real number.[src] Using the identity |u| 2 = uu * we can rewrite this as |z-b|^2 - |b|^2 + c , which is clearly a real quantity.[src] This is because \begin{align} |z-b|^2 &{}= (z-b)(z-b)^*\\ &{}= (z-b)(z^*-b^*)\\ &{}= zz^* - zb^* - bz^* + bb^*\\ &{}= |z|^2 - zb^* - bz^* + |b|^2 .[src] \end{align} As another example, the expression ax^2 + by^2 + c , where a, b, c, x, and y are real numbers, with a > 0 and b > 0, may be expressed in terms of the square of the absolute value of a complex number.[src] Define z = \sqrt{a}\,x + i \sqrt{b} \,y .[src] Then \begin{align} |z|^2 &{}= z z^*\\[1ex] &{}= \left(\sqrt{a}\,x + i \sqrt{b}\,y\right) \left(\sqrt{a}\,x - i \sqrt{b}\,y\right) \\[1ex] &{}= ax^2 - i\sqrt{ab}\,xy + i\sqrt{ba}\,yx - i^2 by^2 \\[1ex] &{}= ax^2 + by^2 , \end{align} so ax^2 + by^2 + c = |z|^2 + c .[src] ===Idempotent matrix=== A matrix M is idempotent when M 2 = M.[src] Idempotent matrices generalize the idempotent properties of 0 and 1.[src] The completion of the square method of addressing the equation a^2 + b^2 = a , shows that some idempotent 2×2 matrices are parametrized by a circle in the (a,b)-plane: The matrix \begin{pmatrix}a & b \\ b & 1-a \end{pmatrix} will be idempotent provided a^2 + b^2 = a , which, upon completing the square, becomes (a - \tfrac{1}{2})^2 + b^2 = \tfrac{1}{4} .[src] In the (a,b)-plane, this is the equation of a circle with center (1/2, 0) and radius 1/2.[src] ==Geometric perspective== Consider completing the square for the equation x^2 + bx = a.[src] Since x 2 represents the area of a square with side of length x, and bx represents the area of a rectangle with sides b and x, the process of completing the square can be viewed as visual manipulation of rectangles.[src] Simple attempts to combine the x 2 and the bx rectangles into a larger square result in a missing corner.[src] The term (b/2) 2 added to each side of the above equation is precisely the area of the missing corner, whence derives the terminology "completing the square".[src] ==A variation on the technique== As conventionally taught, completing the square consists of adding the third term, v to u^2 + 2uv to get a square.[src] There are also cases in which one can add the middle term, either 2uv or −2uv, to u^2 + v^2 to get a square.[src] ===Example: the sum of a positive number and its reciprocal=== By writing \begin{align} x + {1 \over x} &{} = \left(x - 2 + {1 \over x}\right) + 2\\ &{}= \left(\sqrt{x} - {1 \over \sqrt{x}}\right)^2 + 2 \end{align} we show that the sum of a positive number x and its reciprocal is always greater than or equal to 2.[src] The square of a real expression is always greater than or equal to zero, which gives the stated bound; and here we achieve 2 just when x is 1, causing the square to vanish.[src] ===Example: factoring a simple quartic polynomial=== Consider the problem of factoring the polynomial x^4 + 324 .[src] This is (x^2)^2 + (18)^2, so the middle term is 2(x 2 )(18) = 36x 2 .[src] Thus we get \begin{align} x^4 + 324 &{}= (x^4 + 36x^2 + 324 ) - 36x^2 \\ &{}= (x^2 + 18)^2 - (6x)^2 =\text{a difference of two squares} \\ &{}= (x^2 + 18 + 6x)(x^2 + 18 - 6x) \\ &{}= (x^2 + 6x + 18)(x^2 - 6x + 18) \end{align} (the last line being added merely to follow the convention of decreasing degrees of terms).[src] The same argument shows that x^4 + 4a^4 is always factorizable as x^4 + 4a^4 = \left(x^2+2a x + 2a^2\right) \left(x^2-2 ax + 2a^2\right) (Also known as Sophie Germain's identity).[src] ==Completing the cube== "Completing the square" consists to remark that the two first terms of a quadratic polynomial are also the first terms of the square of a linear polynomial, and to use this for expressing the quadratic polynomial as the sum of a square and a constant.[src] Completing the cube is a similar technique that allows to transform a cubic polynomial into a cubic polynomial without term of degree two.[src] More precisely, if ax^3+bx^2+cx+d is a polynomial in such that a\ne 0, its two first terms are the two first terms of the expanded form of a\left(x+\frac b {3a}\right)^3=ax^3+bx^2+x\,\frac{b^2}{3a}+\frac {b^3}{27a^2}.[src] So, the change of variable t=x+\frac b {3a} provides a cubic polynomial in t without term of degree two, which is called the depressed form of the original polynomial.[src] This transformation is generally the first step of the methods for solving the general cubic equation.[src] More generally, a similar transformation can be used for removing terms of degree n-1 in polynomials of degree n , which is called Tschirnhaus transformation.[src] ==References== Algebra 1, Glencoe, , pages 539–544 Algebra 2, Saxon, , pages 214–214, 241–242, 256–257, 398–401 ==External links==[src]
97 sentences · 97 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Completing the square." encyclopegia.org, 2026, https://encyclopegia.org/wiki/completing-the-square. Accessed 05 December 2026.
Chicago
"Completing the square." encyclopegia.org. Accessed December 5, 2026. https://encyclopegia.org/wiki/completing-the-square.
APA
encyclopegia.org. (2026). Completing the square. Retrieved December 5, 2026, from https://encyclopegia.org/wiki/completing-the-square
Accessed December 5, 2026 · CC BY-SA 4.0 · citation page · JSON