Unit 2, chapter 10

Completing the square for a shifted quadratic

How completing the square writes an irreducible quadratic with negative discriminant as a shifted and scaled copy of 1 plus u squared, so that a shift and scale substitution leads to the inverse tangent antiderivative.

  • Chapter 10
  • Trigonometric substitution, partial fractions and completing the square

The denominator of 1/(x2+4x+8)1/(x^2 + 4x + 8) has discriminant 16−32=−1616 - 32 = -16, so it has no real roots and does not factor into real linear pieces, and partial fractions with linear denominators do not apply. Completing the square writes it as (x+2)2+4(x + 2)^2 + 4, a shifted and scaled copy of 1+u21 + u^2, and 1/(1+u2)1/(1 + u^2) is exactly the derivative of the inverse tangent. This page explains completing the square, irreducible quadratics and the discriminant test, the inverse tangent antiderivative and the substitution u=(x+2)/2u = (x + 2)/2, and it evaluates the integral from 00 to 22 to 12(arctan⁡2−π/4)\tfrac12(\arctan 2 - \pi/4).

Key terms

Completing the square

Definition For real numbers a≠0a \ne 0, bb and cc and every real xx,

ax2+bx+c=a(x+b2a)2+c−b24a.\begin{aligned} &ax^2 + bx + c \\[0.4em] &\quad = a\Bigl(x + \frac{b}{2a}\Bigr)^2 \\[0.4em] &\qquad + c - \frac{b^2}{4a}. \end{aligned}

The identity follows by expanding the square, and it changes the form of the quadratic, not its value. With h=−b/(2a)h = -b/(2a) and k=c−b2/(4a)k = c - b^2/(4a) it reads a(x−h)2+ka(x - h)^2 + k, so the graph is a parabola with vertex (h,k)(h, k). For a=1a = 1 the rule is to add and subtract the square of half the coefficient of xx.

In plain words Half the coefficient of xx, squared, is the constant that completes a perfect square. Put it inside the square and take it back outside, and the expression keeps its value for every xx while its center becomes visible.

Example For the integral of this page, half of 44 is 22, and (x+2)2=x2+4x+4(x + 2)^2 = x^2 + 4x + 4, so x2+4x+8=(x+2)2+4x^2 + 4x + 8 = (x + 2)^2 + 4. This is at least 44 for every real xx, so the integrand is continuous on [0,2][0, 2]. Factoring out 44 gives 4(1+((x+2)/2)2)4\bigl(1 + ((x + 2)/2)^2\bigr), and the substitution u=(x+2)/2u = (x + 2)/2 has dx=2 dudx = 2\,du and moves the bounds 00 and 22 to 11 and 22. Hence

∫02dxx2+4x+8=∫122 du4(1+u2)=12[arctan⁡u]12=12(arctan⁡2−π4),\begin{aligned} &\int_0^2 \frac{dx}{x^2 + 4x + 8} \\[0.4em] &\quad = \int_1^2 \frac{2\,du}{4(1 + u^2)} \\[0.4em] &\quad = \frac12\Bigl[\arctan u\Bigr]_1^2 \\[0.4em] &\quad = \frac12\Bigl(\arctan 2 - \frac{\pi}{4}\Bigr), \end{aligned}

with the inverse tangent in radians and taking values in (−π/2,π/2)(-\pi/2, \pi/2). The value is about 0.16090.1609. In the original variable the antiderivative is F(x)=12arctan⁡((x+2)/2)F(x) = \tfrac12\arctan\bigl((x + 2)/2\bigr), and the chain rule confirms it,

F′(x)=1/41+(x+2)2/4=1(x+2)2+4.\begin{aligned} F'(x) &= \frac{1/4}{1 + (x + 2)^2/4} \\[0.4em] &= \frac{1}{(x + 2)^2 + 4}. \end{aligned}

As a rough check, the integrand decreases on [0,2][0, 2] from 1/81/8 to 1/201/20, so over this interval of length 22 the integral lies between 1/101/10 and 1/41/4.

Irreducible quadratic

