Completing the square inside an integral
The arctangent form fits one over one plus x squared exactly. What do you do with one over x squared plus six x plus ten, which matches nothing in the table?
Where you are 16 in Integrals
When you reach for it
The arctangent and arcsine forms from Antiderivatives of trig, exponential and log functions fit \dfrac{1}{1 + x^2} and \displaystyle \dfrac{1}{\sqrt{1 - x^2}} exactly, and nothing else. An integrand such as \dfrac{1}{x^2 + 6x + 10} matches no line of that table, and splitting the quotient does not help. But its denominator is a parabola that never reaches zero, and completing the square writes it as (x + 3)^2 + 1: the denominator 1 + x^2 with x replaced by x + 3. The graph is the arctangent integrand slid 3 units left, and its antiderivative is \arctan x slid the same way.
Reach for this move when a quadratic with no real roots sits in a denominator, either alone or under a linear numerator, and when a quadratic that opens downward sits under a square root in a denominator.
The procedure
Reshaping the quadratic
Completing the square rewrites any quadratic with leading coefficient 1:
Write \displaystyle h = -\frac{b}{2}. The constant \displaystyle c - \frac{b^2}{4} equals \displaystyle -\frac{1}{4}\left(b^2 - 4c\right), so it is positive exactly when the discriminant b^2 - 4c is negative, that is, when the quadratic has no real roots. Then it is a square k^2 with k > 0, and
A leading coefficient other than 1 is factored out of the denominator first and comes outside the integral as a constant. Under a square root the quadratic usually opens downward: factor out -1, complete the square inside, and distribute the -1 back, which gives k^2 - (x - h)^2.
The two shifted forms
For k > 0,
the second on the interval h - k < x < h + k.
Both are checked by differentiating with the chain rule and the derivatives from Derivatives of inverse trigonometric functions. The inside function \displaystyle \frac{x - h}{k} has derivative \displaystyle \frac{1}{k}, so
after multiplying the k^2 into the denominator. For the arcsine,
The last step moves k inside the root as \displaystyle \sqrt{k^2}, which equals k only because k > 0. The arcsine derivative exists only when \displaystyle -1 < \frac{x - h}{k} < 1, which is h - k < x < h + k, and that is also exactly where k^2 - (x - h)^2 is positive.
Figure 1 shows why the shift costs nothing. Replacing x by x - h slides a graph h units right, and every area under it slides along unchanged. Renaming x - h as a single letter u is the simplest case of u-substitution; here each answer is confirmed by differentiating instead.
A linear numerator
For \dfrac{px + q}{x^2 + bx + c}, compare the numerator with the derivative of the denominator, 2x + b. Any linear numerator splits as a multiple of 2x + b plus a constant:
The first piece is \displaystyle \frac{p}{2} times \dfrac{2x + b}{x^2 + bx + c}, the derivative of the denominator over the denominator. By the chain rule (Derivatives of logarithms and logarithmic differentiation), \dfrac{d}{dx}\big[\ln Q(x)\big] = \dfrac{Q'(x)}{Q(x)} wherever Q(x) > 0, so that piece integrates to \displaystyle \frac{p}{2}\ln\left(x^2 + bx + c\right). No absolute value is needed, since (x - h)^2 + k^2 \ge k^2 > 0 for every x. The second piece is a constant times the arctangent form.
Worked examples
The plain case
Find \int \dfrac{dx}{x^2 + 6x + 10}.
SolutionHalf of 6 is 3 and 3^2 = 9, so x^2 + 6x + 10 = (x + 3)^2 + 1. Here h = -3 and k = 1, and the arctangent form gives
Check: \dfrac{d}{dx}\big[\arctan(x + 3)\big] = \dfrac{1}{1 + (x + 3)^2} \cdot 1, and 1 + (x + 3)^2 = x^2 + 6x + 10. The answer holds for every real x, because the denominator is never zero.
A constant on top and a square that is not 1
Find \int \dfrac{5}{x^2 - 8x + 25}\,dx.
SolutionHalf of -8 is -4, and (-4)^2 = 16, so x^2 - 8x + 25 = (x - 4)^2 + 9. The constant 5 comes out, and h = 4, k = 3:
Check: the derivative is \displaystyle \dfrac{5}{3} \cdot \dfrac{1}{1 + \frac{(x - 4)^2}{9}} \cdot \dfrac{1}{3}, which is \dfrac{5}{9 + (x - 4)^2}. Without the factor \displaystyle \frac{1}{k} in front, the derivative would come out 3 times too large.
Hiwa and Sirwan, a fraction and a root
Find \int \dfrac{dx}{x^2 + 3x + 3}. Hiwa gets \displaystyle \dfrac{2}{\sqrt{3}}\arctan\dfrac{2x + 3}{\sqrt{3}} + C; Sirwan gets \displaystyle \dfrac{2\sqrt{3}}{3}\arctan\dfrac{\sqrt{3}(2x + 3)}{3} + C. Who is right?
SolutionHalf of 3 is \displaystyle \frac{3}{2} and \displaystyle \left(\frac{3}{2}\right)^2 = \frac{9}{4}, so
So \displaystyle h = -\frac{3}{2} and \displaystyle k = \sqrt{\frac{3}{4}} = \frac{\sqrt{3}}{2}. Then \displaystyle \frac{1}{k} = \frac{2}{\sqrt{3}}, and \displaystyle \dfrac{x - h}{k} = \dfrac{x + \frac{3}{2}}{\frac{\sqrt{3}}{2}} = \dfrac{2x + 3}{\sqrt{3}}, which is Hiwa’s answer. Check:
which is \dfrac{1}{x^2 + 3x + 3}. Sirwan is right too: he rationalized, and \displaystyle \frac{1}{\sqrt{3}} = \frac{\sqrt{3}}{3}, so his function is Hiwa’s written another way, with the same constant C.
A leading coefficient that is not 1
Find \int \dfrac{dx}{9x^2 - 6x + 5}.
SolutionFactor 9 out of the denominator, then complete the square inside. Half of \displaystyle -\frac{2}{3} is \displaystyle -\frac{1}{3}, whose square is \displaystyle \frac{1}{9}:
So \displaystyle h = \frac{1}{3} and \displaystyle k = \frac{2}{3}, and the \displaystyle \frac{1}{9} comes outside:
Since 9x^2 is the square of 3x, the same square appears faster as 9x^2 - 6x + 5 = (3x - 1)^2 + 4. Check either way: the derivative of \displaystyle \frac{1}{6}\arctan\frac{3x - 1}{2} is \displaystyle \dfrac{1}{6}\cdot\dfrac{3}{2}\cdot\dfrac{1}{1 + \frac{(3x - 1)^2}{4}}, which is \dfrac{1}{(3x - 1)^2 + 4}.
A downward quadratic under a root
Find \displaystyle \int \dfrac{dx}{\sqrt{8 + 2x - x^2}} and say where the answer holds.
SolutionFactor out -1 and complete the square inside:
So k = 3 and h = 1, and the arcsine form gives
on the interval -2 < x < 4. That interval is h - k < x < h + k. It is also where the integrand is defined: 8 + 2x - x^2 = (4 - x)(2 + x) is positive exactly between its roots -2 and 4. Check: the derivative of \displaystyle \arcsin\frac{x - 1}{3} is \displaystyle \dfrac{1}{3}\cdot\dfrac{1}{\sqrt{1 - \frac{(x - 1)^2}{9}}} = \dfrac{1}{\sqrt{9 - (x - 1)^2}}.
Arez splits a linear numerator
Arez needs \int \dfrac{2x + 7}{x^2 + 2x + 5}\,dx.
SolutionThe derivative of the denominator is 2x + 2, and 2x + 7 = (2x + 2) + 5. So the integral splits:
The first is the derivative of the denominator over the denominator, so it gives \ln\left(x^2 + 2x + 5\right), with no absolute value because the denominator is always positive. The second has h = -1 and k = 2. Together,
Check: the derivative is \displaystyle \dfrac{2x + 2}{x^2 + 2x + 5} + \dfrac{5}{2}\cdot\dfrac{1}{2}\cdot\dfrac{1}{1 + \frac{(x + 1)^2}{4}}, and the second term is \dfrac{5}{4 + (x + 1)^2} = \dfrac{5}{x^2 + 2x + 5}. The two terms add to the integrand.
A definite integral, and a quadratic that factors
(a) Evaluate \int_1^4 \dfrac{dx}{x^2 - 2x + 10}. (b) Sirwan tries the same move on \dfrac{1}{x^2 - 2x - 3}. What goes wrong?
Solution(a) x^2 - 2x + 10 = (x - 1)^2 + 9, so \displaystyle \frac{1}{3}\arctan\frac{x - 1}{3} is an antiderivative on all of [1, 4], where the integrand is continuous. By the fundamental theorem,
(b) Completing the square gives x^2 - 2x - 3 = (x - 1)^2 - 4, a square minus 4 rather than plus. The arctangent form needs a plus: the derivative of \displaystyle \frac{1}{2}\arctan\frac{x - 1}{2} is \dfrac{1}{(x - 1)^2 + 4}, a different function. The discriminant 4 + 12 = 16 is positive, and indeed x^2 - 2x - 3 = (x - 3)(x + 1). Such an integrand has vertical asymptotes at x = 3 and x = -1, and its antiderivative is a combination of logarithms found by partial fractions, a later topic.
Boundaries
- The arctangent form needs no real roots. Only when b^2 - 4c < 0 does completing the square give a square plus a positive k^2. When b^2 - 4c > 0 the quadratic factors and the integrand is split by partial fractions. When b^2 - 4c = 0 the quadratic is a perfect square (x - h)^2, and the power rule gives \displaystyle \int \frac{dx}{(x - h)^2} = -\frac{1}{x - h} + C on each side of h.
- The arcsine form needs a positive constant minus a square, so a downward quadratic with two real roots, and it holds only strictly between those roots. A square root of (x - h)^2 + k^2 or of (x - h)^2 - k^2 is a different shape, handled by Trigonometric substitution.
- The formulas use k > 0. A negative k flips the sign of the arcsine formula (Exercise 23).
- A definite integral needs continuity on [a, b]. A denominator (x - h)^2 + k^2 is never zero, so the arctangent form works on any interval. The arcsine form works on [a, b] only if it sits strictly inside (h - k, h + k); at h \pm k the integrand is unbounded and the integral is improper.
- The numerator must be of lower degree. A numerator of degree 2 or more is divided first, by Dividing before integrating.
Where this goes next
u-substitution names the shift u = x - h as one case of a general method. Partial fractions breaks a rational function into pieces, and every piece over an irreducible quadratic is integrated exactly as in Example 6, as a log part plus an arctangent part. Dividing before integrating often leaves such a piece as a remainder. Trigonometric substitution completes the square in the same way and then handles square roots of (x - h)^2 + k^2 and (x - h)^2 - k^2. With improper integrals, the arctangent form shows that the area under \dfrac{1}{(x - h)^2 + k^2} over the whole line is \dfrac{\pi}{k}.
Exercises
The arctangent form
- Find \int \dfrac{dx}{x^2 + 4x + 5}.
- Find \int \dfrac{dx}{x^2 - 6x + 13}.
- Find \int \dfrac{3}{x^2 + 8x + 41}\,dx.
- Find \int \dfrac{dx}{x^2 + 2x + 3}.
- Find \int \dfrac{dx}{x^2 - 3x + 4}.
- Find \int \dfrac{dt}{t^2 + 2t + 17}.
A leading coefficient first
- Find \int \dfrac{dx}{4x^2 + 4x + 5}.
- Find \int \dfrac{dx}{2x^2 - 4x + 4}.
- Find \int \dfrac{dx}{3x^2 + 6x + 15}.
The arcsine form
- Find \displaystyle \int \dfrac{dx}{\sqrt{4x - x^2}} and say where it holds.
- Find \displaystyle \int \dfrac{dx}{\sqrt{-x^2 - 6x - 5}} and say where it holds.
- Find \displaystyle \int \dfrac{dx}{\sqrt{5 + 4x - x^2}} and say where it holds.
A linear numerator
- Find \int \dfrac{2x + 4}{x^2 + 4x + 13}\,dx.
- Find \int \dfrac{x + 3}{x^2 + 2x + 10}\,dx.
- Find \int \dfrac{3x - 1}{x^2 - 4x + 20}\,dx.
- Find \int \dfrac{x}{x^2 + 6x + 18}\,dx.
Definite integrals
- Evaluate \int_{-1}^{1} \dfrac{dx}{x^2 + 2x + 5}.
- Evaluate \int_2^5 \dfrac{dx}{x^2 - 4x + 7}.
- Evaluate \displaystyle \int_1^2 \dfrac{dx}{\sqrt{3 + 2x - x^2}}.
- Evaluate \int_1^5 \dfrac{x + 1}{x^2 - 2x + 17}\,dx.
Reasoning
- For each denominator, say whether \displaystyle \int \frac{dx}{Q(x)} is an arctangent form, and find the integral where the methods so far apply: (a) Q(x) = x^2 + 6x + 8, (b) Q(x) = x^2 + 6x + 9, (c) Q(x) = x^2 + 6x + 11.
- Arez writes \int \dfrac{dx}{x^2 + 4x + 20} = \arctan\dfrac{x + 2}{4} + C. Find the error by differentiating, and correct it.
- Hiwa says Example 5 could use k = -3 just as well, giving \arcsin\dfrac{x - 1}{-3} + C. Differentiate her function and explain what the condition k > 0 is for.
- Explain why the log part of a linear-numerator integral needs no absolute value, and why the arctangent form holds for every real x.
- Show that \int_h^{h + k} \dfrac{dx}{(x - h)^2 + k^2} = \dfrac{\pi}{4k} for every h and every k > 0, and use Figure 1 to explain why the answer does not depend on h.
Answers
- \arctan(x + 2) + C. The denominator is (x + 2)^2 + 1.
- \dfrac{1}{2}\arctan\dfrac{x - 3}{2} + C. The denominator is (x - 3)^2 + 4, so k = 2.
- \dfrac{3}{5}\arctan\dfrac{x + 4}{5} + C. The denominator is (x + 4)^2 + 25.
- \displaystyle \dfrac{1}{\sqrt{2}}\arctan\dfrac{x + 1}{\sqrt{2}} + C. The denominator is (x + 1)^2 + 2, so \displaystyle k = \sqrt{2}.
- \displaystyle \dfrac{2}{\sqrt{7}}\arctan\dfrac{2x - 3}{\sqrt{7}} + C. The denominator is \displaystyle \left(x - \frac{3}{2}\right)^2 + \frac{7}{4}, so \displaystyle k = \frac{\sqrt{7}}{2} and \displaystyle \frac{x - 3/2}{k} = \frac{2x - 3}{\sqrt{7}}.
- \dfrac{1}{4}\arctan\dfrac{t + 1}{4} + C. The denominator is (t + 1)^2 + 16.
- \dfrac{1}{4}\arctan\dfrac{2x + 1}{2} + C. The denominator is (2x + 1)^2 + 4, and the derivative of the answer is \displaystyle \frac{1}{4}\cdot\frac{2}{2}\cdot\frac{4}{4 + (2x + 1)^2}, the integrand.
- \dfrac{1}{2}\arctan(x - 1) + C. The denominator is 2\left[(x - 1)^2 + 1\right].
- \dfrac{1}{6}\arctan\dfrac{x + 1}{2} + C. The denominator is 3\left[(x + 1)^2 + 4\right], so the answer is \displaystyle \frac{1}{3}\cdot\frac{1}{2}\arctan\frac{x + 1}{2}.
- \arcsin\dfrac{x - 2}{2} + C on 0 < x < 4. Here 4x - x^2 = 4 - (x - 2)^2.
- \arcsin\dfrac{x + 3}{2} + C on -5 < x < -1. Here -x^2 - 6x - 5 = -\left[(x + 3)^2 - 4\right], which is 4 - (x + 3)^2.
- \arcsin\dfrac{x - 2}{3} + C on -1 < x < 5. Here 5 + 4x - x^2 = 9 - (x - 2)^2.
- \ln\left(x^2 + 4x + 13\right) + C. The numerator is exactly the derivative of the denominator, so there is no arctangent part.
- \dfrac{1}{2}\ln\left(x^2 + 2x + 10\right) + \dfrac{2}{3}\arctan\dfrac{x + 1}{3} + C. Split \displaystyle x + 3 = \frac{1}{2}(2x + 2) + 2; the denominator is (x + 1)^2 + 9.
- \dfrac{3}{2}\ln\left(x^2 - 4x + 20\right) + \dfrac{5}{4}\arctan\dfrac{x - 2}{4} + C. Split \displaystyle 3x - 1 = \frac{3}{2}(2x - 4) + 5; the denominator is (x - 2)^2 + 16.
- \dfrac{1}{2}\ln\left(x^2 + 6x + 18\right) - \arctan\dfrac{x + 3}{3} + C. Split \displaystyle x = \frac{1}{2}(2x + 6) - 3; the denominator is (x + 3)^2 + 9, and \displaystyle -3 \cdot \frac{1}{3} = -1.
- \dfrac{\pi}{8}. The antiderivative \displaystyle \frac{1}{2}\arctan\frac{x + 1}{2} runs from \displaystyle \frac{1}{2}\arctan 0 = 0 to \displaystyle \frac{1}{2}\arctan 1 = \frac{\pi}{8}.
- \displaystyle \dfrac{\pi\sqrt{3}}{9}. The denominator is (x - 2)^2 + 3; the antiderivative \displaystyle \frac{1}{\sqrt{3}}\arctan\frac{x - 2}{\sqrt{3}} gives \displaystyle \frac{1}{\sqrt{3}}\cdot\frac{\pi}{3} - 0, which is \displaystyle \frac{\pi}{3\sqrt{3}}.
- \dfrac{\pi}{6}. Here 3 + 2x - x^2 = 4 - (x - 1)^2, and [1, 2] lies inside (-1, 3); \displaystyle \arcsin\frac{x - 1}{2} runs from 0 to \displaystyle \arcsin\frac{1}{2} = \frac{\pi}{6}.
- \dfrac{1}{2}\ln 2 + \dfrac{\pi}{8}. Split \displaystyle x + 1 = \frac{1}{2}(2x - 2) + 2; the denominator is (x - 1)^2 + 16, so an antiderivative is \displaystyle \frac{1}{2}\ln\left(x^2 - 2x + 17\right) \displaystyle + \frac{1}{2}\arctan\frac{x - 1}{4}. At 5 it is \displaystyle \frac{1}{2}\ln 32 + \frac{\pi}{8}, at 1 it is \displaystyle \frac{1}{2}\ln 16, and \displaystyle \frac{1}{2}\ln 32 - \frac{1}{2}\ln 16 = \frac{1}{2}\ln 2.
- (a) Not an arctangent form: x^2 + 6x + 8 = (x + 3)^2 - 1 = (x + 2)(x + 4) factors, so it needs partial fractions. (b) Not an arctangent form: x^2 + 6x + 9 = (x + 3)^2, and the power rule gives -\dfrac{1}{x + 3} + C on each side of -3. (c) Yes: (x + 3)^2 + 2 gives \displaystyle \dfrac{1}{\sqrt{2}}\arctan\dfrac{x + 3}{\sqrt{2}} + C.
- The denominator is (x + 2)^2 + 16, and the derivative of Arez’s function is \displaystyle \frac{1}{4}\cdot\frac{16}{16 + (x + 2)^2}, which is \dfrac{4}{x^2 + 4x + 20}, four times too large. He left out \displaystyle \frac{1}{k}. Correct: \dfrac{1}{4}\arctan\dfrac{x + 2}{4} + C.
- The derivative is \displaystyle \dfrac{1}{\sqrt{1 - \frac{(x - 1)^2}{9}}}\cdot\left(-\dfrac{1}{3}\right) = -\dfrac{1}{\sqrt{9 - (x - 1)^2}}, the negative of the integrand. In the derivation, k was moved inside the root as \displaystyle \sqrt{k^2}, which equals \lvert k \rvert; that equals k only for k > 0. With k = -3 the result is off by a sign.
- After completing the square the quadratic is (x - h)^2 + k^2 with k > 0, and a square is never negative, so the quadratic is at least k^2 > 0 for every x. A positive quantity is its own absolute value, so \ln\lvert Q \rvert = \ln Q. The same fact means the denominator is never zero, so the integrand and its antiderivative \displaystyle \frac{1}{k}\arctan\frac{x - h}{k} are defined and continuous on the whole line.
- \displaystyle \frac{1}{k}\arctan\frac{x - h}{k}\Big|_h^{h + k} \displaystyle = \frac{1}{k}\arctan 1 - \frac{1}{k}\arctan 0 \displaystyle = \frac{\pi}{4k}. The graph of \displaystyle \frac{1}{(x - h)^2 + k^2} is the graph of \displaystyle \frac{1}{x^2 + k^2} slid h units right, and the interval [h, h + k] slides with it from [0, k]. A slide does not change area, which is what Figure 1 shows for k = 1 and h = 2.