Samiksha Jaiswal (Editor)

Completing the square

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Completing the square

In elementary algebra, completing the square is a technique for converting a quadratic polynomial of the form

Contents

a x 2 + b x + c

to the form

a ( ) 2 + constant .

In this context, "constant" means not depending on x. The expression inside the parenthesis is of the form (x + constant). Thus

a x 2 + b x + c is converted to a ( x h ) 2 + k

for some values of h and k.

Completing the square is used in

  • solving quadratic equations,
  • graphing quadratic functions,
  • evaluating integrals in calculus, such as Gaussian integrals with a linear term in the exponent
  • finding Laplace transforms.
  • In mathematics, completing the square is often applied in any computation involving quadratic polynomials. Completing the square is also used to derive the quadratic formula.

    Background

    There is a simple formula in elementary algebra for computing the square of a binomial:

    ( x + p ) 2 = x 2 + 2 p x + p 2 .

    For example:

    ( x + 3 ) 2 = x 2 + 6 x + 9 ( p = 3 ) ( x 5 ) 2 = x 2 10 x + 25 ( p = 5 ) .

    In any perfect square, the coefficient of x is twice the number p, and the constant term is equal to p2.

    Basic example

    Consider the following quadratic polynomial:

    x 2 + 10 x + 28.

    This quadratic is not a perfect square, since 28 is not the square of 5:

    ( x + 5 ) 2 = x 2 + 10 x + 25.

    However, it is possible to write the original quadratic as the sum of this square and a constant:

    x 2 + 10 x + 28 = ( x + 5 ) 2 + 3.

    This is called completing the square.

    General description

    Given any monic quadratic

    x 2 + b x + c ,

    it is possible to form a square that has the same first two terms:

    ( x + 1 2 b ) 2 = x 2 + b x + 1 4 b 2 .

    This square differs from the original quadratic only in the value of the constant term. Therefore, we can write

    x 2 + b x + c = ( x + 1 2 b ) 2 + k ,

    where k is a constant. This operation is known as completing the square. For example:

    x 2 + 6 x + 11 = ( x + 3 ) 2 + 2 x 2 + 14 x + 30 = ( x + 7 ) 2 19 x 2 2 x + 7 = ( x 1 ) 2 + 6.

    Non-monic case

    Given a quadratic polynomial of the form

    a x 2 + b x + c

    it is possible to factor out the coefficient a, and then complete the square for the resulting monic polynomial.

    Example:

    3 x 2 + 12 x + 27 = 3 ( x 2 + 4 x + 9 ) = 3 ( ( x + 2 ) 2 + 5 ) = 3 ( x + 2 ) 2 + 15

    This allows us to write any quadratic polynomial in the form

    a ( x h ) 2 + k .

    Formula

    The result of completing the square may be written as a formula. For the general case:

    a x 2 + b x + c = a ( x h ) 2 + k , where h = b 2 a and k = c a h 2 = c b 2 4 a .

    Specifically, when a=1:

    x 2 + b x + c = ( x h ) 2 + k , where h = b 2 and k = c b 2 4 .

    The matrix case looks very similar:

    x T A x + x T b + c = ( x h ) T A ( x h ) + k where h = 1 2 A 1 b and k = c 1 4 b T A 1 b

    where A has to be symmetric.

    If A is not symmetric the formulae for h and k have to be generalized to:

    h = ( A + A T ) 1 b and k = c h T A h = c b T ( A + A T ) 1 A ( A + A T ) 1 b .

    Relation to the graph

    In analytic geometry, the graph of any quadratic function is a parabola in the xy-plane. Given a quadratic polynomial of the form

    ( x h ) 2 + k or a ( x h ) 2 + k

    the numbers h and k may be interpreted as the Cartesian coordinates of the vertex of the parabola. That is, h is the x-coordinate of the axis of symmetry, and k is the minimum value (or maximum value, if a < 0) of the quadratic function.

    One way to see this is to note that the graph of the function ƒ(x) = x2 is a parabola whose vertex is at the origin (0, 0). Therefore, the graph of the function ƒ(x − h) = (x − h)2 is a parabola shifted to the right by h whose vertex is at (h, 0), as shown in the top figure. In contrast, the graph of the function ƒ(x) + kx2 + k is a parabola shifted upward by k whose vertex is at (0, k), as shown in the center figure. Combining both horizontal and vertical shifts yields ƒ(x − h) + k = (x − h)2 + k is a parabola shifted to the right by h and upward by k whose vertex is at (hk), as shown in the bottom figure.

    Solving quadratic equations

    Completing the square may be used to solve any quadratic equation. For example:

    x 2 + 6 x + 5 = 0 ,

    The first step is to complete the square:

    ( x + 3 ) 2 4 = 0.

    Next we solve for the squared term:

    ( x + 3 ) 2 = 4.

    Then either

    x + 3 = 2 or x + 3 = 2 ,

    and therefore

    x = 5 or x = 1.

    This can be applied to any quadratic equation. When the x2 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.

    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. For example, consider the equation

    x 2 10 x + 18 = 0.

    Completing the square gives

    ( x 5 ) 2 7 = 0 ,

    so

    ( x 5 ) 2 = 7.

    Then either

    x 5 = 7 or x 5 = 7 ,

    so

    x = 5 7 or x = 5 + 7 .

    In terser language:

    x = 5 ± 7 .

    Equations with complex roots can be handled in the same way. For example:

    x 2 + 4 x + 5 = 0 ( x + 2 ) 2 + 1 = 0 ( x + 2 ) 2 = 1 x + 2 = ± i x = 2 ± i .

    Non-monic case

    For an equation involving a non-monic quadratic, the first step to solving them is to divide through by the coefficient of x2. For example:

    2 x 2 + 7 x + 6 = 0 x 2 + 7 2 x + 3 = 0 ( x + 7 4 ) 2 1 16 = 0 ( x + 7 4 ) 2 = 1 16 x + 7 4 = 1 4 or x + 7 4 = 1 4 x = 3 2 or x = 2.

    Applying this procedure to the general form of a quadratic equation leads to the quadratic formula.

    Integration

    Completing the square may be used to evaluate any integral of the form

    d x a x 2 + b x + c

    using the basic integrals

    d x x 2 a 2 = 1 2 a ln | x a x + a | + C and d x x 2 + a 2 = 1 a arctan ( x a ) + C .

    For example, consider the integral

    d x x 2 + 6 x + 13 .

    Completing the square in the denominator gives:

    d x ( x + 3 ) 2 + 4 = d x ( x + 3 ) 2 + 2 2 .

    This can now be evaluated by using the substitution u = x + 3, which yields

    d x ( x + 3 ) 2 + 4 = 1 2 arctan ( x + 3 2 ) + C .

    Complex numbers

    Consider the expression

    | z | 2 b z b z + 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. Using the identity |u|2 = uu* we can rewrite this as

    | z b | 2 | b | 2 + c ,

    which is clearly a real quantity. This is because

    | z b | 2 = ( z b ) ( z b ) = ( z b ) ( z b ) = z z z b b z + b b = | z | 2 z b b z + | b | 2 .

    As another example, the expression

    a x 2 + b y 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. Define

    z = a x + i b y .

    Then

    | z | 2 = z z = ( a x + i b y ) ( a x i b y ) = a x 2 i a b x y + i b a y x i 2 b y 2 = a x 2 + b y 2 ,

    so

    a x 2 + b y 2 + c = | z | 2 + c .

    Idempotent matrix

    A matrix M is idempotent when M 2 = M. Idempotent matrices generalize the idempotent properties of 0 and 1. 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 ( a b b 1 a ) will be idempotent provided a 2 + b 2 = a , which, upon completing the square, becomes

    ( a 1 2 ) 2 + b 2 = 1 4 .

    In the (a,b)-plane, this is the equation of a circle with center (1/2, 0) and radius 1/2.

    Geometric perspective

    Consider completing the square for the equation

    x 2 + b x = a .

    Since x2 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.

    Simple attempts to combine the x2 and the bx rectangles into a larger square result in a missing corner. 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".

    A variation on the technique

    As conventionally taught, completing the square consists of adding the third term, v 2 to

    u 2 + 2 u v

    to get a square. 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.

    Example: the sum of a positive number and its reciprocal

    By writing

    x + 1 x = ( x 2 + 1 x ) + 2 = ( x 1 x ) 2 + 2

    we show that the sum of a positive number x and its reciprocal is always greater than or equal to 2. 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.

    Example: factoring a simple quartic polynomial

    Consider the problem of factoring the polynomial

    x 4 + 324.

    This is

    ( x 2 ) 2 + ( 18 ) 2 ,

    so the middle term is 2(x2)(18) = 36x2. Thus we get

    x 4 + 324 = ( x 4 + 36 x 2 + 324 ) 36 x 2 = ( x 2 + 18 ) 2 ( 6 x ) 2 = a difference of two squares = ( x 2 + 18 + 6 x ) ( x 2 + 18 6 x ) = ( x 2 + 6 x + 18 ) ( x 2 6 x + 18 )

    (the last line being added merely to follow the convention of decreasing degrees of terms).

    References

    Completing the square Wikipedia


    Similar Topics