Definition A quadratic ax2+bx+cax^2 + bx + c with real coefficients and a≠0a \ne 0 is irreducible over the real numbers if it cannot be written as a product of two linear factors with real coefficients. This happens exactly when it has no real root, which is the case exactly when b2−4ac<0b^2 - 4ac < 0. Over the complex numbers every quadratic factors, and an irreducible real quadratic has two complex conjugate roots. In a partial fraction decomposition, an irreducible quadratic factor gets a numerator of the form Bx+CBx + C.

In plain words An irreducible quadratic never meets the xx-axis, so it cannot be split into real linear factors. Its reciprocal integrates to an inverse tangent, and a linear numerator adds a logarithm of the quadratic.

Example The quadratic x2+4x+8x^2 + 4x + 8 is irreducible. Its roots are the complex numbers −2±2i-2 \pm 2i, and x2+4x+8=(x+2−2i)(x+2+2i)x^2 + 4x + 8 = (x + 2 - 2i)(x + 2 + 2i). By contrast x2+4x+3=(x+1)(x+3)x^2 + 4x + 3 = (x + 1)(x + 3) is reducible. For a linear numerator, split off a multiple of the derivative 2x+42x + 4 of the quadratic,

x+4x2+4x+8=12(2x+4)x2+4x+8+2x2+4x+8.\begin{aligned} &\frac{x + 4}{x^2 + 4x + 8} \\[0.4em] &\quad = \frac{\tfrac12(2x + 4)}{x^2 + 4x + 8} \\[0.4em] &\qquad + \frac{2}{x^2 + 4x + 8}. \end{aligned}

The first part integrates to 12ln⁡(x2+4x+8)\tfrac12\ln(x^2 + 4x + 8), with no absolute value because the quadratic is positive, and the second to arctan⁡((x+2)/2)\arctan\bigl((x + 2)/2\bigr). So the antiderivatives on the whole real line are 12ln⁡(x2+4x+8)+arctan⁡((x+2)/2)+C\tfrac12\ln(x^2 + 4x + 8) + \arctan\bigl((x + 2)/2\bigr) + C.

Negative discriminant

Definition The discriminant of ax2+bx+cax^2 + bx + c, with a≠0a \ne 0, is Δ=b2−4ac\Delta = b^2 - 4ac. Completing the square gives

ax2+bx+c=a(x+b2a)2−Δ4a.\begin{aligned} &ax^2 + bx + c \\[0.4em] &\quad = a\Bigl(x + \frac{b}{2a}\Bigr)^2 - \frac{\Delta}{4a}. \end{aligned}

If Δ<0\Delta < 0, the second term −Δ/(4a)-\Delta/(4a) is not 00 and has the sign of aa, and the first term is 00 or has the sign of aa. So the quadratic is never 00 and has the sign of aa for every real xx. Its value −Δ/(4a)-\Delta/(4a) at x=−b/(2a)x = -b/(2a) is the minimum when a>0a > 0 and the maximum when a<0a < 0. If Δ=0\Delta = 0, the quadratic is a(x+b/(2a))2a\bigl(x + b/(2a)\bigr)^2, with one repeated real root, and if Δ>0\Delta > 0, it has the two distinct real roots (−b±Δ)/(2a)\bigl(-b \pm \sqrt{\Delta}\bigr)/(2a).

In plain words A negative discriminant means that the quadratic has no real roots and keeps one sign. Its reciprocal is then continuous on the whole real line, so an integral of the reciprocal over any interval has no singularity.

Example For x2+4x+8x^2 + 4x + 8, the discriminant is 16−32=−1616 - 32 = -16. The minimum value is 16/4=416/4 = 4, at x=−2x = -2, where the integrand 1/(x2+4x+8)1/(x^2 + 4x + 8) has its highest point 1/41/4. The interval [0,2][0, 2] lies to the right of this peak, where the integrand decreases. For 2x2−4x+52x^2 - 4x + 5, the discriminant is 16−40=−2416 - 40 = -24, and the minimum value is 24/8=324/8 = 3, at x=1x = 1. For x2+4x+3x^2 + 4x + 3, the discriminant is 16−12=4>016 - 12 = 4 > 0, and the roots are −1-1 and −3-3.

Inverse tangent antiderivative

Definition For every real uu, the inverse tangent arctan⁡u\arctan u, also written tan⁡−1u\tan^{-1} u, is the unique angle θ\theta in the open interval (−π/2,π/2)(-\pi/2, \pi/2) with tan⁡θ=u\tan\theta = u, measured in radians. It is differentiable on the whole real line, with

dduarctan⁡u=11+u2,\frac{d}{du}\arctan u = \frac{1}{1 + u^2},

because u=tan⁡θu = \tan\theta gives du/dθ=sec⁡2θ=1+tan⁡2θ=1+u2du/d\theta = \sec^2\theta = 1 + \tan^2\theta = 1 + u^2, which is positive, and the derivative of an inverse function is the reciprocal of this rate. Consequently, for a constant a>0a > 0 and on the whole real line,

∫duu2+a2=1aarctan⁡ua+C.\begin{aligned} &\int \frac{du}{u^2 + a^2} \\[0.4em] &\quad = \frac1a\arctan\frac{u}{a} + C. \end{aligned}

In plain words The function 1/(1+u2)1/(1 + u^2) is the rate of change of an angle. Its integral from pp to qq is the change in the angle whose tangent is uu, from arctan⁡p\arctan p to arctan⁡q\arctan q.

Example Since arctan⁡1=π/4\arctan 1 = \pi/4,

∫12du1+u2=arctan⁡2−π4≈1.1071−0.7854≈0.3218.\begin{aligned} &\int_1^2 \frac{du}{1 + u^2} = \arctan 2 - \frac{\pi}{4} \\[0.4em] &\quad \approx 1.1071 - 0.7854 \\[0.4em] &\quad \approx 0.3218. \end{aligned}

The value arctan⁡2\arctan 2 is not a standard angle, so it stays in the exact answer. The angles must be in radians. In degrees the same difference would be about 18.4318.43, which is not the integral.

Shift and scale substitution

Definition For constants hh and k>0k > 0, the substitution u=(x−h)/ku = (x - h)/k, with x=h+kux = h + ku and dx=k dudx = k\,du, turns (x−h)2+k2(x - h)^2 + k^2 into k2(1+u2)k^2(1 + u^2). A definite integral from x=px = p to x=qx = q becomes an integral from u=(p−h)/ku = (p - h)/k to u=(q−h)/ku = (q - h)/k, and on the whole real line

∫dx(x−h)2+k2=1karctan⁡x−hk+C.\begin{aligned} &\int \frac{dx}{(x - h)^2 + k^2} \\[0.4em] &\quad = \frac1k\arctan\frac{x - h}{k} + C. \end{aligned}

In plain words The shift moves the center of the quadratic to u=0u = 0, and dividing by kk makes the constant term 11. The width factor dx=k dudx = k\,du and the height factor 1/k21/k^2 combine into the single factor 1/k1/k in front. Forgetting the width factor is the most common slip.

Example Completing the square gives x2−2x+10=(x−1)2+9x^2 - 2x + 10 = (x - 1)^2 + 9, so h=1h = 1 and k=3k = 3. With u=(x−1)/3u = (x - 1)/3, the bounds 11 and 44 become 00 and 11, and

∫14dxx2−2x+10=13∫01du1+u2=13⋅π4=π12,\begin{aligned} &\int_1^4 \frac{dx}{x^2 - 2x + 10} \\[0.4em] &\quad = \frac13\int_0^1 \frac{du}{1 + u^2} \\[0.4em] &\quad = \frac13 \cdot \frac{\pi}{4} = \frac{\pi}{12}, \end{aligned}

which is about 0.26180.2618. Leaving out dx=3 dudx = 3\,du would give π/36\pi/36, three times too small. As a check, the integrand decreases on [1,4][1, 4] from 1/91/9 to 1/181/18, so over this interval of length 33 the integral lies between 1/61/6 and 1/31/3. The integral from 00 to 22 above is the case h=−2h = -2 and k=2k = 2.

Check yourself

  1. Evaluate the integral below.
∫−11dxx2+2x+5\int_{-1}^{1} \frac{dx}{x^2 + 2x + 5}
Show the answer

Completing the square gives x2+2x+5=(x+1)2+4x^2 + 2x + 5 = (x + 1)^2 + 4, which is at least 44, so the integrand is continuous everywhere. With u=(x+1)/2u = (x + 1)/2 and dx=2 dudx = 2\,du, the bounds −1-1 and 11 become 00 and 11, and

∫−11dxx2+2x+5=24∫01du1+u2=12⋅π4=π8,\begin{aligned} &\int_{-1}^{1} \frac{dx}{x^2 + 2x + 5} \\[0.4em] &\quad = \frac{2}{4}\int_0^1 \frac{du}{1 + u^2} \\[0.4em] &\quad = \frac12 \cdot \frac{\pi}{4} = \frac{\pi}{8}, \end{aligned}

which is about 0.39270.3927. The integrand decreases from 1/41/4 to 1/81/8 on this interval of length 22, so the value lies between 1/41/4 and 1/21/2, and it does.

  1. Evaluate the integral below, taking care with the leading coefficient.
∫01dx4x2+4x+2\int_0^1 \frac{dx}{4x^2 + 4x + 2}
Show the answer

The discriminant is 16−32=−16<016 - 32 = -16 < 0, so the quadratic is irreducible. Completing the square with the leading coefficient factored out gives 4x2+4x+2=4(x+12)2+1=(2x+1)2+14x^2 + 4x + 2 = 4\bigl(x + \tfrac12\bigr)^2 + 1 = (2x + 1)^2 + 1. With u=2x+1u = 2x + 1 and dx=12 dudx = \tfrac12\,du, the bounds 00 and 11 become 11 and 33, so

∫01dx4x2+4x+2=12∫13du1+u2=12(arctan⁡3−π4),\begin{aligned} &\int_0^1 \frac{dx}{4x^2 + 4x + 2} \\[0.4em] &\quad = \frac12\int_1^3 \frac{du}{1 + u^2} \\[0.4em] &\quad = \frac12\Bigl(\arctan 3 - \frac{\pi}{4}\Bigr), \end{aligned}

which is about 0.23180.2318. The integrand decreases from 1/21/2 to 1/101/10 on an interval of length 11, consistent with the value. Dropping the factor 12\tfrac12 that comes from dxdx would give about 0.46360.4636, twice the correct value.

  1. Someone completes the square in x2+4x+3x^2 + 4x + 3 and writes arctan⁡(x+2)+C\arctan(x + 2) + C as the antiderivative of 1/(x2+4x+3)1/(x^2 + 4x + 3). What went wrong? Evaluate the integral of 1/(x2+4x+3)1/(x^2 + 4x + 3) from 00 to 11.
Show the answer

The discriminant is 16−12=4>016 - 12 = 4 > 0, so the quadratic is reducible, and completing the square gives (x+2)2−1(x + 2)^2 - 1, a difference rather than a sum. The inverse tangent form needs (x−h)2+k2(x - h)^2 + k^2 with k>0k > 0. Differentiating the claimed answer exposes the error, since the derivative of arctan⁡(x+2)\arctan(x + 2) is 1/((x+2)2+1)=1/(x2+4x+5)1/\bigl((x + 2)^2 + 1\bigr) = 1/(x^2 + 4x + 5). Partial fractions apply instead. From x2+4x+3=(x+1)(x+3)x^2 + 4x + 3 = (x + 1)(x + 3) and 1=A(x+3)+B(x+1)1 = A(x + 3) + B(x + 1), the value x=−1x = -1 gives A=1/2A = 1/2 and the value x=−3x = -3 gives B=−1/2B = -1/2. The poles −1-1 and −3-3 lie outside [0,1][0, 1], where both factors are positive, so

∫01dxx2+4x+3=12[ln⁡x+1x+3]01=12(ln⁡12−ln⁡13)=12ln⁡32.\begin{aligned} &\int_0^1 \frac{dx}{x^2 + 4x + 3} \\[0.4em] &\quad = \frac12\Bigl[\ln\frac{x + 1}{x + 3}\Bigr]_0^1 \\[0.4em] &\quad = \frac12\Bigl(\ln\frac12 - \ln\frac13\Bigr) \\[0.4em] &\quad = \frac12\ln\frac32. \end{aligned}

After the shift v=x+2v = x + 2, this is the integral of 1/(v2−1)1/(v^2 - 1) from 22 to 33, worked on the page on partial fractions.

How this lesson connects

It also uses expanding a square and the derivative of inverse tangent.