Ran Wei/ Calculus/Module 11
中文
Calculus · Part III · Integrals

Module 11Techniques of integration

Integrate products, powers of trigonometric functions, square roots of quadratics and rational functions, by parts, with identities, with trigonometric substitutions and with partial fractions. You will also learn to choose a method, to check a computer’s answer, to recognise integrands with no elementary antiderivative, and to bound the error of a numerical approximation when the integrand has the required derivatives.

⏱ 270 minYou need: Modules 1 to 10, especially the product and chain rules (Module 5), the derivatives of Modules 5 and 6, and antiderivatives and substitution (Module 10)

In this module you will

  • Integrate by parts, choosing uu and dv,dv\mathclose{\text{,}} repeatedly or in a table, in definite integrals and to derive reduction formulas
  • Integrate powers of sines, cosines, tangents and secants with identities and substitutions
  • Evaluate integrals containing a2−x2,\sqrt{a^2 - x^2}\mathclose{\text{,}} a2+x2\sqrt{a^2 + x^2} or x2−a2\sqrt{x^2 - a^2} by trigonometric substitution, and return to xx with a triangle
  • Integrate rational functions by long division and partial fractions
  • Choose a method, check a computer’s answer by differentiating it, and recognise integrands with no elementary antiderivative
  • Approximate integrals with the midpoint, trapezoidal and Simpson’s rules, and bound their errors
1

Integration by parts

Module 10 turned the chain rule round and got the substitution rule. This section turns the product rule round. Products are everywhere in integrals, xcos⁡x,x\cos x\mathclose{\text{,}} xe−x,xe^{-x}\mathclose{\text{,}} x2ln⁡x,x^2\ln x\mathclose{\text{,}} exsin⁡x,e^x\sin x\mathclose{\text{,}} and Module 10 warned that there is no product rule for antiderivatives: an antiderivative of xcos⁡xx\cos x is not 12x2sin⁡x\tfrac12x^2\sin x (Section 10.1).

Start from the product rule of Module 5, (fg)′=f′g+fg′.(fg)' = f'g + fg'\mathclose{\text{.}} Read backwards, it says that fgfg is an antiderivative of f′g+fg′.f'g + fg'\mathclose{\text{.}} So if you can integrate one of the two terms, you can integrate the other. Try it on xcos⁡x,x\cos x\mathclose{\text{,}} with f(x)=xf(x) = x and g(x)=sin⁡x,g(x) = \sin x\mathclose{\text{,}} so that fg′=xcos⁡xfg' = x\cos x is the integrand and f′g=sin⁡xf'g = \sin x is easy:

ddx(xsin⁡x)=sin⁡x+xcos⁡x.\frac{d}{dx}(x\sin x) = \sin x + x\cos x.

So xcos⁡x=(xsin⁡x)′−sin⁡x,x\cos x = (x\sin x)' - \sin x\mathclose{\text{,}} and an antiderivative of the right side is xsin⁡x−(−cos⁡x):x\sin x - (-\cos x)\mathclose{\text{:}}

∫xcos⁡x dx=xsin⁡x+cos⁡x+C.\int x\cos x\,dx = x\sin x + \cos x + C.

Check: ddx(xsin⁡x+cos⁡x)=sin⁡x+xcos⁡x−sin⁡x=xcos⁡x.\dfrac{d}{dx}(x\sin x + \cos x) = \sin x + x\cos x - \sin x = x\cos x\mathclose{\text{.}}

Theorem 11.1Integration by parts

Let ff and gg have continuous derivatives on an interval I.I\mathclose{\text{.}} Then, on I,I\mathclose{\text{,}}

∫f(x) g′(x) dx=f(x) g(x)−∫f′(x) g(x) dx.\begin{aligned} &\int f(x)\,g'(x)\,dx \\ &\quad= f(x)\,g(x) - \int f'(x)\,g(x)\,dx. \end{aligned}

That is: if GG is an antiderivative of f′gf'g on I,I\mathclose{\text{,}} then fg−Gfg - G is an antiderivative of fg′.fg'\mathclose{\text{.}}

Proof

The function f′gf'g is continuous on I,I\mathclose{\text{,}} so it has an antiderivative GG there, by Part 1 of the Fundamental Theorem (Section 10.4). By the product rule,

(fg−G)′=f′g+fg′−f′g=fg′(fg - G)' = f'g + fg' - f'g = fg'

on I.I\mathclose{\text{.}} So fg−Gfg - G is an antiderivative of fg′.fg'\mathclose{\text{.}}

∎

In Leibniz’s notation, put u=f(x)u = f(x) and v=g(x),v = g(x)\mathclose{\text{,}} so that du=f′(x) dxdu = f'(x)\,dx and dv=g′(x) dxdv = g'(x)\,dx are their differentials. The formula becomes

∫u dv=uv−∫v du,\int u\,dv = uv - \int v\,du,

read “the integral of u d v is u v minus the integral of v d u”. To use it, split the integrand into two factors: u,u\mathclose{\text{,}} which you will differentiate, and dv,dv\mathclose{\text{,}} which includes dxdx and which you must be able to integrate. The formula trades ∫u dv\int u\,dv for ∫v du,\int v\,du\mathclose{\text{,}} and it helps when the new integral is simpler than the old.

Example 11.1Three integrals by parts✓ Checked

Find (a) ∫xe−x dx,\displaystyle\int xe^{-x}\,dx\mathclose{\text{,}} (b) ∫ln⁡x dx,\displaystyle\int \ln x\,dx\mathclose{\text{,}} for x>0,x > 0\mathclose{\text{,}} and (c) ∫arctan⁡x dx.\displaystyle\int \arctan x\,dx\mathclose{\text{.}}

(a) Let u=xu = x and dv=e−x dx.dv = e^{-x}\,dx\mathclose{\text{.}} Then du=dxdu = dx and v=−e−x;v = -e^{-x}\mathclose{\text{;}} any antiderivative of e−xe^{-x} will do, so take the simplest. So

∫xe−x dx=x(−e−x)−∫(−e−x) dx=−xe−x+∫e−x dx=−xe−x−e−x+C.\begin{aligned} &\int xe^{-x}\,dx \\ &\quad= x\big(-e^{-x}\big) - \int \big(-e^{-x}\big)\,dx \\ &\quad= -xe^{-x} + \int e^{-x}\,dx \\ &\quad= -xe^{-x} - e^{-x} + C. \end{aligned}

Check: ddx(−xe−x−e−x)=−e−x+xe−x+e−x=xe−x.\dfrac{d}{dx}\big(-xe^{-x} - e^{-x}\big) = -e^{-x} + xe^{-x} + e^{-x} = xe^{-x}\mathclose{\text{.}}

(b) There seems to be only one factor, but ln⁡x dx\ln x\,dx is u dvu\,dv with u=ln⁡xu = \ln x and dv=dx.dv = dx\mathclose{\text{.}} Then du=dxxdu = \dfrac{dx}{x} and v=x:v = x\mathclose{\text{:}}

∫ln⁡x dx=xln⁡x−∫x⋅1x dx=xln⁡x−x+C.\begin{aligned} \int \ln x\,dx &= x\ln x - \int x\cdot\frac1x\,dx \\ &= x\ln x - x + C. \end{aligned}

(c) The same trick: u=arctan⁡xu = \arctan x and dv=dx,dv = dx\mathclose{\text{,}} so du=dx1+x2du = \dfrac{dx}{1 + x^2} and v=x.v = x\mathclose{\text{.}} Then

∫arctan⁡x dx=xarctan⁡x−∫x1+x2 dx=xarctan⁡x−12ln⁡(1+x2)+C,\begin{aligned} &\int \arctan x\,dx \\ &\quad= x\arctan x - \int \frac{x}{1 + x^2}\,dx \\ &\quad= x\arctan x - \tfrac12\ln\big(1 + x^2\big) + C, \end{aligned}

the last integral by the substitution w=1+x2,w = 1 + x^2\mathclose{\text{,}} dw=2x dxdw = 2x\,dx (Module 10), with no absolute value bars because 1+x2>0.1 + x^2 > 0\mathclose{\text{.}}

Choosing u and dv

The choice matters. In ∫xcos⁡x dx,\int x\cos x\,dx\mathclose{\text{,}} take the opposite roles, u=cos⁡xu = \cos x and dv=x dx.dv = x\,dx\mathclose{\text{.}} Then du=−sin⁡x dxdu = -\sin x\,dx and v=12x2,v = \tfrac12x^2\mathclose{\text{,}} and

∫xcos⁡x dx=12x2cos⁡x+12∫x2sin⁡x dx.\int x\cos x\,dx = \tfrac12x^2\cos x + \tfrac12\int x^2\sin x\,dx.

That is true, but the new integral is harder than the old one: the power of xx went up instead of down. Integration by parts pays off when differentiating uu makes it simpler, and integrating dvdv does not make it much worse.

Key idea

A rough guide to the choice of uu is the word LIATE. Take for uu the factor whose kind comes first in the list

  1. Logarithmic: ln⁡x\ln x
  2. Inverse trigonometric: arctan⁡x,\arctan x\mathclose{\text{,}} arcsin⁡x\arcsin x
  3. Algebraic: powers and polynomials, such as x,x\mathclose{\text{,}} x3,x^3\mathclose{\text{,}} x\sqrt x
  4. Trigonometric: sin⁡x,\sin x\mathclose{\text{,}} cos⁡x\cos x
  5. Exponential: ex,e^x\mathclose{\text{,}} e−2x,e^{-2x}\mathclose{\text{,}} 2x2^x

and let dvdv be the rest, with dx.dx\mathclose{\text{.}} The kinds early in the list get simpler when they are differentiated (ln⁡x\ln x becomes 1/x,1/x\mathclose{\text{,}} arctan⁡x\arctan x becomes 1/(1+x2),1/(1 + x^2)\mathclose{\text{,}} x3x^3 becomes 3x2);3x^2\mathclose{\text{);}} the kinds late in the list are easy to integrate and stay the same kind.

In ∫xe−x dx,\int xe^{-x}\,dx\mathclose{\text{,}} algebraic comes before exponential, so u=x;u = x\mathclose{\text{;}} in ∫ln⁡x dx\int \ln x\,dx and ∫arctan⁡x dx,\int \arctan x\,dx\mathclose{\text{,}} the logarithm and the inverse tangent come first, and dv=dx.dv = dx\mathclose{\text{.}} But LIATE is a rule of thumb, not a theorem, and the requirement that you can integrate dvdv comes first.

Example 11.2When the guide misleads✓ Checked

Find ∫x3ex2 dx.\displaystyle\int x^3e^{x^2}\,dx\mathclose{\text{.}}

LIATE suggests u=x3u = x^3 and dv=ex2 dx.dv = e^{x^2}\,dx\mathclose{\text{.}} But then vv would be an antiderivative of ex2,e^{x^2}\mathclose{\text{,}} and no formula built from the functions of Module 1’s catalogue is one (Section 11.6). Split the integrand differently. The factor ex2e^{x^2} can be integrated only together with a factor x,x\mathclose{\text{,}} by the substitution w=x2,w = x^2\mathclose{\text{,}} dw=2x dx:dw = 2x\,dx\mathclose{\text{:}} ∫xex2 dx=12ex2+C.\int xe^{x^2}\,dx = \tfrac12e^{x^2} + C\mathclose{\text{.}} So take

u=x2,dv=xex2 dx,du=2x dx,v=12ex2.\begin{aligned} u &= x^2, & dv &= xe^{x^2}\,dx, \\ du &= 2x\,dx, & v &= \tfrac12e^{x^2}. \end{aligned}

Then

∫x3ex2 dx=12x2ex2−∫12ex2⋅2x dx=12x2ex2−12ex2+C=12(x2−1)ex2+C,\begin{aligned} \int x^3e^{x^2}\,dx &= \tfrac12x^2e^{x^2} - \int \tfrac12e^{x^2}\cdot 2x\,dx \\ &= \tfrac12x^2e^{x^2} - \tfrac12e^{x^2} + C \\ &= \tfrac12\big(x^2 - 1\big)e^{x^2} + C, \end{aligned}

the middle integral by the same substitution. Check: ddx(12(x2−1)ex2)=xex2+12(x2−1)2xex2=x3ex2.\dfrac{d}{dx}\Big(\tfrac12\big(x^2 - 1\big)e^{x^2}\Big) = xe^{x^2} + \tfrac12\big(x^2 - 1\big)2xe^{x^2} = x^3e^{x^2}\mathclose{\text{.}}

Watch out

Three slips with parts. (1) The sign: ∫u dv\int u\,dv is uvuv minus ∫v du.\int v\,du\mathclose{\text{.}} (2) Integrating dvdv carelessly. In ∫xe3x dx,\int xe^{3x}\,dx\mathclose{\text{,}} with u=xu = x and dv=e3x dx,dv = e^{3x}\,dx\mathclose{\text{,}} vv is 13e3x,\tfrac13e^{3x}\mathclose{\text{,}} not e3x,e^{3x}\mathclose{\text{,}} and the answer is 13xe3x−19e3x+C;\tfrac13xe^{3x} - \tfrac19e^{3x} + C\mathclose{\text{;}} with v=e3xv = e^{3x} you would get xe3x−e3x,xe^{3x} - e^{3x}\mathclose{\text{,}} whose derivative is 3xe3x−2e3x.3xe^{3x} - 2e^{3x}\mathclose{\text{.}} (3) A choice that cannot work: a dvdv you cannot integrate, as in Example 11.2, or a uu that does not get simpler. Differentiate the answer to catch all three.

Repeated parts and the tabular method

Sometimes the new integral is simpler but still a product, and a second round of parts finishes the job.

Example 11.3Twice by parts✓ Checked

Find ∫x2sin⁡x dx.\displaystyle\int x^2\sin x\,dx\mathclose{\text{.}}

By LIATE, u=x2u = x^2 and dv=sin⁡x dx,dv = \sin x\,dx\mathclose{\text{,}} so du=2x dxdu = 2x\,dx and v=−cos⁡x:v = -\cos x\mathclose{\text{:}}

∫x2sin⁡x dx=−x2cos⁡x+∫2xcos⁡x dx.\begin{aligned} &\int x^2\sin x\,dx \\ &\quad= -x^2\cos x + \int 2x\cos x\,dx. \end{aligned}

The new integrand is again a product, with a lower power of x.x\mathclose{\text{.}} It is twice the integral found at the start of this section (by parts with u=xu = x and dv=cos⁡x dx),dv = \cos x\,dx\mathclose{\text{),}} that is, 2(xsin⁡x+cos⁡x)+C.2(x\sin x + \cos x) + C\mathclose{\text{.}} So

∫x2sin⁡x dx=−x2cos⁡x+2xsin⁡x+2cos⁡x+C.\begin{aligned} &\int x^2\sin x\,dx \\ &\quad= -x^2\cos x + 2x\sin x \\ &\qquad + 2\cos x + C. \end{aligned}

Each round lowers the power of xx by one, so xnx^n needs nn rounds.

When uu is a polynomial, the rounds follow a pattern that a table organises: the tabular method. Write uu and its successive derivatives in one column, down to 0, and the function in dvdv and its successive antiderivatives in the other. Multiply each entry of the left column by the entry one row lower in the right column, give the products the signs +,−,+,−,…+, -, +, -, \dots in turn, and add them up.

Example 11.4The tabular method✓ Checked

Find ∫x3e2x dx.\displaystyle\int x^3e^{2x}\,dx\mathclose{\text{.}}

Differentiate x3x^3 until it becomes 0, and integrate e2xe^{2x} as many times:

Sign Differentiate Integrate
++ x3x^3 e2xe^{2x}
−- 3x23x^2 12e2x\tfrac12e^{2x}
++ 6x6x 14e2x\tfrac14e^{2x}
−- 66 18e2x\tfrac18e^{2x}
00 116e2x\tfrac1{16}e^{2x}

Multiplying along the diagonals, with the signs of the first column,

∫x3e2x dx=12x3e2x−34x2e2x+34xe2x−38e2x+C=18e2x(4x3−6x2+6x−3)+C.\begin{aligned} &\int x^3e^{2x}\,dx \\ &\quad= \tfrac12x^3e^{2x} - \tfrac34x^2e^{2x} \\ &\qquad + \tfrac34xe^{2x} - \tfrac38e^{2x} + C \\ &\quad= \tfrac18e^{2x}\big(4x^3 - 6x^2 + 6x - 3\big) + C. \end{aligned}

Each diagonal is one round of parts. The first round gives x3⋅12e2x−∫3x2⋅12e2x dx:x^3\cdot\tfrac12e^{2x} - \int 3x^2\cdot\tfrac12e^{2x}\,dx\mathclose{\text{:}} the first product, minus the integral of the next row’s two entries. That integral is treated the same way, with every sign reversed, and so on. The process stops when the left column reaches 0, because then the leftover integral is 0.

Definite integrals by parts

For a definite integral, evaluate uvuv between the limits.

Theorem 11.2Integration by parts in definite integrals

If ff and gg have continuous derivatives on [a,b],[a, b]\mathclose{\text{,}} then

∫abf(x) g′(x) dx=[f(x) g(x)]ab−∫abf′(x) g(x) dx.\begin{aligned} &\int_a^b f(x)\,g'(x)\,dx \\ &\quad= \big[f(x)\,g(x)\big]_a^b - \int_a^b f'(x)\,g(x)\,dx. \end{aligned}
Proof

The functions fg′fg' and f′gf'g are continuous on [a,b],[a, b]\mathclose{\text{,}} so both integrals exist. Let GG be an antiderivative of f′gf'g on [a,b].[a, b]\mathclose{\text{.}} By Theorem 11.1, fg−Gfg - G is an antiderivative of fg′,fg'\mathclose{\text{,}} so by Part 2 of the Fundamental Theorem (Section 10.5) the left side is [fg−G]ab=[fg]ab−[G]ab,\big[fg - G\big]_a^b = \big[fg\big]_a^b - \big[G\big]_a^b\mathclose{\text{,}} and [G]ab=∫abf′g dx,\big[G\big]_a^b = \int_a^b f'g\,dx\mathclose{\text{,}} by Part 2 again.

∎

When u=f(x)u = f(x) and v=g(x)v = g(x) are never negative and both increase with x,x\mathclose{\text{,}} the theorem has a picture (Figure 11.1). As xx runs from aa to b,b\mathclose{\text{,}} the point (u,v)(u, v) traces a curve from (u1,v1)(u_1, v_1) to (u2,v2),(u_2, v_2)\mathclose{\text{,}} where u1=f(a),u_1 = f(a)\mathclose{\text{,}} v1=g(a),v_1 = g(a)\mathclose{\text{,}} u2=f(b)u_2 = f(b) and v2=g(b).v_2 = g(b)\mathclose{\text{.}} The integral ∫v du=∫abg(x)f′(x) dx\int v\,du = \int_a^b g(x)f'(x)\,dx is the area between this curve and the uu-axis, and ∫u dv=∫abf(x)g′(x) dx\int u\,dv = \int_a^b f(x)g'(x)\,dx is the area between the curve and the vv-axis. Together the two regions fill the rectangle u2v2u_2v_2 except for the rectangle u1v1:u_1v_1\mathclose{\text{:}}

∫u dv+∫v du=u2v2−u1v1=[uv]ab,\int u\,dv + \int v\,du = u_2v_2 - u_1v_1 = \big[uv\big]_a^b,

which is Theorem 11.2.

Integration by parts as areas. Left: the curve traced by (u, v) from (u1, v1) to (u2, v2). The blue region, between the curve and the u-axis, has area int v,du; the orange region, between the curve and the v-axis, has area int u,dv. Together they make the large rectangle u2v2 minus the small rectangle u1v1. Right: the case u = x, v = ln x for 1 le x le e (Example 11.5(a)). The blue area int1^e ln x,dx and the orange area int0^1 e^v,dv = e - 1 add up to the rectangle e times 1, so the blue area is 1.
Figure 11.1

Integration by parts as areas. Left: the curve traced by (u,v)(u, v) from (u1,v1)(u_1, v_1) to (u2,v2).(u_2, v_2)\mathclose{\text{.}} The blue region, between the curve and the uu-axis, has area ∫v du;\int v\,du\mathclose{\text{;}} the orange region, between the curve and the vv-axis, has area ∫u dv.\int u\,dv\mathclose{\text{.}} Together they make the large rectangle u2v2u_2v_2 minus the small rectangle u1v1.u_1v_1\mathclose{\text{.}} Right: the case u=x,u = x\mathclose{\text{,}} v=ln⁡xv = \ln x for 1≤x≤e1 \le x \le e (Example 11.5(a)). The blue area ∫1eln⁡x dx\int_1^e \ln x\,dx and the orange area ∫01ev dv=e−1\int_0^1 e^v\,dv = e - 1 add up to the rectangle e×1,e \times 1\mathclose{\text{,}} so the blue area is 1.

Example 11.5Definite integrals by parts✓ Checked

Evaluate (a) ∫1eln⁡x dx\displaystyle\int_1^e \ln x\,dx and (b) ∫0πxsin⁡x dx.\displaystyle\int_0^\pi x\sin x\,dx\mathclose{\text{.}}

(a) With u=ln⁡xu = \ln x and dv=dx,dv = dx\mathclose{\text{,}} as in Example 11.1(b),

∫1eln⁡x dx=[xln⁡x]1e−∫1ex⋅1x dx=(eln⁡e−1⋅ln⁡1)−(e−1)=e−(e−1)=1.\begin{aligned} &\int_1^e \ln x\,dx \\ &\quad= \big[x\ln x\big]_1^e - \int_1^e x\cdot\frac1x\,dx \\ &\quad= (e\ln e - 1\cdot\ln 1) - (e - 1) \\ &\quad= e - (e - 1) = 1. \end{aligned}

Figure 11.1 (right) shows this area as the rectangle of area ee minus the region of area e−1e - 1 to the left of the curve.

(b) With u=xu = x and dv=sin⁡x dx,dv = \sin x\,dx\mathclose{\text{,}} so du=dxdu = dx and v=−cos⁡x,v = -\cos x\mathclose{\text{,}}

∫0πxsin⁡x dx=[−xcos⁡x]0π+∫0πcos⁡x dx=(−πcos⁡π+0)+[sin⁡x]0π=π+0=π.\begin{aligned} &\int_0^\pi x\sin x\,dx \\ &\quad= \big[-x\cos x\big]_0^\pi + \int_0^\pi \cos x\,dx \\ &\quad= (-\pi\cos\pi + 0) + \big[\sin x\big]_0^\pi \\ &\quad= \pi + 0 = \pi. \end{aligned}

When the integral comes back

In some integrals neither factor gets simpler when differentiated. Then two rounds of parts may bring back the integral you started with, and you can solve for it.

Example 11.6An integral that comes back✓ Checked

Find ∫exsin⁡x dx.\displaystyle\int e^x\sin x\,dx\mathclose{\text{.}}

Call the integral I.I\mathclose{\text{.}} Take u=sin⁡xu = \sin x and dv=ex dx,dv = e^x\,dx\mathclose{\text{,}} so du=cos⁡x dxdu = \cos x\,dx and v=ex:v = e^x\mathclose{\text{:}}

I=exsin⁡x−∫excos⁡x dx.I = e^x\sin x - \int e^x\cos x\,dx.

The new integral is of the same kind. Integrate by parts again, with the factors in the same roles, u=cos⁡xu = \cos x and dv=ex dx,dv = e^x\,dx\mathclose{\text{,}} so du=−sin⁡x dx:du = -\sin x\,dx\mathclose{\text{:}}

∫excos⁡x dx=excos⁡x+∫exsin⁡x dx=excos⁡x+I.\begin{aligned} &\int e^x\cos x\,dx \\ &\quad= e^x\cos x + \int e^x\sin x\,dx \\ &\quad= e^x\cos x + I. \end{aligned}

Put this into the first equation:

I=exsin⁡x−excos⁡x−I.I = e^x\sin x - e^x\cos x - I.

The unknown integral appears on both sides, so solve for it as in an equation: 2I=ex(sin⁡x−cos⁡x),2I = e^x(\sin x - \cos x)\mathclose{\text{,}} and

∫exsin⁡x dx=12ex(sin⁡x−cos⁡x)+C.\int e^x\sin x\,dx = \tfrac12e^x(\sin x - \cos x) + C.

Each indefinite integral stands for a family of functions that differ by constants, so these equations hold up to constants; the + C+\,C at the end collects them. Check: ddx(12ex(sin⁡x−cos⁡x))=12ex(sin⁡x−cos⁡x)+12ex(cos⁡x+sin⁡x)=exsin⁡x.\dfrac{d}{dx}\Big(\tfrac12e^x(\sin x - \cos x)\Big) = \tfrac12e^x(\sin x - \cos x) + \tfrac12e^x(\cos x + \sin x) = e^x\sin x\mathclose{\text{.}}

Watch out

In the second round, keep the roles of the first. With u=exu = e^x and dv=cos⁡x dxdv = \cos x\,dx instead, the second round undoes the first: ∫excos⁡x dx=exsin⁡x−I,\int e^x\cos x\,dx = e^x\sin x - I\mathclose{\text{,}} and the first equation becomes I=exsin⁡x−exsin⁡x+I,I = e^x\sin x - e^x\sin x + I\mathclose{\text{,}} that is, I=I.I = I\mathclose{\text{.}} True, but no help.

Reduction formulas

Some integrals depend on a whole number n,n\mathclose{\text{,}} such as ∫sin⁡nx dx\int \sin^n x\,dx or ∫xnex dx.\int x^ne^x\,dx\mathclose{\text{.}} Integration by parts can lower n.n\mathclose{\text{.}} A reduction formula expresses such an integral in terms of the same integral with a smaller n;n\mathclose{\text{;}} applied again and again, it brings nn down to 0 or 1.

Theorem 11.3A reduction formula for powers of sine

For every whole number n≥2,n \ge 2\mathclose{\text{,}}

∫sin⁡nx dx=−sin⁡n−1xcos⁡xn+n−1n∫sin⁡n−2x dx.\begin{aligned} \int \sin^n x\,dx &= -\frac{\sin^{n-1}x\cos x}{n} \\ &\quad + \frac{n - 1}{n}\int \sin^{n-2}x\,dx. \end{aligned}
Proof

Write sin⁡nx=sin⁡n−1x⋅sin⁡x\sin^n x = \sin^{n-1}x\cdot\sin x and integrate by parts with u=sin⁡n−1xu = \sin^{n-1}x and dv=sin⁡x dx.dv = \sin x\,dx\mathclose{\text{.}} By the chain rule du=(n−1)sin⁡n−2xcos⁡x dx,du = (n - 1)\sin^{n-2}x\cos x\,dx\mathclose{\text{,}} and v=−cos⁡x:v = -\cos x\mathclose{\text{:}}

∫sin⁡nx dx=−sin⁡n−1xcos⁡x+(n−1)∫sin⁡n−2xcos⁡2x dx.\begin{aligned} &\int \sin^n x\,dx \\ &\quad= -\sin^{n-1}x\cos x \\ &\qquad + (n - 1)\int \sin^{n-2}x\cos^2 x\,dx. \end{aligned}

Replace cos⁡2x\cos^2 x by 1−sin⁡2x1 - \sin^2 x and split the integral:

∫sin⁡nx dx=−sin⁡n−1xcos⁡x+(n−1)∫sin⁡n−2x dx−(n−1)∫sin⁡nx dx.\begin{aligned} &\int \sin^n x\,dx \\ &\quad= -\sin^{n-1}x\cos x \\ &\qquad + (n - 1)\int \sin^{n-2}x\,dx \\ &\qquad - (n - 1)\int \sin^n x\,dx. \end{aligned}

The integral of sin⁡nx\sin^n x has come back, as in Example 11.6. Add (n−1)∫sin⁡nx dx(n - 1)\int \sin^n x\,dx to both sides and divide by n.n\mathclose{\text{.}}

∎
Example 11.7Powers of sine✓ Checked

Find (a) ∫sin⁡2x dx,\displaystyle\int \sin^2 x\,dx\mathclose{\text{,}} (b) ∫sin⁡4x dx\displaystyle\int \sin^4 x\,dx and (c) ∫0π/2sin⁡4x dx.\displaystyle\int_0^{\pi/2} \sin^4 x\,dx\mathclose{\text{.}}

(a) With n=2,n = 2\mathclose{\text{,}} and sin⁡0x=1,\sin^0 x = 1\mathclose{\text{,}}

∫sin⁡2x dx=−12sin⁡xcos⁡x+12x+C.\int \sin^2 x\,dx = -\tfrac12\sin x\cos x + \tfrac12x + C.

(b) With n=4,n = 4\mathclose{\text{,}} and then (a),

∫sin⁡4x dx=−14sin⁡3xcos⁡x+34∫sin⁡2x dx=−14sin⁡3xcos⁡x−38sin⁡xcos⁡x+38x+C.\begin{aligned} &\int \sin^4 x\,dx \\ &\quad= -\tfrac14\sin^3 x\cos x + \tfrac34\int \sin^2 x\,dx \\ &\quad= -\tfrac14\sin^3 x\cos x - \tfrac38\sin x\cos x \\ &\qquad + \tfrac38x + C. \end{aligned}

(c) In a definite integral, the reduction formula holds with its first term evaluated between the limits (use Theorem 11.2 in the proof). On [0,π/2][0, \pi/2] that term vanishes at both ends, since sin⁡0=0,\sin 0 = 0\mathclose{\text{,}} cos⁡π2=0\cos\tfrac{\pi}{2} = 0 and the power n−1n - 1 is at least 1. So, applying the formula twice,

∫0π/2sin⁡4x dx=34∫0π/2sin⁡2x dx=34⋅12∫0π/21 dx=34⋅12⋅π2=3π16≈0.5890.\begin{aligned} \int_0^{\pi/2} \sin^4 x\,dx &= \frac34\int_0^{\pi/2} \sin^2 x\,dx \\ &= \frac34\cdot\frac12\int_0^{\pi/2} 1\,dx \\ &= \frac34\cdot\frac12\cdot\frac{\pi}{2} \\ &= \frac{3\pi}{16} \approx 0.5890. \end{aligned}

The second line says that ∫0π/2sin⁡2x dx=12⋅π2=π4,\int_0^{\pi/2} \sin^2 x\,dx = \tfrac12\cdot\tfrac{\pi}{2} = \tfrac{\pi}{4}\mathclose{\text{,}} as Exercise 10.12 found by symmetry.

2

Trigonometric integrals

Example 11.7 integrated powers of the sine with a reduction formula. Most products of powers of sines and cosines give way faster, to an identity and a substitution. Three identities do the work. The first is the Pythagorean identity sin⁡2x+cos⁡2x=1\sin^2 x + \cos^2 x = 1 of Module 1; dividing it by cos⁡2x\cos^2 x gives the second, tan⁡2x+1=sec⁡2x.\tan^2 x + 1 = \sec^2 x\mathclose{\text{.}} The third comes from the addition formula cos⁡(x+y)=cos⁡xcos⁡y−sin⁡xsin⁡y\cos(x + y) = \cos x\cos y - \sin x\sin y of Module 1, with y=x:y = x\mathclose{\text{:}}

cos⁡2x=cos⁡2x−sin⁡2x.\cos 2x = \cos^2 x - \sin^2 x.

Replacing cos⁡2x\cos^2 x by 1−sin⁡2x,1 - \sin^2 x\mathclose{\text{,}} or sin⁡2x\sin^2 x by 1−cos⁡2x,1 - \cos^2 x\mathclose{\text{,}} and solving gives the half-angle identities

sin⁡2x=1−cos⁡2x2,cos⁡2x=1+cos⁡2x2.\begin{aligned} \sin^2 x &= \frac{1 - \cos 2x}{2}, \\ \cos^2 x &= \frac{1 + \cos 2x}{2}. \end{aligned}

They trade a square for a cosine of twice the angle, which is easy to integrate. In the same way the addition formula for the sine gives sin⁡2x=2sin⁡xcos⁡x.\sin 2x = 2\sin x\cos x\mathclose{\text{.}}

Powers of sine and cosine

Key idea

To integrate sin⁡mxcos⁡nx,\sin^m x\cos^n x\mathclose{\text{,}} where mm and nn are whole numbers:

  • If the power nn of the cosine is odd, save one factor cos⁡x,\cos x\mathclose{\text{,}} write the remaining even power of the cosine in terms of the sine with cos⁡2x=1−sin⁡2x,\cos^2 x = 1 - \sin^2 x\mathclose{\text{,}} and substitute u=sin⁡x,u = \sin x\mathclose{\text{,}} du=cos⁡x dx.du = \cos x\,dx\mathclose{\text{.}}
  • If the power mm of the sine is odd, save one factor sin⁡x,\sin x\mathclose{\text{,}} use sin⁡2x=1−cos⁡2x,\sin^2 x = 1 - \cos^2 x\mathclose{\text{,}} and substitute u=cos⁡x,u = \cos x\mathclose{\text{,}} du=−sin⁡x dx.du = -\sin x\,dx\mathclose{\text{.}}
  • If both powers are even, use the half-angle identities, again and again if needed, or the reduction formula of Theorem 11.3.
Example 11.8Odd powers✓ Checked

Find (a) ∫sin⁡3x dx\displaystyle\int \sin^3 x\,dx and (b) ∫sin⁡2xcos⁡3x dx.\displaystyle\int \sin^2 x\cos^3 x\,dx\mathclose{\text{.}}

(a) The power of the sine is odd. Save one sin⁡x:\sin x\mathclose{\text{:}} sin⁡3x=sin⁡2x⋅sin⁡x=(1−cos⁡2x)sin⁡x.\sin^3 x = \sin^2 x\cdot\sin x = \big(1 - \cos^2 x\big)\sin x\mathclose{\text{.}} With u=cos⁡xu = \cos x and du=−sin⁡x dx,du = -\sin x\,dx\mathclose{\text{,}}

∫sin⁡3x dx=−∫(1−u2) du=−u+u33+C=−cos⁡x+13cos⁡3x+C.\begin{aligned} \int \sin^3 x\,dx &= -\int \big(1 - u^2\big)\,du \\ &= -u + \frac{u^3}{3} + C \\ &= -\cos x + \tfrac13\cos^3 x + C. \end{aligned}

(b) The power of the cosine is odd. Save one cos⁡x:\cos x\mathclose{\text{:}} sin⁡2xcos⁡3x=sin⁡2x(1−sin⁡2x)cos⁡x.\sin^2 x\cos^3 x = \sin^2 x\big(1 - \sin^2 x\big)\cos x\mathclose{\text{.}} With u=sin⁡xu = \sin x and du=cos⁡x dx,du = \cos x\,dx\mathclose{\text{,}}

∫sin⁡2xcos⁡3x dx=∫(u2−u4) du=13sin⁡3x−15sin⁡5x+C.\begin{aligned} &\int \sin^2 x\cos^3 x\,dx \\ &\quad= \int \big(u^2 - u^4\big)\,du \\ &\quad= \tfrac13\sin^3 x - \tfrac15\sin^5 x + C. \end{aligned}
Example 11.9Even powers✓ Checked

Find (a) ∫cos⁡2x dx\displaystyle\int \cos^2 x\,dx and (b) ∫0πsin⁡4x dx.\displaystyle\int_0^\pi \sin^4 x\,dx\mathclose{\text{.}}

(a) By the half-angle identity, and with ∫cos⁡2x dx=12sin⁡2x+C\int \cos 2x\,dx = \tfrac12\sin 2x + C from Module 10’s table,

∫cos⁡2x dx=12∫(1+cos⁡2x) dx=x2+sin⁡2x4+C.\begin{aligned} \int \cos^2 x\,dx &= \frac12\int (1 + \cos 2x)\,dx \\ &= \frac{x}{2} + \frac{\sin 2x}{4} + C. \end{aligned}

(b) Square the half-angle identity for sin⁡2x,\sin^2 x\mathclose{\text{,}} then use the one for cos⁡2\cos^2 again, with 2x2x in place of x:x\mathclose{\text{:}}

sin⁡4x=(1−cos⁡2x2)2=14(1−2cos⁡2x+cos⁡22x)=14(1−2cos⁡2x+1+cos⁡4x2)=38−12cos⁡2x+18cos⁡4x.\begin{aligned} \sin^4 x &= \Big(\frac{1 - \cos 2x}{2}\Big)^2 \\ &= \frac14\big(1 - 2\cos 2x + \cos^2 2x\big) \\ &= \frac14\Big(1 - 2\cos 2x + \frac{1 + \cos 4x}{2}\Big) \\ &= \frac38 - \frac12\cos 2x + \frac18\cos 4x. \end{aligned}

So

∫0πsin⁡4x dx=[3x8−sin⁡2x4+sin⁡4x32]0π=3π8≈1.178,\begin{aligned} &\int_0^\pi \sin^4 x\,dx \\ &\quad= \Big[\frac{3x}{8} - \frac{\sin 2x}{4} + \frac{\sin 4x}{32}\Big]_0^\pi \\ &\quad= \frac{3\pi}{8} \approx 1.178, \end{aligned}

since all the sines vanish at 0 and at π.\pi\mathclose{\text{.}} This is twice the value 3π16\tfrac{3\pi}{16} found on [0,π/2][0, \pi/2] in Example 11.7, as it should be: the graph of sin⁡4x\sin^4 x is symmetric about x=π/2,x = \pi/2\mathclose{\text{,}} because sin⁡(π−x)=sin⁡x.\sin(\pi - x) = \sin x\mathclose{\text{.}}

Watch out

Three slips. (1) sin⁡2x\sin^2 x is (sin⁡x)2,(\sin x)^2\mathclose{\text{,}} not sin⁡(x2).\sin(x^2)\mathclose{\text{.}} (2) The power rule does not apply to sin⁡2x\sin^2 x as if sin⁡x\sin x were x:x\mathclose{\text{:}} ∫sin⁡2x dx\int \sin^2 x\,dx is not 13sin⁡3x+C,\tfrac13\sin^3 x + C\mathclose{\text{,}} whose derivative is sin⁡2xcos⁡x\sin^2 x\cos x by the chain rule. (3) ∫cos⁡2x dx=12sin⁡2x+C,\int \cos 2x\,dx = \tfrac12\sin 2x + C\mathclose{\text{,}} not sin⁡2x+C;\sin 2x + C\mathclose{\text{;}} and cos⁡2x\cos 2x is not 2cos⁡x.2\cos x\mathclose{\text{.}}

Powers of tangent and secant

For tangents and secants the derivatives (tan⁡x)′=sec⁡2x(\tan x)' = \sec^2 x and (sec⁡x)′=sec⁡xtan⁡x(\sec x)' = \sec x\tan x of Module 5 play the parts of cos⁡x\cos x and sin⁡x,\sin x\mathclose{\text{,}} and sec⁡2x=1+tan⁡2x\sec^2 x = 1 + \tan^2 x plays the part of the Pythagorean identity.

Key idea

To integrate tan⁡mxsec⁡nx,\tan^m x\sec^n x\mathclose{\text{,}} where mm and nn are whole numbers:

  • If the power nn of the secant is even and at least 2, save sec⁡2x,\sec^2 x\mathclose{\text{,}} write the other secants in terms of the tangent with sec⁡2x=1+tan⁡2x,\sec^2 x = 1 + \tan^2 x\mathclose{\text{,}} and substitute u=tan⁡x,u = \tan x\mathclose{\text{,}} du=sec⁡2x dx.du = \sec^2 x\,dx\mathclose{\text{.}}
  • If the power mm of the tangent is odd and n≥1,n \ge 1\mathclose{\text{,}} save sec⁡xtan⁡x,\sec x\tan x\mathclose{\text{,}} write the other tangents in terms of the secant with tan⁡2x=sec⁡2x−1,\tan^2 x = \sec^2 x - 1\mathclose{\text{,}} and substitute u=sec⁡x,u = \sec x\mathclose{\text{,}} du=sec⁡xtan⁡x dx.du = \sec x\tan x\,dx\mathclose{\text{.}}
  • Otherwise use identities, the integrals of tan⁡x\tan x (Example 10.11) and sec⁡x\sec x (Theorem 11.4), or parts (Example 11.11).
Example 11.10Tangents and secants✓ Checked

Find (a) ∫tan⁡2xsec⁡4x dx,\displaystyle\int \tan^2 x\sec^4 x\,dx\mathclose{\text{,}} (b) ∫tan⁡3xsec⁡x dx\displaystyle\int \tan^3 x\sec x\,dx and (c) ∫tan⁡2x dx,\displaystyle\int \tan^2 x\,dx\mathclose{\text{,}} on an interval where cos⁡x≠0.\cos x \ne 0\mathclose{\text{.}}

(a) The power of the secant is even: tan⁡2xsec⁡4x=tan⁡2x(1+tan⁡2x)sec⁡2x.\tan^2 x\sec^4 x = \tan^2 x\big(1 + \tan^2 x\big)\sec^2 x\mathclose{\text{.}} With u=tan⁡x,u = \tan x\mathclose{\text{,}}

∫(u2+u4) du=13tan⁡3x+15tan⁡5x+C.\begin{aligned} &\int \big(u^2 + u^4\big)\,du \\ &\quad= \tfrac13\tan^3 x + \tfrac15\tan^5 x + C. \end{aligned}

(b) The power of the tangent is odd: tan⁡3xsec⁡x=(sec⁡2x−1)sec⁡xtan⁡x.\tan^3 x\sec x = \big(\sec^2 x - 1\big)\sec x\tan x\mathclose{\text{.}} With u=sec⁡x,u = \sec x\mathclose{\text{,}}

∫(u2−1) du=13sec⁡3x−sec⁡x+C.\int \big(u^2 - 1\big)\,du = \tfrac13\sec^3 x - \sec x + C.

(c) There is no secant, but the identity still helps:

∫tan⁡2x dx=∫(sec⁡2x−1) dx=tan⁡x−x+C.\begin{aligned} \int \tan^2 x\,dx &= \int \big(\sec^2 x - 1\big)\,dx \\ &= \tan x - x + C. \end{aligned}

The integral of sec⁡x\sec x itself needs a trick.

Theorem 11.4The integral of the secant

On every interval on which cos⁡x≠0,\cos x \ne 0\mathclose{\text{,}}

∫sec⁡x dx=ln⁡∣sec⁡x+tan⁡x∣+C.\int \sec x\,dx = \ln\abs{\sec x + \tan x} + C.
Proof

Where cos⁡x≠0,\cos x \ne 0\mathclose{\text{,}} sec⁡x+tan⁡x=1+sin⁡xcos⁡x\sec x + \tan x = \dfrac{1 + \sin x}{\cos x} is never 0: 1+sin⁡x=01 + \sin x = 0 would mean sin⁡x=−1,\sin x = -1\mathclose{\text{,}} and then cos⁡x=0.\cos x = 0\mathclose{\text{.}} So ln⁡∣sec⁡x+tan⁡x∣\ln\abs{\sec x + \tan x} is differentiable there, and by the chain rule, with ddxln⁡∣w∣=w′w\dfrac{d}{dx}\ln\abs{w} = \dfrac{w'}{w} (Module 6),

ddxln⁡∣sec⁡x+tan⁡x∣=sec⁡xtan⁡x+sec⁡2xsec⁡x+tan⁡x=sec⁡x(tan⁡x+sec⁡x)sec⁡x+tan⁡x=sec⁡x.\begin{aligned} &\frac{d}{dx}\ln\abs{\sec x + \tan x} \\ &\quad= \frac{\sec x\tan x + \sec^2 x}{\sec x + \tan x} \\ &\quad= \frac{\sec x(\tan x + \sec x)}{\sec x + \tan x} = \sec x. \end{aligned}
∎

The proof checks the formula; it does not show how anyone could find it. Here is one way, with a trick: multiply the integrand by 1, in the form sec⁡x+tan⁡xsec⁡x+tan⁡x.\dfrac{\sec x + \tan x}{\sec x + \tan x}\mathclose{\text{.}} Then

∫sec⁡x dx=∫sec⁡2x+sec⁡xtan⁡xsec⁡x+tan⁡x dx,\int \sec x\,dx = \int \frac{\sec^2 x + \sec x\tan x}{\sec x + \tan x}\,dx,

and the numerator is the derivative of the denominator, so the substitution w=sec⁡x+tan⁡xw = \sec x + \tan x gives ∫dww=ln⁡∣w∣+C.\int \dfrac{dw}{w} = \ln\abs{w} + C\mathclose{\text{.}} Tricks like this one come from experience, which is one reason to check every antiderivative by differentiating it. The same trick with csc⁡x−cot⁡x,\csc x - \cot x\mathclose{\text{,}} whose derivative is csc⁡2x−csc⁡xcot⁡x,\csc^2 x - \csc x\cot x\mathclose{\text{,}} gives ∫csc⁡x dx=ln⁡∣csc⁡x−cot⁡x∣+C\int \csc x\,dx = \ln\abs{\csc x - \cot x} + C on every interval on which sin⁡x≠0.\sin x \ne 0\mathclose{\text{.}}

Example 11.11The secant cubed✓ Checked

Find ∫sec⁡3x dx\displaystyle\int \sec^3 x\,dx on an interval where cos⁡x≠0.\cos x \ne 0\mathclose{\text{.}}

The power of the secant is odd and there is no tangent, so neither substitution applies. Integrate by parts with u=sec⁡xu = \sec x and dv=sec⁡2x dx,dv = \sec^2 x\,dx\mathclose{\text{,}} so du=sec⁡xtan⁡x dxdu = \sec x\tan x\,dx and v=tan⁡x:v = \tan x\mathclose{\text{:}}

∫sec⁡3x dx=sec⁡xtan⁡x−∫sec⁡xtan⁡2x dx=sec⁡xtan⁡x−∫sec⁡x(sec⁡2x−1) dx=sec⁡xtan⁡x−∫sec⁡3x dx+∫sec⁡x dx.\begin{aligned} &\int \sec^3 x\,dx \\ &\quad= \sec x\tan x - \int \sec x\tan^2 x\,dx \\ &\quad= \sec x\tan x \\ &\qquad - \int \sec x\big(\sec^2 x - 1\big)\,dx \\ &\quad= \sec x\tan x - \int \sec^3 x\,dx \\ &\qquad + \int \sec x\,dx. \end{aligned}

The integral has come back, as in Example 11.6. Solve for it, and use Theorem 11.4:

∫sec⁡3x dx=12sec⁡xtan⁡x+12ln⁡∣sec⁡x+tan⁡x∣+C.\begin{aligned} &\int \sec^3 x\,dx \\ &\quad= \tfrac12\sec x\tan x \\ &\qquad + \tfrac12\ln\abs{\sec x + \tan x} + C. \end{aligned}
3

Trigonometric substitution

The area of a disc of radius rr is πr2,\pi r^2\mathclose{\text{,}} and Module 9 used that formula to evaluate integrals such as ∫039−x2 dx\int_0^3 \sqrt{9 - x^2}\,dx (Exercise 9.4). Now integration can find such areas itself. The upper half of the circle x2+y2=r2x^2 + y^2 = r^2 is the graph of y=r2−x2,y = \sqrt{r^2 - x^2}\mathclose{\text{,}} but no substitution u=g(x)u = g(x) of Module 10 helps with this integrand: there is no factor g′(x)g'(x) to go with dx.dx\mathclose{\text{.}} Instead, go the other way, and replace xx by a function of a new variable. Since 1−sin⁡2θ=cos⁡2θ,1 - \sin^2\theta = \cos^2\theta\mathclose{\text{,}} the substitution x=rsin⁡θx = r\sin\theta turns r2−x2\sqrt{r^2 - x^2} into r2cos⁡2θ,\sqrt{r^2\cos^2\theta}\mathclose{\text{,}} a square root that goes away.

The substitution rule of Module 10 justifies this, read from right to left.

Theorem 11.5Substitution in reverse

Let gg have a continuous derivative on an interval J.J\mathclose{\text{.}}

  • (a) If ff is continuous on an interval that contains every value of gg on J,J\mathclose{\text{,}} then for all α\alpha and β\beta in JJ
    ∫g(α)g(β)f(x) dx=∫αβf(g(θ)) g′(θ) dθ.\begin{aligned} &\int_{g(\alpha)}^{g(\beta)} f(x)\,dx \\ &\quad= \int_\alpha^\beta f\big(g(\theta)\big)\,g'(\theta)\,d\theta. \end{aligned}
  • (b) Suppose that JJ is open, that gg is one-to-one on J,J\mathclose{\text{,}} that ff is continuous on the interval II of the values of gg on J,J\mathclose{\text{,}} and that GG is an antiderivative of f(g(θ)) g′(θ)f\big(g(\theta)\big)\,g'(\theta) on J.J\mathclose{\text{.}} Then G(g−1(x))G\big(g^{-1}(x)\big) is an antiderivative of ff on I.I\mathclose{\text{.}}
Proof

(a) is the substitution rule for definite integrals (Theorem 10.7), with x=g(θ),x = g(\theta)\mathclose{\text{,}} read from right to left. For (b): II is an open interval, because gg is continuous and one-to-one on the open interval J.J\mathclose{\text{.}} By Part 1 of the Fundamental Theorem, ff has an antiderivative FF on I,I\mathclose{\text{,}} and by the substitution rule (Theorem 10.6), F(g(θ))F\big(g(\theta)\big) is an antiderivative of f(g(θ)) g′(θ)f\big(g(\theta)\big)\,g'(\theta) on J.J\mathclose{\text{.}} So G(θ)=F(g(θ))+C0G(\theta) = F\big(g(\theta)\big) + C_0 for a constant C0C_0 (Theorem 10.1). For xx in I,I\mathclose{\text{,}} put θ=g−1(x):\theta = g^{-1}(x)\mathclose{\text{:}} then G(g−1(x))=F(x)+C0,G\big(g^{-1}(x)\big) = F(x) + C_0\mathclose{\text{,}} which is an antiderivative of f.f\mathclose{\text{.}}

∎

Three substitutions cover the three square roots of the form ±x2±a2\sqrt{\pm x^2 \pm a^2} that can be real. In each row a>0:a > 0\mathclose{\text{:}}

Integrand contains Substitute Identity used
a2−x2\sqrt{a^2 - x^2} x=asin⁡θ,x = a\sin\theta\mathclose{\text{,}} −π2≤θ≤π2-\tfrac{\pi}{2} \le \theta \le \tfrac{\pi}{2} 1−sin⁡2θ=cos⁡2θ1 - \sin^2\theta = \cos^2\theta
a2+x2\sqrt{a^2 + x^2} x=atan⁡θ,x = a\tan\theta\mathclose{\text{,}} −π2<θ<π2-\tfrac{\pi}{2} < \theta < \tfrac{\pi}{2} 1+tan⁡2θ=sec⁡2θ1 + \tan^2\theta = \sec^2\theta
x2−a2\sqrt{x^2 - a^2} x=asec⁡θ,x = a\sec\theta\mathclose{\text{,}} 0≤θ<π20 \le \theta < \tfrac{\pi}{2} sec⁡2θ−1=tan⁡2θ\sec^2\theta - 1 = \tan^2\theta

The ranges of θ\theta do two jobs. On them cos⁡θ≥0,\cos\theta \ge 0\mathclose{\text{,}} sec⁡θ>0\sec\theta > 0 and tan⁡θ≥0\tan\theta \ge 0 respectively, so the square roots are a2−x2=acos⁡θ,\sqrt{a^2 - x^2} = a\cos\theta\mathclose{\text{,}} a2+x2=asec⁡θ\sqrt{a^2 + x^2} = a\sec\theta and x2−a2=atan⁡θ,\sqrt{x^2 - a^2} = a\tan\theta\mathclose{\text{,}} with no absolute value signs. And on them each substitution is one-to-one, so θ\theta can be recovered from x:x\mathclose{\text{:}} θ=arcsin⁡xa,\theta = \arcsin\dfrac{x}{a}\mathclose{\text{,}} θ=arctan⁡xa\theta = \arctan\dfrac{x}{a} and, for x≥a,x \ge a\mathclose{\text{,}} θ=arccos⁡ax\theta = \arccos\dfrac{a}{x} (since sec⁡θ=x/a\sec\theta = x/a means cos⁡θ=a/x).\cos\theta = a/x\mathclose{\text{).}}

The secant row covers only x≥a.x \ge a\mathclose{\text{.}} For x≤−a,x \le -a\mathclose{\text{,}} take π2<θ≤π\tfrac{\pi}{2} < \theta \le \pi instead, where sec⁡θ≤−1.\sec\theta \le -1\mathclose{\text{.}} There tan⁡θ≤0,\tan\theta \le 0\mathclose{\text{,}} so x2−a2=∣atan⁡θ∣=−atan⁡θ,\sqrt{x^2 - a^2} = \abs{a\tan\theta} = -a\tan\theta\mathclose{\text{,}} and the minus sign must be carried through the calculation. In both cases θ=arccos⁡ax,\theta = \arccos\dfrac{a}{x}\mathclose{\text{,}} which is arcsec⁡xa\arcsec\dfrac{x}{a} in the convention of Module 6. Often it is simpler to put x=−tx = -t first, so that t≥a.t \ge a\mathclose{\text{.}}

Example 11.12The area of a circle and of an ellipse✓ Checked

Find the area enclosed by the circle x2+y2=r2,x^2 + y^2 = r^2\mathclose{\text{,}} and by the ellipse x2a2+y2b2=1,\dfrac{x^2}{a^2} + \dfrac{y^2}{b^2} = 1\mathclose{\text{,}} where r,r\mathclose{\text{,}} aa and bb are positive.

The circle. The upper half of the disc is the region under the graph of y=r2−x2,y = \sqrt{r^2 - x^2}\mathclose{\text{,}} for −r≤x≤r,-r \le x \le r\mathclose{\text{,}} and the lower half is its mirror image in the xx-axis. So the area of the disc is ∫−rr2r2−x2 dx.\int_{-r}^{r} 2\sqrt{r^2 - x^2}\,dx\mathclose{\text{.}} Substitute x=rsin⁡θx = r\sin\theta with −π2≤θ≤π2.-\tfrac{\pi}{2} \le \theta \le \tfrac{\pi}{2}\mathclose{\text{.}} Then dx=rcos⁡θ dθ,dx = r\cos\theta\,d\theta\mathclose{\text{,}} and r2−r2sin⁡2θ=r2cos⁡2θ=rcos⁡θ,\sqrt{r^2 - r^2\sin^2\theta} = \sqrt{r^2\cos^2\theta} = r\cos\theta\mathclose{\text{,}} because cos⁡θ≥0\cos\theta \ge 0 on this range. The limits x=−rx = -r and x=rx = r correspond to θ=−π2\theta = -\tfrac{\pi}{2} and θ=π2.\theta = \tfrac{\pi}{2}\mathclose{\text{.}} By Theorem 11.5(a) and Example 11.9(a),

∫−rr2r2−x2 dx=∫−π/2π/22rcos⁡θ⋅rcos⁡θ dθ=2r2∫−π/2π/2cos⁡2θ dθ=2r2[θ2+sin⁡2θ4]−π/2π/2=2r2⋅π2=πr2.\begin{aligned} &\int_{-r}^{r} 2\sqrt{r^2 - x^2}\,dx \\ &\quad= \int_{-\pi/2}^{\pi/2} 2r\cos\theta\cdot r\cos\theta\,d\theta \\ &\quad= 2r^2\int_{-\pi/2}^{\pi/2} \cos^2\theta\,d\theta \\ &\quad= 2r^2\Big[\frac{\theta}{2} + \frac{\sin 2\theta}{4}\Big]_{-\pi/2}^{\pi/2} \\ &\quad= 2r^2\cdot\frac{\pi}{2} = \pi r^2. \end{aligned}

The ellipse. Solving its equation for yy gives y=±baa2−x2,y = \pm\tfrac{b}{a}\sqrt{a^2 - x^2}\mathclose{\text{,}} for −a≤x≤a.-a \le x \le a\mathclose{\text{.}} In the same way, the upper half of the region inside the ellipse lies under the graph of y=baa2−x2,y = \tfrac{b}{a}\sqrt{a^2 - x^2}\mathclose{\text{,}} and the lower half is its mirror image. So the area is ba\tfrac{b}{a} times that of the disc of radius a:a\mathclose{\text{:}}

ba∫−aa2a2−x2 dx=ba⋅πa2=πab.\frac{b}{a}\int_{-a}^{a} 2\sqrt{a^2 - x^2}\,dx = \frac{b}{a}\cdot\pi a^2 = \pi ab.

For a=b=ra = b = r the ellipse is the circle, and πab=πr2,\pi ab = \pi r^2\mathclose{\text{,}} as it should be.

Good to know

Example 11.12 does not prove from nothing that a disc has area πr2.\pi r^2\mathclose{\text{.}} It uses the derivatives of the sine and cosine (Module 5). They rest on the limit sin⁡θ/θ→1,\sin\theta/\theta \to 1\mathclose{\text{,}} and Module 2 proved that limit with the area π\pi of the disc of radius 1, taken from geometry. What the example proves is that this one fact gives the area of every disc and of every ellipse.

Back to x with a triangle

In an indefinite integral the answer comes out in terms of θ\theta and must be written in terms of xx again. A right triangle does it. Draw one with an angle θ\theta whose sides make the substitution true; Pythagoras’ theorem gives the third side, and the other trigonometric functions of θ\theta can be read off (Figure 11.2).

The reference triangles of the three substitutions. Left: x = asintheta means sintheta = x/a, opposite side over hypotenuse; the third side is sqrt{a^2 - x^2}, so, for example, costheta = sqrt{a^2 - x^2}/a and cottheta = sqrt{a^2 - x^2}/x. Middle: x = atantheta, with hypotenuse sqrt{a^2 + x^2}. Right: x = asectheta, that is, costheta = a/x, with opposite side sqrt{x^2 - a^2}. The triangles show 0 < theta < pi/2; the formulas read from them hold on the whole ranges in the table.
Figure 11.2

The reference triangles of the three substitutions. Left: x=asin⁡θx = a\sin\theta means sin⁡θ=x/a,\sin\theta = x/a\mathclose{\text{,}} opposite side over hypotenuse; the third side is a2−x2,\sqrt{a^2 - x^2}\mathclose{\text{,}} so, for example, cos⁡θ=a2−x2/a\cos\theta = \sqrt{a^2 - x^2}/a and cot⁡θ=a2−x2/x.\cot\theta = \sqrt{a^2 - x^2}/x\mathclose{\text{.}} Middle: x=atan⁡θ,x = a\tan\theta\mathclose{\text{,}} with hypotenuse a2+x2.\sqrt{a^2 + x^2}\mathclose{\text{.}} Right: x=asec⁡θ,x = a\sec\theta\mathclose{\text{,}} that is, cos⁡θ=a/x,\cos\theta = a/x\mathclose{\text{,}} with opposite side x2−a2.\sqrt{x^2 - a^2}\mathclose{\text{.}} The triangles show 0<θ<π/2;0 < \theta < \pi/2\mathclose{\text{;}} the formulas read from them hold on the whole ranges in the table.

Example 11.13Back to x✓ Checked

Find ∫9−x2x2 dx\displaystyle\int \frac{\sqrt{9 - x^2}}{x^2}\,dx for 0<x<3.0 < x < 3\mathclose{\text{.}}

Substitute x=3sin⁡θx = 3\sin\theta with 0<θ<π2,0 < \theta < \tfrac{\pi}{2}\mathclose{\text{,}} one-to-one onto (0,3).(0, 3)\mathclose{\text{.}} Then dx=3cos⁡θ dθdx = 3\cos\theta\,d\theta and 9−x2=3cos⁡θ,\sqrt{9 - x^2} = 3\cos\theta\mathclose{\text{,}} so

∫9−x2x2 dx=∫3cos⁡θ9sin⁡2θ 3cos⁡θ dθ=∫cot⁡2θ dθ=∫(csc⁡2θ−1) dθ=−cot⁡θ−θ+C,\begin{aligned} &\int \frac{\sqrt{9 - x^2}}{x^2}\,dx \\ &\quad= \int \frac{3\cos\theta}{9\sin^2\theta}\,3\cos\theta\,d\theta \\ &\quad= \int \cot^2\theta\,d\theta \\ &\quad= \int \big(\csc^2\theta - 1\big)\,d\theta \\ &\quad= -\cot\theta - \theta + C, \end{aligned}

where cot⁡2θ=csc⁡2θ−1\cot^2\theta = \csc^2\theta - 1 comes from dividing cos⁡2θ+sin⁡2θ=1\cos^2\theta + \sin^2\theta = 1 by sin⁡2θ,\sin^2\theta\mathclose{\text{,}} and −cot⁡θ-\cot\theta is an antiderivative of csc⁡2θ\csc^2\theta (Module 10’s table). Now back to x,x\mathclose{\text{,}} with the left triangle of Figure 11.2 and a=3:a = 3\mathclose{\text{:}} cot⁡θ=9−x2x\cot\theta = \dfrac{\sqrt{9 - x^2}}{x} and θ=arcsin⁡x3.\theta = \arcsin\dfrac{x}{3}\mathclose{\text{.}} By Theorem 11.5(b),

∫9−x2x2 dx=−9−x2x−arcsin⁡x3+C.\begin{aligned} &\int \frac{\sqrt{9 - x^2}}{x^2}\,dx \\ &\quad= -\frac{\sqrt{9 - x^2}}{x} - \arcsin\frac{x}{3} + C. \end{aligned}

The same steps, with −π2<θ<0,-\tfrac{\pi}{2} < \theta < 0\mathclose{\text{,}} give the same formula on (−3,0).(-3, 0)\mathclose{\text{.}} Check by differentiating: the derivative of −9−x2/x-\sqrt{9 - x^2}/x is 9x29−x2\dfrac{9}{x^2\sqrt{9 - x^2}} (quotient rule, then a common denominator), that of −arcsin⁡x3-\arcsin\dfrac{x}{3} is −19−x2,-\dfrac{1}{\sqrt{9 - x^2}}\mathclose{\text{,}} and their sum is 9−x2x29−x2=9−x2x2.\dfrac{9 - x^2}{x^2\sqrt{9 - x^2}} = \dfrac{\sqrt{9 - x^2}}{x^2}\mathclose{\text{.}}

Example 11.14Tangent and secant substitutions✓ Checked

Find (a) ∫dxx2+4\displaystyle\int \frac{dx}{\sqrt{x^2 + 4}} and (b) ∫x2−4x dx\displaystyle\int \frac{\sqrt{x^2 - 4}}{x}\,dx for x>2.x > 2\mathclose{\text{.}}

(a) Substitute x=2tan⁡θx = 2\tan\theta with −π2<θ<π2.-\tfrac{\pi}{2} < \theta < \tfrac{\pi}{2}\mathclose{\text{.}} Then dx=2sec⁡2θ dθdx = 2\sec^2\theta\,d\theta and x2+4=4tan⁡2θ+4=2sec⁡θ,\sqrt{x^2 + 4} = \sqrt{4\tan^2\theta + 4} = 2\sec\theta\mathclose{\text{,}} so, by Theorem 11.4,

∫dxx2+4=∫2sec⁡2θ2sec⁡θ dθ=∫sec⁡θ dθ=ln⁡∣sec⁡θ+tan⁡θ∣+C1.\begin{aligned} \int \frac{dx}{\sqrt{x^2 + 4}} &= \int \frac{2\sec^2\theta}{2\sec\theta}\,d\theta \\ &= \int \sec\theta\,d\theta \\ &= \ln\abs{\sec\theta + \tan\theta} + C_1. \end{aligned}

The middle triangle of Figure 11.2, with a=2,a = 2\mathclose{\text{,}} gives tan⁡θ=x2\tan\theta = \dfrac{x}{2} and sec⁡θ=x2+42.\sec\theta = \dfrac{\sqrt{x^2 + 4}}{2}\mathclose{\text{.}} So the integral is

ln⁡∣x+x2+42∣+C1=ln⁡(x+x2+4)+C,\begin{aligned} &\ln\Big|\frac{x + \sqrt{x^2 + 4}}{2}\Big| + C_1 \\ &\quad= \ln\big(x + \sqrt{x^2 + 4}\big) + C, \end{aligned}

where C=C1−ln⁡2,C = C_1 - \ln 2\mathclose{\text{,}} and the absolute value bars can go because x+x2+4>x+∣x∣≥0.x + \sqrt{x^2 + 4} > x + \abs{x} \ge 0\mathclose{\text{.}} In the same way, for every constant a≠0,a \ne 0\mathclose{\text{,}}

∫dxx2+a2=ln⁡(x+x2+a2)+C.\begin{aligned} &\int \frac{dx}{\sqrt{x^2 + a^2}} \\ &\quad= \ln\big(x + \sqrt{x^2 + a^2}\big) + C. \end{aligned}

For a=1a = 1 this antiderivative is the inverse hyperbolic sine, arsinh⁡x,\operatorname{arsinh} x\mathclose{\text{,}} of Exercise 6.10.

(b) Substitute x=2sec⁡θx = 2\sec\theta with 0<θ<π2,0 < \theta < \tfrac{\pi}{2}\mathclose{\text{,}} one-to-one onto (2,∞).(2, \infty)\mathclose{\text{.}} Then dx=2sec⁡θtan⁡θ dθdx = 2\sec\theta\tan\theta\,d\theta and x2−4=2tan⁡θ,\sqrt{x^2 - 4} = 2\tan\theta\mathclose{\text{,}} so, with Example 11.10(c),

∫x2−4x dx=∫2tan⁡θ2sec⁡θ 2sec⁡θtan⁡θ dθ=2∫tan⁡2θ dθ=2tan⁡θ−2θ+C.\begin{aligned} &\int \frac{\sqrt{x^2 - 4}}{x}\,dx \\ &\quad= \int \frac{2\tan\theta}{2\sec\theta}\,2\sec\theta\tan\theta\,d\theta \\ &\quad= 2\int \tan^2\theta\,d\theta \\ &\quad= 2\tan\theta - 2\theta + C. \end{aligned}

The right triangle of Figure 11.2 gives tan⁡θ=x2−42,\tan\theta = \dfrac{\sqrt{x^2 - 4}}{2}\mathclose{\text{,}} and cos⁡θ=2x\cos\theta = \dfrac{2}{x} gives θ=arccos⁡2x.\theta = \arccos\dfrac{2}{x}\mathclose{\text{.}} So, for x>2,x > 2\mathclose{\text{,}}

∫x2−4x dx=x2−4−2arccos⁡2x+C.\begin{aligned} &\int \frac{\sqrt{x^2 - 4}}{x}\,dx \\ &\quad= \sqrt{x^2 - 4} - 2\arccos\frac{2}{x} + C. \end{aligned}
Watch out

Four slips with trigonometric substitution. (1) Forgetting that dxdx changes too: with x=asin⁡θ,x = a\sin\theta\mathclose{\text{,}} dx=acos⁡θ dθ,dx = a\cos\theta\,d\theta\mathclose{\text{,}} not dθ.d\theta\mathclose{\text{.}} (2) cos⁡2θ=∣cos⁡θ∣;\sqrt{\cos^2\theta} = \abs{\cos\theta}\mathclose{\text{;}} it is cos⁡θ\cos\theta only because the range of θ\theta keeps cos⁡θ≥0.\cos\theta \ge 0\mathclose{\text{.}} (3) In a definite integral, change the limits to values of θ,\theta\mathclose{\text{,}} as in Example 11.12, or return to xx before using the old limits. (4) A quadratic with a term in xx needs completing the square first: 5−4x−x2=9−(x+2)2,\sqrt{5 - 4x - x^2} = \sqrt{9 - (x + 2)^2}\mathclose{\text{,}} and then x+2=3sin⁡θ.x + 2 = 3\sin\theta\mathclose{\text{.}}

4

Partial fractions

Adding fractions is school algebra:

2x−2+3x+1=2(x+1)+3(x−2)(x−2)(x+1)=5x−4x2−x−2.\begin{aligned} \frac{2}{x - 2} + \frac{3}{x + 1} &= \frac{2(x + 1) + 3(x - 2)}{(x - 2)(x + 1)} \\ &= \frac{5x - 4}{x^2 - x - 2}. \end{aligned}

The left side is easy to integrate, to 2ln⁡∣x−2∣+3ln⁡∣x+1∣+C.2\ln\abs{x - 2} + 3\ln\abs{x + 1} + C\mathclose{\text{.}} So the right side is easy to integrate too, once you can run the addition backwards. Writing a rational function as a sum of simpler fractions of this kind is called decomposing it into partial fractions. Every rational function can be decomposed, with a polynomial added in front when it is improper (below).

Definition 11.1Proper and improper rational functions

A rational function P(x)Q(x)\dfrac{P(x)}{Q(x)} (Module 1) is proper if the degree of the polynomial PP is less than the degree of Q,Q\mathclose{\text{,}} and improper otherwise.

Long division of polynomials turns an improper rational function into a polynomial plus a proper one: dividing PP by QQ gives a quotient SS and a remainder R,R\mathclose{\text{,}} polynomials with P=SQ+RP = SQ + R and deg⁡R<deg⁡Q,\deg R < \deg Q\mathclose{\text{,}} so that

P(x)Q(x)=S(x)+R(x)Q(x).\frac{P(x)}{Q(x)} = S(x) + \frac{R(x)}{Q(x)}.

The polynomial SS is integrated term by term; partial fractions are for the proper part.

Distinct linear factors

Start with a denominator that is a product of different linear factors, such as x2−x−2=(x−2)(x+1),x^2 - x - 2 = (x - 2)(x + 1)\mathclose{\text{,}} and suppose you did not know the answer above. Look for constants AA and BB with

5x−4(x−2)(x+1)=Ax−2+Bx+1.\frac{5x - 4}{(x - 2)(x + 1)} = \frac{A}{x - 2} + \frac{B}{x + 1}.

Multiply both sides by (x−2)(x+1):(x - 2)(x + 1)\mathclose{\text{:}}

5x−4=A(x+1)+B(x−2).5x - 4 = A(x + 1) + B(x - 2).

This must hold for every xx except 2 and −1,-1\mathclose{\text{,}} and so for every x,x\mathclose{\text{,}} since both sides are straight lines and two lines that share more than one point are the same line. Put x=2:x = 2\mathclose{\text{:}} 6=3A,6 = 3A\mathclose{\text{,}} so A=2.A = 2\mathclose{\text{.}} Put x=−1:x = -1\mathclose{\text{:}} −9=−3B,-9 = -3B\mathclose{\text{,}} so B=3.B = 3\mathclose{\text{.}} (Comparing coefficients works too: A+B=5A + B = 5 and A−2B=−4.)A - 2B = -4\mathclose{\text{.)}}

There is a shortcut. To find A,A\mathclose{\text{,}} the coefficient of 1x−2,\dfrac{1}{x - 2}\mathclose{\text{,}} cover up the factor x−2x - 2 in the denominator of the left side and put x=2x = 2 in what is left: 5⋅2−42+1=2.\dfrac{5\cdot 2 - 4}{2 + 1} = 2\mathclose{\text{.}} For B,B\mathclose{\text{,}} cover up x+1x + 1 and put x=−1:x = -1\mathclose{\text{:}} 5(−1)−4−1−2=3.\dfrac{5(-1) - 4}{-1 - 2} = 3\mathclose{\text{.}} This is the cover-up method. It works because multiplying the decomposition by x−2x - 2 gives

5x−4x+1=A+B x−2x+1\frac{5x - 4}{x + 1} = A + B\,\frac{x - 2}{x + 1}

for xx near 2; as x→2,x \to 2\mathclose{\text{,}} the left side tends to its value at 2 and the last term tends to 0, which leaves A.A\mathclose{\text{.}}

Key idea

The cover-up method. If x−rx - r is a factor of the denominator Q(x)Q(x) that appears only once, the coefficient of 1x−r\dfrac{1}{x - r} in the decomposition of P(x)Q(x)\dfrac{P(x)}{Q(x)} is the value at x=rx = r of the fraction with the factor x−rx - r covered up.

Example 11.15Two logarithms✓ Checked

Find (a) ∫5x−4x2−x−2 dx\displaystyle\int \frac{5x - 4}{x^2 - x - 2}\,dx and (b) ∫dxx2−a2,\displaystyle\int \frac{dx}{x^2 - a^2}\mathclose{\text{,}} where a≠0a \ne 0 is a constant.

(a) By the decomposition above, on each interval that avoids 2 and −1,-1\mathclose{\text{,}}

∫5x−4x2−x−2 dx=2ln⁡∣x−2∣+3ln⁡∣x+1∣+C.\begin{aligned} &\int \frac{5x - 4}{x^2 - x - 2}\,dx \\ &\quad= 2\ln\abs{x - 2} + 3\ln\abs{x + 1} + C. \end{aligned}

(b) x2−a2=(x−a)(x+a),x^2 - a^2 = (x - a)(x + a)\mathclose{\text{,}} two different factors since a≠0.a \ne 0\mathclose{\text{.}} Cover up x−ax - a and put x=a:x = a\mathclose{\text{:}} the coefficient of 1x−a\dfrac{1}{x - a} is 1a+a=12a.\dfrac{1}{a + a} = \dfrac{1}{2a}\mathclose{\text{.}} Cover up x+ax + a and put x=−a:x = -a\mathclose{\text{:}} the coefficient of 1x+a\dfrac{1}{x + a} is 1−a−a=−12a.\dfrac{1}{-a - a} = -\dfrac{1}{2a}\mathclose{\text{.}} So

1x2−a2=12a(1x−a−1x+a),\frac{1}{x^2 - a^2} = \frac{1}{2a}\Big(\frac{1}{x - a} - \frac{1}{x + a}\Big),

and, for x≠±a,x \ne \pm a\mathclose{\text{,}}

∫dxx2−a2=12a(ln⁡∣x−a∣−ln⁡∣x+a∣)+C=12aln⁡∣x−ax+a∣+C.\begin{aligned} &\int \frac{dx}{x^2 - a^2} \\ &\quad= \frac{1}{2a}\big(\ln\abs{x - a} - \ln\abs{x + a}\big) + C \\ &\quad= \frac{1}{2a}\ln\Big|\frac{x - a}{x + a}\Big| + C. \end{aligned}

The method works whenever the denominator is a product of different linear factors.

Theorem 11.6Partial fractions with distinct linear factors

Let Q(x)=(x−r1)(x−r2)⋯(x−rn),Q(x) = (x - r_1)(x - r_2)\cdots(x - r_n)\mathclose{\text{,}} where the numbers r1,…,rnr_1, \dots, r_n are all different, and let PP be a polynomial of degree less than n.n\mathclose{\text{.}} Then there are unique constants A1,…,AnA_1, \dots, A_n with

P(x)Q(x)=A1x−r1+A2x−r2+⋯+Anx−rn\begin{aligned} \frac{P(x)}{Q(x)} &= \frac{A_1}{x - r_1} + \frac{A_2}{x - r_2} \\ &\quad + \dots + \frac{A_n}{x - r_n} \end{aligned}

for every xx other than r1,…,rn.r_1, \dots, r_n\mathclose{\text{.}} Each AkA_k is given by the cover-up method:

Ak=P(rk)Qk(rk),whereQk(x)=Q(x)x−rk.\begin{aligned} A_k &= \frac{P(r_k)}{Q_k(r_k)}, \quad\text{where} \\ Q_k(x) &= \frac{Q(x)}{x - r_k}. \end{aligned}
Proof

Existence. QkQ_k is the product of the n−1n - 1 factors other than x−rk,x - r_k\mathclose{\text{,}} a polynomial of degree n−1,n - 1\mathclose{\text{,}} and Qk(rk)≠0Q_k(r_k) \ne 0 because the numbers rjr_j are all different. Define AkA_k by the formula, and consider the polynomial

D(x)=P(x)−A1Q1(x)−A2Q2(x)−⋯−AnQn(x).\begin{aligned} D(x) &= P(x) - A_1Q_1(x) - A_2Q_2(x) \\ &\quad - \dots - A_nQ_n(x). \end{aligned}

Its degree is less than n.n\mathclose{\text{.}} At x=rk,x = r_k\mathclose{\text{,}} every QjQ_j with j≠kj \ne k contains the factor x−rkx - r_k and so vanishes, and D(rk)=P(rk)−AkQk(rk)=0D(r_k) = P(r_k) - A_kQ_k(r_k) = 0 by the choice of Ak.A_k\mathclose{\text{.}} So DD has the nn different zeros r1,…,rn.r_1, \dots, r_n\mathclose{\text{.}} But a polynomial of degree less than nn that is not the zero polynomial has fewer than nn zeros (by school algebra, each zero rr gives a factor x−r,x - r\mathclose{\text{,}} and nn such factors would make the degree at least n).n\mathclose{\text{).}} So DD is the zero polynomial: P=A1Q1+⋯+AnQn.P = A_1Q_1 + \dots + A_nQ_n\mathclose{\text{.}} Divide by Q,Q\mathclose{\text{,}} using Qk(x)Q(x)=1x−rk.\dfrac{Q_k(x)}{Q(x)} = \dfrac{1}{x - r_k}\mathclose{\text{.}}

Uniqueness. Suppose the constants AkA_k satisfy the equation. Multiply it by x−rk:x - r_k\mathclose{\text{:}} for xx near rk,r_k\mathclose{\text{,}} x≠rk,x \ne r_k\mathclose{\text{,}}

P(x)Qk(x)=Ak+(x−rk)∑j≠kAjx−rj.\frac{P(x)}{Q_k(x)} = A_k + (x - r_k)\sum_{j \ne k} \frac{A_j}{x - r_j}.

Let x→rk.x \to r_k\mathclose{\text{.}} Both sides are continuous at rk,r_k\mathclose{\text{,}} and the right side tends to Ak,A_k\mathclose{\text{,}} so Ak=P(rk)/Qk(rk):A_k = P(r_k)/Q_k(r_k)\mathclose{\text{:}} the constants can only be those of the formula.

∎
Example 11.16Long division first✓ Checked

Find ∫x3+2x2+2x−2x2+x−2 dx.\displaystyle\int \frac{x^3 + 2x^2 + 2x - 2}{x^2 + x - 2}\,dx\mathclose{\text{.}}

The fraction is improper, degree 3 over degree 2, so divide first. x3x^3 divided by x2x^2 is x;x\mathclose{\text{;}} subtract x(x2+x−2)=x3+x2−2xx\big(x^2 + x - 2\big) = x^3 + x^2 - 2x from the numerator, which leaves x2+4x−2.x^2 + 4x - 2\mathclose{\text{.}} Then x2x^2 divided by x2x^2 is 1; subtract x2+x−2,x^2 + x - 2\mathclose{\text{,}} which leaves 3x.3x\mathclose{\text{.}} The remainder 3x3x has degree less than 2, so stop: the quotient is x+1x + 1 and the remainder 3x,3x\mathclose{\text{,}}

x3+2x2+2x−2x2+x−2=x+1+3xx2+x−2.\begin{aligned} &\frac{x^3 + 2x^2 + 2x - 2}{x^2 + x - 2} \\ &\quad= x + 1 + \frac{3x}{x^2 + x - 2}. \end{aligned}

Now x2+x−2=(x−1)(x+2),x^2 + x - 2 = (x - 1)(x + 2)\mathclose{\text{,}} and the cover-up method gives the coefficients 3⋅11+2=1\dfrac{3\cdot 1}{1 + 2} = 1 and 3(−2)−2−1=2:\dfrac{3(-2)}{-2 - 1} = 2\mathclose{\text{:}}

3x(x−1)(x+2)=1x−1+2x+2.\frac{3x}{(x - 1)(x + 2)} = \frac{1}{x - 1} + \frac{2}{x + 2}.

So

∫x3+2x2+2x−2x2+x−2 dx=x22+x+ln⁡∣x−1∣+2ln⁡∣x+2∣+C.\begin{aligned} &\int \frac{x^3 + 2x^2 + 2x - 2}{x^2 + x - 2}\,dx \\ &\quad= \frac{x^2}{2} + x + \ln\abs{x - 1} \\ &\qquad + 2\ln\abs{x + 2} + C. \end{aligned}

Repeated and quadratic factors

Two things can complicate a denominator. A factor may be repeated, as in (x−1)2(x+1).(x - 1)^2(x + 1)\mathclose{\text{.}} And a quadratic factor such as x2+1x^2 + 1 may have no real zeros, so that it does not split into real linear factors. A quadratic x2+px+qx^2 + px + q with p2<4qp^2 < 4q (a negative discriminant) is called irreducible. A theorem of algebra, which this series uses without proof, says that every polynomial with real coefficients is a product of a constant, linear factors and irreducible quadratic factors. (It follows from the fundamental theorem of algebra.) So the next theorem covers every proper rational function, at least in principle: finding the factors of QQ can be the hard part.

Theorem 11.7Partial fraction decomposition

Let P(x)Q(x)\dfrac{P(x)}{Q(x)} be a proper rational function, and let QQ be factored as a constant times powers of different linear factors x−rx - r and of different irreducible quadratic factors x2+px+q.x^2 + px + q\mathclose{\text{.}} Then P(x)Q(x)\dfrac{P(x)}{Q(x)} is a sum of the following terms, with unique constants:

  • for each factor (x−r)k(x - r)^k of Q,Q\mathclose{\text{,}} the kk terms A1x−r+A2(x−r)2+⋯+Ak(x−r)k;\dfrac{A_1}{x - r} + \dfrac{A_2}{(x - r)^2} + \dots + \dfrac{A_k}{(x - r)^k}\mathclose{\text{;}}
  • for each factor (x2+px+q)m\big(x^2 + px + q\big)^m of Q,Q\mathclose{\text{,}} the mm terms B1x+C1x2+px+q+⋯+Bmx+Cm(x2+px+q)m.\dfrac{B_1x + C_1}{x^2 + px + q} + \dots + \dfrac{B_mx + C_m}{\big(x^2 + px + q\big)^m}\mathclose{\text{.}}

Theorem 11.6 is the case in which every power is 1 and there are no quadratic factors; the general case is proved in algebra courses, and this series uses it without proof. To find the constants, multiply by Q(x)Q(x) and compare coefficients, or put convenient values of x;x\mathclose{\text{;}} the cover-up method still gives the coefficient of the highest power of each linear factor. Each term then integrates with the methods you know: a power of x−rx - r by the power rule or to a logarithm, and a quadratic term by completing the square, a logarithm and an arctangent. (A power m≥2m \ge 2 of an irreducible quadratic needs a trigonometric substitution as well.)

Example 11.17Repeated and quadratic factors✓ Checked

Find (a) ∫4x(x−1)2(x+1) dx\displaystyle\int \frac{4x}{(x - 1)^2(x + 1)}\,dx and (b) ∫2x2+4x+4(x+1)(x2+1) dx.\displaystyle\int \frac{2x^2 + 4x + 4}{(x + 1)\big(x^2 + 1\big)}\,dx\mathclose{\text{.}}

(a) By Theorem 11.7, with constants A,A\mathclose{\text{,}} BB and D,D\mathclose{\text{,}}

4x(x−1)2(x+1)=Ax−1+B(x−1)2+Dx+1.\begin{aligned} \frac{4x}{(x - 1)^2(x + 1)} &= \frac{A}{x - 1} + \frac{B}{(x - 1)^2} \\ &\quad + \frac{D}{x + 1}. \end{aligned}

The cover-up method gives the coefficient of the highest power of x−1,x - 1\mathclose{\text{,}} B=4⋅11+1=2,B = \dfrac{4\cdot 1}{1 + 1} = 2\mathclose{\text{,}} and D=4(−1)(−1−1)2=−1.D = \dfrac{4(-1)}{(-1 - 1)^2} = -1\mathclose{\text{.}} For A,A\mathclose{\text{,}} multiply by the denominator,

4x=A(x−1)(x+1)+B(x+1)+D(x−1)2,\begin{aligned} 4x &= A(x - 1)(x + 1) \\ &\quad + B(x + 1) + D(x - 1)^2, \end{aligned}

and compare the coefficients of x2:x^2\mathclose{\text{:}} 0=A+D,0 = A + D\mathclose{\text{,}} so A=1.A = 1\mathclose{\text{.}} Then

∫4x(x−1)2(x+1) dx=∫(1x−1+2(x−1)2−1x+1) dx=ln⁡∣x−1∣−2x−1−ln⁡∣x+1∣+C.\begin{aligned} &\int \frac{4x}{(x - 1)^2(x + 1)}\,dx \\ &\quad= \int \Big(\frac{1}{x - 1} + \frac{2}{(x - 1)^2} \\ &\qquad - \frac{1}{x + 1}\Big)\,dx \\ &\quad= \ln\abs{x - 1} - \frac{2}{x - 1} \\ &\qquad - \ln\abs{x + 1} + C. \end{aligned}

(b) x2+1x^2 + 1 is irreducible (02<4⋅1),0^2 < 4\cdot 1\mathclose{\text{),}} so

2x2+4x+4(x+1)(x2+1)=Ax+1+Bx+Dx2+1.\frac{2x^2 + 4x + 4}{(x + 1)\big(x^2 + 1\big)} = \frac{A}{x + 1} + \frac{Bx + D}{x^2 + 1}.

The cover-up method gives A=2−4+4(−1)2+1=1.A = \dfrac{2 - 4 + 4}{(-1)^2 + 1} = 1\mathclose{\text{.}} Multiply by the denominator: 2x2+4x+4=(x2+1)+(Bx+D)(x+1).2x^2 + 4x + 4 = \big(x^2 + 1\big) + (Bx + D)(x + 1)\mathclose{\text{.}} Comparing the coefficients of x2x^2 gives 2=1+B,2 = 1 + B\mathclose{\text{,}} so B=1,B = 1\mathclose{\text{,}} and the constant terms give 4=1+D,4 = 1 + D\mathclose{\text{,}} so D=3;D = 3\mathclose{\text{;}} the coefficients of xx agree, 4=B+D.4 = B + D\mathclose{\text{.}} So the integrand is

1x+1+xx2+1+3x2+1,\frac{1}{x + 1} + \frac{x}{x^2 + 1} + \frac{3}{x^2 + 1},

and, with the substitution w=x2+1w = x^2 + 1 for the middle term,

∫2x2+4x+4(x+1)(x2+1) dx=ln⁡∣x+1∣+12ln⁡(x2+1)+3arctan⁡x+C.\begin{aligned} &\int \frac{2x^2 + 4x + 4}{(x + 1)\big(x^2 + 1\big)}\,dx \\ &\quad= \ln\abs{x + 1} + \tfrac12\ln\big(x^2 + 1\big) \\ &\qquad + 3\arctan x + C. \end{aligned}
Watch out

Four slips with partial fractions. (1) Not dividing first. x3x2−1\dfrac{x^3}{x^2 - 1} is improper; it is x+xx2−1,x + \dfrac{x}{x^2 - 1}\mathclose{\text{,}} and only the second part has the form Ax−1+Bx+1.\dfrac{A}{x - 1} + \dfrac{B}{x + 1}\mathclose{\text{.}} (2) Leaving out a power of a repeated factor. In Example 11.17(a), the form B(x−1)2+Dx+1\dfrac{B}{(x - 1)^2} + \dfrac{D}{x + 1} without Ax−1\dfrac{A}{x - 1} has no solution: in 4x=B(x+1)+D(x−1)2,4x = B(x + 1) + D(x - 1)^2\mathclose{\text{,}} the terms in x2x^2 give D=0,D = 0\mathclose{\text{,}} then the terms in xx give B=4,B = 4\mathclose{\text{,}} and then the constant terms say 0=B+D=4.0 = B + D = 4\mathclose{\text{.}} (3) A constant numerator over an irreducible quadratic: it must be Bx+C.Bx + C\mathclose{\text{.}} (4) Missing a substitution: ∫x2+1x3+3x dx=13ln⁡∣x3+3x∣+C\displaystyle\int \frac{x^2 + 1}{x^3 + 3x}\,dx = \tfrac13\ln\abs{x^3 + 3x} + C with u=x3+3x,u = x^3 + 3x\mathclose{\text{,}} no partial fractions needed.

Compute itPartial fractions with SymPy

SymPy’s factor finds the factors, div divides polynomials, and apart decomposes a rational function into partial fractions:

Python
import sympy as sp
x = sp.symbols('x')
P = x**3 + 2*x**2 + 2*x - 2
Q = x**2 + x - 2
print(sp.factor(Q))
print(sp.div(P, Q, x))                  # (quotient, remainder)
print(sp.apart(P/Q, x))                 # Example 11.16
print(sp.apart((2*x**2 + 4*x + 4)/((x + 1)*(x**2 + 1)), x))
Output
(x - 1)*(x + 2)
(x + 1, 3*x)
x + 1 + 2/(x + 2) + 1/(x - 1)
(x + 3)/(x**2 + 1) + 1/(x + 1)

These are Example 11.16, in SymPy’s order of terms, and Example 11.17(b) before its last split. SymPy factors over the rational numbers, so a denominator such as x2−2,x^2 - 2\mathclose{\text{,}} whose zeros ±2\pm\sqrt2 are irrational, stays whole unless you say which numbers to allow:

Python
print(sp.apart(1/(x**2 - 2), x))
print(sp.apart(1/(x**2 - 2), x, extension=sp.sqrt(2)))
Output
1/(x**2 - 2)
-sqrt(2)/(4*(x + sqrt(2))) + sqrt(2)/(4*(x - sqrt(2)))

The second answer is Example 11.15(b) with a=2,a = \sqrt2\mathclose{\text{,}} since 122=24.\tfrac{1}{2\sqrt2} = \tfrac{\sqrt2}{4}\mathclose{\text{.}}

5

A strategy for integration

Differentiation is mechanical: the rules of Modules 4 to 6 differentiate every formula built from the catalogue of Module 1. Integration is not. No set of rules always works, the same integrand may give way to several methods, and some integrands give way to none (Section 11.6). What you have is a toolbox and a checklist.

Key idea

A strategy for integration.

  1. Simplify the integrand if you can: expand, cancel, split a fraction, use an identity such as sin⁡xcos⁡x=12sin⁡2x\sin x\cos x = \tfrac12\sin 2x or tan⁡2x=sec⁡2x−1.\tan^2 x = \sec^2 x - 1\mathclose{\text{.}} Then look in the table of Section 10.1.
  2. Substitute if the integrand contains a function together with its derivative, perhaps up to a constant factor (Section 10.7).
  3. Classify the integrand by its form:
    • a product of a power of xx with ekx,e^{kx}\mathclose{\text{,}} sin⁡kx\sin kx or cos⁡kx,\cos kx\mathclose{\text{,}} or with ln⁡x\ln x or an inverse trigonometric function: by parts (Section 11.1);
    • powers of trigonometric functions: identities and substitutions (Section 11.2);
    • a2−x2,\sqrt{a^2 - x^2}\mathclose{\text{,}} a2+x2\sqrt{a^2 + x^2} or x2−a2,\sqrt{x^2 - a^2}\mathclose{\text{,}} perhaps after completing the square: a trigonometric substitution (Section 11.3);
    • a rational function: long division if it is improper, then partial fractions (Section 11.4);
    • a root g(x)n:\sqrt[n]{g(x)}\mathclose{\text{:}} try u=g(x)n.u = \sqrt[n]{g(x)}\mathclose{\text{.}}
  4. Try again: combine methods (a substitution, then parts), multiply by a clever form of 1 (as for sec⁡x),\sec x\mathclose{\text{),}} or relate the integral to one you have done. If nothing works, the integrand may have no elementary antiderivative (Section 11.6): compute the integral numerically (Section 11.7).
Example 11.18Choosing a method✓ Checked

Choose a method for each integral, and evaluate it.

  • (a) ∫xx2+4 dx\displaystyle\int \frac{x}{x^2 + 4}\,dx
  • (b) ∫ex dx,\displaystyle\int e^{\sqrt x}\,dx\mathclose{\text{,}} for x>0x > 0
  • (c) ∫dxx2−4x+13\displaystyle\int \frac{dx}{x^2 - 4x + 13}
  • (d) ∫x1+x dx,\displaystyle\int \frac{\sqrt x}{1 + x}\,dx\mathclose{\text{,}} for x>0x > 0

(a) A rational function, but step 2 comes first: the numerator is half the derivative of the denominator. With u=x2+4,u = x^2 + 4\mathclose{\text{,}} du=2x dx:du = 2x\,dx\mathclose{\text{:}}

∫xx2+4 dx=12∫duu=12ln⁡(x2+4)+C.\begin{aligned} \int \frac{x}{x^2 + 4}\,dx &= \frac12\int \frac{du}{u} \\ &= \frac12\ln\big(x^2 + 4\big) + C. \end{aligned}

(b) A root: let w=x,w = \sqrt x\mathclose{\text{,}} so that x=w2x = w^2 and dx=2w dwdx = 2w\,dw (Theorem 11.5(b), with the one-to-one substitution x=w2,x = w^2\mathclose{\text{,}} w>0).w > 0\mathclose{\text{).}} The integral becomes 2∫wew dw,2\int we^w\,dw\mathclose{\text{,}} a product for parts: with u=wu = w and dv=ew dw,dv = e^w\,dw\mathclose{\text{,}}

2∫wew dw=2(wew−ew)+C=2(x−1)ex+C.\begin{aligned} 2\int we^w\,dw &= 2\big(we^w - e^w\big) + C \\ &= 2\big(\sqrt x - 1\big)e^{\sqrt x} + C. \end{aligned}

(c) A rational function whose denominator has no real zeros, since (−4)2−4⋅13=−36<0.(-4)^2 - 4\cdot 13 = -36 < 0\mathclose{\text{.}} Complete the square, x2−4x+13=(x−2)2+9,x^2 - 4x + 13 = (x - 2)^2 + 9\mathclose{\text{,}} and use ∫duu2+a2=1aarctan⁡ua+C\int \frac{du}{u^2 + a^2} = \frac1a\arctan\frac{u}{a} + C (Example 10.11) with u=x−2u = x - 2 and a=3:a = 3\mathclose{\text{:}}

∫dxx2−4x+13=13arctan⁡x−23+C.\begin{aligned} &\int \frac{dx}{x^2 - 4x + 13} \\ &\quad= \frac13\arctan\frac{x - 2}{3} + C. \end{aligned}

(d) A root again: w=x,w = \sqrt x\mathclose{\text{,}} dx=2w dw,dx = 2w\,dw\mathclose{\text{,}} gives 2∫w21+w2 dw,2\int \dfrac{w^2}{1 + w^2}\,dw\mathclose{\text{,}} an improper rational function. Divide, or write w2=(1+w2)−1:w^2 = (1 + w^2) - 1\mathclose{\text{:}}

2∫w21+w2 dw=2∫(1−11+w2) dw=2w−2arctan⁡w+C=2x−2arctan⁡x+C.\begin{aligned} &2\int \frac{w^2}{1 + w^2}\,dw \\ &\quad= 2\int \Big(1 - \frac{1}{1 + w^2}\Big)\,dw \\ &\quad= 2w - 2\arctan w + C \\ &\quad= 2\sqrt x - 2\arctan\sqrt x + C. \end{aligned}
Watch out

Reaching for a heavy method when a light one works. ∫xx2+4 dx\int \dfrac{x}{x^2 + 4}\,dx needs no partial fractions, and ∫xx2+1 dx\int x\sqrt{x^2 + 1}\,dx needs no trigonometric substitution: u=x2+1u = x^2 + 1 gives 13(x2+1)3/2+C\tfrac13\big(x^2 + 1\big)^{3/2} + C in one line. Look for a substitution before anything else.

6

Integration by computer

Computer algebra systems such as SymPy integrate with the methods of this module and with algorithms that handle whole families of integrands at once. Module 10 introduced sp.integrate (Section 10.8); here it is on integrals of this module, with the lesson of Module 10 in mind: an answer that looks different is not necessarily wrong.

Compute itIntegrals of this module by computer
Python
import sympy as sp
x = sp.symbols('x')
print(sp.integrate(x**2*sp.sin(x), x))                 # Example 11.3
print(sp.integrate(sp.exp(x)*sp.sin(x), x))            # Example 11.6
print(sp.integrate((5*x - 4)/(x**2 - x - 2), x))       # Example 11.15(a)
print(sp.integrate(1/sp.sqrt(x**2 + 4), x))            # Example 11.14(a)
print(sp.integrate(sp.sec(x), x))                      # Theorem 11.4
Output
-x**2*cos(x) + 2*x*sin(x) + 2*cos(x)
exp(x)*sin(x)/2 - exp(x)*cos(x)/2
2*log(x - 2) + 3*log(x + 1)
asinh(x/2)
-log(sin(x) - 1)/2 + log(sin(x) + 1)/2

The first two are the answers of Examples 11.3 and 11.6, in SymPy’s order of terms. The third writes ln⁡(x−2)\ln(x - 2) for ln⁡∣x−2∣,\ln\abs{x - 2}\mathclose{\text{,}} as Module 10 explained: SymPy’s log works with complex numbers, and its answer is right where x>2.x > 2\mathclose{\text{.}} The fourth is arsinh⁡x2=ln⁡(x2+x24+1)=ln⁡(x+x2+4)−ln⁡2,\operatorname{arsinh}\dfrac{x}{2} = \ln\Big(\dfrac{x}{2} + \sqrt{\dfrac{x^2}{4} + 1}\Big) = \ln\big(x + \sqrt{x^2 + 4}\big) - \ln 2\mathclose{\text{,}} by Exercise 6.10: Example 11.14’s answer minus the constant ln⁡2.\ln 2\mathclose{\text{.}} The fifth looks nothing like ln⁡∣sec⁡x+tan⁡x∣.\ln\abs{\sec x + \tan x}\mathclose{\text{.}} Where cos⁡x≠0,\cos x \ne 0\mathclose{\text{,}} sin⁡x−1<0,\sin x - 1 < 0\mathclose{\text{,}} so SymPy’s ln⁡(sin⁡x−1)\ln(\sin x - 1) is a complex number, ln⁡(1−sin⁡x)\ln(1 - \sin x) plus the constant πi.\pi i\mathclose{\text{.}} Up to a constant, then, SymPy’s answer is

12ln⁡1+sin⁡x1−sin⁡x=12ln⁡(1+sin⁡x)2cos⁡2x=ln⁡∣sec⁡x+tan⁡x∣,\begin{aligned} \frac12\ln\frac{1 + \sin x}{1 - \sin x} &= \frac12\ln\frac{(1 + \sin x)^2}{\cos^2 x} \\ &= \ln\abs{\sec x + \tan x}, \end{aligned}

where the middle step multiplies the top and the bottom by 1+sin⁡x.1 + \sin x\mathclose{\text{.}} Two right answers, again. To check an answer, differentiate it:

Python
mine = sp.log(x + sp.sqrt(x**2 + 4))                   # Example 11.14(a)
print(sp.simplify(sp.diff(mine, x) - 1/sp.sqrt(x**2 + 4)))
print(sp.simplify(sp.diff(sp.log(sp.sec(x) + sp.tan(x)), x) - sp.sec(x)))
print(sp.N((mine - sp.asinh(x/2)).subs(x, 3)), sp.N(sp.log(2)))
Output
0
0
0.693147180559945 0.693147180559945

Both differences of derivatives are 0, and the difference between Example 11.14’s answer and SymPy’s, at x=3x = 3 or anywhere else, is ln⁡2.\ln 2\mathclose{\text{.}} Finally, an integral that defeats SymPy, the length of an arch of the sine curve in Module 12:

Python
print(sp.integrate(sp.sqrt(1 + sp.cos(x)**2), x))
Output
Integral(sqrt(cos(x)**2 + 1), x)

SymPy returns the integral unevaluated: it has found no antiderivative.

Watch out

Three things to remember about a computer’s antiderivative. (1) It leaves out “+ C+\,C” and usually the absolute value bars, and it may use complex logarithms. (2) A different-looking answer may well be right: differentiate it, or compare it with yours at a few points of one interval, where the difference must be the same constant. (3) An unevaluated Integral(...) means that SymPy found no antiderivative, not that none exists; and a correct answer can be so long that a numerical value (Section 11.7) is more useful.

Functions with no elementary antiderivative

The integral of the last Compute it box is not unusual. Most of the functions in this module’s examples were chosen because their antiderivatives can be written down; many functions that turn up in practice cannot be integrated that way.

Definition 11.2Elementary function

An elementary function is a function that can be built from constants and xx with finitely many additions, subtractions, multiplications, divisions, powers, roots, exponentials, logarithms, trigonometric and inverse trigonometric functions, and compositions of these.

Every function of Module 1’s catalogue is elementary, and so are combinations such as e−x2,e^{-x^2}\mathclose{\text{,}} 1+cos⁡2x,\sqrt{1 + \cos^2 x}\mathclose{\text{,}} sinh⁡x=12(ex−e−x)\sinh x = \tfrac12\big(e^x - e^{-x}\big) and ln⁡(x+x2+1).\ln\big(x + \sqrt{x^2 + 1}\big)\mathclose{\text{.}} The derivative of an elementary function is elementary: the rules of Modules 4 to 6 produce it. The antiderivative of an elementary function need not be. Liouville’s theorem describes what an elementary antiderivative must look like, if there is one; from it one can prove that none of

e−x2,sin⁡xx,1ln⁡x,exx,sin⁡(x2)e^{-x^2}, \quad \frac{\sin x}{x}, \quad \frac{1}{\ln x}, \quad \frac{e^x}{x}, \quad \sin\big(x^2\big)

has an elementary antiderivative; nor has ex2,e^{x^2}\mathclose{\text{,}} which Example 11.2 met. This series proves neither Liouville’s theorem nor these consequences of it: the proofs need algebra beyond the series. What they mean is not beyond it: no cleverness with the methods of this module will find such an antiderivative, because none exists.

These functions do have antiderivatives, all the same. Each is continuous on every interval inside its domain, so by Part 1 of the Fundamental Theorem (Section 10.4) an area function ∫axf(t) dt,\int_a^x f(t)\,dt\mathclose{\text{,}} with aa in such an interval, is an antiderivative there. The most useful of them have names, and their values are computed numerically, in the same way as calculators compute sin⁡x\sin x and ln⁡x.\ln x\mathclose{\text{.}}

Definition 11.3Three functions defined by integrals
  • The error function is erf⁡x=2π∫0xe−t2 dt,\operatorname{erf} x = \dfrac{2}{\sqrt\pi}\displaystyle\int_0^x e^{-t^2}\,dt\mathclose{\text{,}} for every real xx (Module 10).
  • The sine integral is Si⁡x=∫0xsin⁡tt dt,\operatorname{Si} x = \displaystyle\int_0^x \frac{\sin t}{t}\,dt\mathclose{\text{,}} for every real x,x\mathclose{\text{,}} where the integrand is given the value 1 at t=0,t = 0\mathclose{\text{,}} its limit there (Module 2), so that it is continuous.
  • The logarithmic integral is Li⁡x=∫2xdtln⁡t,\operatorname{Li} x = \displaystyle\int_2^x \frac{dt}{\ln t}\mathclose{\text{,}} for x>1.x > 1\mathclose{\text{.}}

By Part 1 of the Fundamental Theorem, (erf⁡x)′=2πe−x2,(\operatorname{erf} x)' = \dfrac{2}{\sqrt\pi}e^{-x^2}\mathclose{\text{,}} (Si⁡x)′=sin⁡xx(\operatorname{Si} x)' = \dfrac{\sin x}{x} for x≠0,x \ne 0\mathclose{\text{,}} and (Li⁡x)′=1ln⁡x.(\operatorname{Li} x)' = \dfrac{1}{\ln x}\mathclose{\text{.}} Figure 11.3 shows the three, and here are a few values of the first two:

xxerf⁡x\operatorname{erf} xSi⁡x\operatorname{Si} x
0.50.50.5205000.5205000.4931070.493107
110.8427010.8427010.9460830.946083
220.9953220.9953221.605411.60541
330.9999780.9999781.848651.84865

The error function is the workhorse of probability, where e−x2e^{-x^2} is the shape of the normal distribution (Module 12). The sine integral turns up in signal processing and optics. The logarithmic integral counts primes: the number of prime numbers up to xx is close to Li⁡x\operatorname{Li} x when xx is large, in the sense that their ratio tends to 1 as x→∞.x \to \infty\mathclose{\text{.}} That is the prime number theorem, and the Compute it box below compares the two at a million.

Three integrands with no elementary antiderivative (blue) and the antiderivatives defined by their integrals (orange). Left: e^{-x^2} and int0^x e^{-t^2},dt = tfrac{sqrtpi}{2}operatorname{erf} x, which levels off at tfrac{sqrtpi}{2} approx 0.886. Middle: dfrac{sin x}{x} and operatorname{Si} x, which rises while the integrand is positive and falls while it is negative, and settles towards tfrac{pi}{2} approx 1.571. Right: dfrac{1}{ln x} and operatorname{Li} x, for x ge 2; operatorname{Li} x keeps growing, because dfrac{1}{ln x} stays positive.
Figure 11.3

Three integrands with no elementary antiderivative (blue) and the antiderivatives defined by their integrals (orange). Left: e−x2e^{-x^2} and ∫0xe−t2 dt=π2erf⁡x,\int_0^x e^{-t^2}\,dt = \tfrac{\sqrt\pi}{2}\operatorname{erf} x\mathclose{\text{,}} which levels off at π2≈0.886.\tfrac{\sqrt\pi}{2} \approx 0.886\mathclose{\text{.}} Middle: sin⁡xx\dfrac{\sin x}{x} and Si⁡x,\operatorname{Si} x\mathclose{\text{,}} which rises while the integrand is positive and falls while it is negative, and settles towards π2≈1.571.\tfrac{\pi}{2} \approx 1.571\mathclose{\text{.}} Right: 1ln⁡x\dfrac{1}{\ln x} and Li⁡x,\operatorname{Li} x\mathclose{\text{,}} for x≥2;x \ge 2\mathclose{\text{;}} Li⁡x\operatorname{Li} x keeps growing, because 1ln⁡x\dfrac{1}{\ln x} stays positive.

Compute itSpecial functions in SymPy

Asked for these antiderivatives, SymPy names them:

Python
import sympy as sp
x = sp.symbols('x')
for f in [sp.exp(-x**2), sp.sin(x)/x, 1/sp.log(x), sp.exp(x)/x]:
    print(sp.integrate(f, x))
Output
sqrt(pi)*erf(x)/2
Si(x)
li(x)
Ei(x)

Ei is the exponential integral, another named antiderivative. SymPy’s li is another antiderivative of 1ln⁡x,\dfrac{1}{\ln x}\mathclose{\text{,}} defined by an integral from 0 that needs special care at t=1,t = 1\mathclose{\text{,}} where 1ln⁡t\dfrac{1}{\ln t} is undefined; it differs from Li⁡\operatorname{Li} by the constant li⁡2.\operatorname{li} 2\mathclose{\text{.}} The prime numbers up to a million, counted by primepi, against Li⁡\operatorname{Li} of a million:

Python
print(sp.N(sp.li(2)))
print(sp.primepi(10**6), sp.N(sp.Li(10**6)))
print(sp.Integral(sp.exp(-x**2), (x, 0, 1)).evalf())
Output
1.04516378011749
78498 78626.5039956821
0.746824132812427

There are 78,498 primes below a million, and Li⁡106≈78,627:\operatorname{Li} 10^6 \approx 78{,}627\mathclose{\text{:}} a difference of less than 0.2%. The last line is ∫01e−x2 dx,\int_0^1 e^{-x^2}\,dx\mathclose{\text{,}} which evalf computes numerically, the value that Module 9 estimated with midpoint sums.

Watch out

“No elementary antiderivative” does not mean “no antiderivative”, and it does not stop you from evaluating definite integrals: ∫01e−x2 dx≈0.746824\int_0^1 e^{-x^2}\,dx \approx 0.746824 is a perfectly good number. And small changes matter. ∫xe−x2 dx=−12e−x2+C\int xe^{-x^2}\,dx = -\tfrac12e^{-x^2} + C and ∫xsin⁡(x2) dx=−12cos⁡(x2)+C,\int x\sin\big(x^2\big)\,dx = -\tfrac12\cos\big(x^2\big) + C\mathclose{\text{,}} by substitution; without the factor x,x\mathclose{\text{,}} neither has an elementary antiderivative.

7

Numerical integration

Two kinds of integral call for numbers rather than formulas: integrals of functions with no elementary antiderivative, such as ∫01e−x2 dx,\int_0^1 e^{-x^2}\,dx\mathclose{\text{,}} and integrals of functions known only through measurements, such as a speed or a power read every few seconds. A numerical integration rule computes an integral from values of the integrand. The midpoint sum of Module 9 is one, the midpoint rule

Mn=Δx [f(xˉ1)+f(xˉ2)+⋯+f(xˉn)],M_n = \Delta x\,\big[f(\bar x_1) + f(\bar x_2) + \dots + f(\bar x_n)\big],

where Δx=b−an,\Delta x = \tfrac{b - a}{n}\mathclose{\text{,}} xi=a+i Δx,x_i = a + i\,\Delta x\mathclose{\text{,}} and xˉi=12(xi−1+xi)\bar x_i = \tfrac12(x_{i-1} + x_i) is the midpoint of the iith subinterval (read “x bar i”; Module 9 wrote mi).m_i\mathclose{\text{).}} Its error shrank like 1n2\tfrac{1}{n^2} (Section 9.3). This section adds two rules, explains why the errors behave as they do, and bounds them.

The trapezoidal rule

In Example 9.2 a car’s speed was read every 2 seconds. The left and right sums gave 100 m and 140 m, and their average, 120 m, was a better single estimate. Averaging LnL_n and RnR_n term by term gives

Ln+Rn2=∑i=1nf(xi−1)+f(xi)2 Δx,\frac{L_n + R_n}{2} = \sum_{i=1}^{n} \frac{f(x_{i-1}) + f(x_i)}{2}\,\Delta x,

and each term is the area of a trapezoid: when ff is positive, the region under the chord that joins the points (xi−1,f(xi−1))(x_{i-1}, f(x_{i-1})) and (xi,f(xi))(x_i, f(x_i)) of the graph (Figure 11.4, left). Every value of ff except the first and the last belongs to two neighbouring trapezoids, so collecting terms gives the following rule.

Definition 11.4The trapezoidal rule

Let ff be defined on [a,b],[a, b]\mathclose{\text{,}} let n≥1n \ge 1 be a whole number, Δx=b−an\Delta x = \tfrac{b - a}{n} and xi=a+i Δx.x_i = a + i\,\Delta x\mathclose{\text{.}} The trapezoidal rule with nn subintervals is

Tn=Δx2[f(x0)+2f(x1)+2f(x2)+…+2f(xn−1)+f(xn)].\begin{aligned} T_n = \frac{\Delta x}{2}\big[&f(x_0) + 2f(x_1) \\ &+ 2f(x_2) + \dots \\ &+ 2f(x_{n-1}) + f(x_n)\big]. \end{aligned}

It is the average 12(Ln+Rn)\tfrac12(L_n + R_n) of the left and right sums.

The error of a rule is the integral minus the approximation: ET=∫abf(x) dx−TnE_T = \int_a^b f(x)\,dx - T_n and EM=∫abf(x) dx−Mn.E_M = \int_a^b f(x)\,dx - M_n\mathclose{\text{.}} A positive error means that the rule underestimates.

Example 11.19The trapezoidal and midpoint rules for ln 2✓ Checked

Compute T4T_4 for ∫12dxx=ln⁡2,\displaystyle\int_1^2 \frac{dx}{x} = \ln 2\mathclose{\text{,}} and compare the errors of T4T_4 and M4.M_4\mathclose{\text{.}}

Here Δx=0.25,\Delta x = 0.25\mathclose{\text{,}} and 1x\dfrac1x takes the values 1,1\mathclose{\text{,}} 45,\tfrac45\mathclose{\text{,}} 23,\tfrac23\mathclose{\text{,}} 47\tfrac47 and 12\tfrac12 at x=1,x = 1\mathclose{\text{,}} 1.25, 1.5, 1.75 and 2 (Example 9.4). So

T4=0.252[1+2⋅45+2⋅23+2⋅47+12]=11711680≈0.69702,\begin{aligned} T_4 &= \frac{0.25}{2}\Big[1 + 2\cdot\frac45 + 2\cdot\frac23 \\ &\qquad + 2\cdot\frac47 + \frac12\Big] \\ &= \frac{1171}{1680} \approx 0.69702, \end{aligned}

which is the average of L4=319420L_4 = \tfrac{319}{420} and R4=533840R_4 = \tfrac{533}{840} from Example 9.4. That example also found M4≈0.6912,M_4 \approx 0.6912\mathclose{\text{,}} or 0.691220.69122 to five decimal places. With ln⁡2≈0.693147,\ln 2 \approx 0.693147\mathclose{\text{,}}

ET=ln⁡2−T4≈−0.00388,EM=ln⁡2−M4≈0.00193.\begin{aligned} E_T &= \ln 2 - T_4 \approx -0.00388, \\ E_M &= \ln 2 - M_4 \approx 0.00193. \end{aligned}

The trapezoidal rule overestimates, the midpoint rule underestimates, and the midpoint error is about half the size of the trapezoidal one.

Here is the same comparison for more subintervals:

nnETE_TEME_M
44−0.0038766-0.00387660.00192730.0019273
88−0.0009747-0.00097470.00048660.0004866
1616−0.0002440-0.00024400.00012200.0001220
3232−0.0000610-0.00006100.00003050.0000305

Two patterns stand out. Each time nn doubles, both errors are divided by about 4, as Module 9 found for midpoint sums. And at every n,n\mathclose{\text{,}} ET≈−2EM.E_T \approx -2E_M\mathclose{\text{.}}

The signs come from the shape of the graph. The second derivative of 1x\tfrac1x is 2x3,\tfrac{2}{x^3}\mathclose{\text{,}} positive for every x>0,x > 0\mathclose{\text{,}} so the graph is concave up on (0,∞),(0, \infty)\mathclose{\text{,}} an open interval that contains [1,2][1, 2] (Section 8.4). It sags below each chord, and each trapezoid covers more than the region under the graph. So TnT_n overestimates (Figure 11.4, left). For the midpoint rule, draw the tangent line at the midpoint of a subinterval. It passes through the middle of the top of the midpoint rectangle and cuts off two triangles of equal area, one above the top on one side and one below it on the other. So the rectangle has the same area as the trapezoid under the tangent line (Figure 11.4, right). A concave-up graph lies above its tangent lines (Theorem 8.11), so that trapezoid lies below the graph, and MnM_n underestimates. For a graph that is concave down, both conclusions turn round, as Module 9 saw in Exercise 9.2, where M4M_4 overestimated ∫02(4−x2) dx.\int_0^2 (4 - x^2)\,dx\mathclose{\text{.}}

One subinterval of the two rules for int1^2 frac{dx}{x}, with n = 1 so that the errors are visible. Left: the trapezoid under the chord has area 0.75, more than the area ln 2 approx 0.693 under the graph: the graph, concave up, sags below the chord, and the orange sliver is the excess. Right: the midpoint rectangle (dashed) has area tfrac23 approx 0.667, the same as the trapezoid under the tangent line at the midpoint, because the two small triangles between them are equal; the graph lies above the tangent, so the rectangle is too small by the green sliver.
Figure 11.4

One subinterval of the two rules for ∫12dxx,\int_1^2 \frac{dx}{x}\mathclose{\text{,}} with n=1n = 1 so that the errors are visible. Left: the trapezoid under the chord has area 0.75, more than the area ln⁡2≈0.693\ln 2 \approx 0.693 under the graph: the graph, concave up, sags below the chord, and the orange sliver is the excess. Right: the midpoint rectangle (dashed) has area 23≈0.667,\tfrac23 \approx 0.667\mathclose{\text{,}} the same as the trapezoid under the tangent line at the midpoint, because the two small triangles between them are equal; the graph lies above the tangent, so the rectangle is too small by the green sliver.

Error bounds

Theorem 11.8Error bounds for the midpoint and trapezoidal rules

Let f′′f'' be continuous on [a,b],[a, b]\mathclose{\text{,}} and let KK be a number with ∣f′′(x)∣≤K\abs{f''(x)} \le K for every xx in [a,b].[a, b]\mathclose{\text{.}} Then, for every n≥1,n \ge 1\mathclose{\text{,}}

∣ET∣≤K(b−a)312n2and∣EM∣≤K(b−a)324n2.\begin{aligned} \abs{E_T} &\le \frac{K(b - a)^3}{12n^2} \quad\text{and} \\ \abs{E_M} &\le \frac{K(b - a)^3}{24n^2}. \end{aligned}

If f′′(x)≥0f''(x) \ge 0 for every xx in [a,b],[a, b]\mathclose{\text{,}} then Mn≤∫abf(x) dx≤Tn;M_n \le \int_a^b f(x)\,dx \le T_n\mathclose{\text{;}} if f′′(x)≤0f''(x) \le 0 for every xx in [a,b],[a, b]\mathclose{\text{,}} then Tn≤∫abf(x) dx≤Mn.T_n \le \int_a^b f(x)\,dx \le M_n\mathclose{\text{.}}

Such a KK exists: ∣f′′∣\abs{f''} is continuous on the closed interval [a,b],[a, b]\mathclose{\text{,}} so it has a largest value there, by the Extreme Value Theorem (Module 3). The bounds shrink like 1n2,\tfrac{1}{n^2}\mathclose{\text{,}} and the bound for MnM_n is half the bound for Tn.T_n\mathclose{\text{.}} A bound only limits the size of an error, but the errors themselves usually follow the same pattern: the Going deeper box shows why doubling nn divides them by about 4, and why ET≈−2EM.E_T \approx -2E_M\mathclose{\text{.}} It also proves the trapezoidal half of the theorem; Exercise 11.12 proves the midpoint half in the same way.

Going deeperWhy the theorem is true, and the factors 4 and −2

Take one subinterval [p,q],[p, q]\mathclose{\text{,}} of width w=q−p,w = q - p\mathclose{\text{,}} and the function k(x)=12(x−p)(q−x).k(x) = \tfrac12(x - p)(q - x)\mathclose{\text{.}} It is at least 0 on [p,q][p, q] and 0 at both ends; k′(x)=p+q2−x,k'(x) = \tfrac{p + q}{2} - x\mathclose{\text{,}} so k′(p)=w2k'(p) = \tfrac{w}{2} and k′(q)=−w2;k'(q) = -\tfrac{w}{2}\mathclose{\text{;}} and k′′(x)=−1.k''(x) = -1\mathclose{\text{.}} Integrate ∫pqkf′′ dx\int_p^q k f''\,dx by parts twice (Theorem 11.2), first with u=ku = k and dv=f′′(x) dx,dv = f''(x)\,dx\mathclose{\text{,}} then with u=k′u = k' and dv=f′(x) dx:dv = f'(x)\,dx\mathclose{\text{:}}

∫pqkf′′ dx=[kf′]pq−∫pqk′f′ dx=0−[k′f]pq+∫pqk′′f dx=w2(f(p)+f(q))−∫pqf dx.\begin{aligned} &\int_p^q k f''\,dx \\ &\quad= \big[kf'\big]_p^q - \int_p^q k'f'\,dx \\ &\quad= 0 - \big[k'f\big]_p^q + \int_p^q k''f\,dx \\ &\quad= \frac{w}{2}\big(f(p) + f(q)\big) - \int_p^q f\,dx. \end{aligned}

So the error of a single trapezoid is

∫pqf(x) dx−w2(f(p)+f(q))=−∫pqk(x) f′′(x) dx.\begin{aligned} &\int_p^q f(x)\,dx - \frac{w}{2}\big(f(p) + f(q)\big) \\ &\quad= -\int_p^q k(x)\,f''(x)\,dx. \end{aligned}

The bound. Since k≥0k \ge 0 and −K≤f′′≤K,-K \le f'' \le K\mathclose{\text{,}} the comparison theorem (Theorem 9.7) puts the right side between −K∫pqk dx-K\int_p^q k\,dx and K∫pqk dx,K\int_p^q k\,dx\mathclose{\text{,}} and ∫pqk(x) dx=w312.\int_p^q k(x)\,dx = \tfrac{w^3}{12}\mathclose{\text{.}} So each trapezoid is in error by at most Kw312.\tfrac{Kw^3}{12}\mathclose{\text{.}} There are nn trapezoids, each of width w=b−an,w = \tfrac{b - a}{n}\mathclose{\text{,}} so

∣ET∣≤n⋅K12(b−an)3=K(b−a)312n2.\begin{aligned} \abs{E_T} &\le n\cdot\frac{K}{12}\Big(\frac{b - a}{n}\Big)^3 \\ &= \frac{K(b - a)^3}{12n^2}. \end{aligned}

The sign. If f′′≥0,f'' \ge 0\mathclose{\text{,}} each −∫pqkf′′ dx-\int_p^q kf''\,dx is at most 0, so ET≤0:E_T \le 0\mathclose{\text{:}} TnT_n overestimates.

The factors 4 and −2.-2\mathclose{\text{.}} If f′′f'' hardly changes across [p,q],[p, q]\mathclose{\text{,}} the error of one trapezoid is close to −f′′(p)∫pqk dx=−f′′(p)w312.-f''(p)\int_p^q k\,dx = -f''(p)\tfrac{w^3}{12}\mathclose{\text{.}} Adding up over the subintervals, with w=Δx,w = \Delta x\mathclose{\text{,}}

ET≈−Δx212∑i=1nf′′(xi−1) Δx≈−Δx212∫abf′′(x) dx=−Δx212(f′(b)−f′(a)),\begin{aligned} E_T &\approx -\frac{\Delta x^2}{12}\sum_{i=1}^{n} f''(x_{i-1})\,\Delta x \\ &\approx -\frac{\Delta x^2}{12}\int_a^b f''(x)\,dx \\ &= -\frac{\Delta x^2}{12}\big(f'(b) - f'(a)\big), \end{aligned}

because the sum is a Riemann sum of f′′.f''\mathclose{\text{.}} In the same way, the formula of Exercise 11.12(b) gives EM≈Δx224(f′(b)−f′(a)).E_M \approx \tfrac{\Delta x^2}{24}\big(f'(b) - f'(a)\big)\mathclose{\text{.}} Halving Δx\Delta x divides both by 4, and ET≈−2EM.E_T \approx -2E_M\mathclose{\text{.}} For ln⁡2\ln 2 with n=4,n = 4\mathclose{\text{,}} f′(x)=−1x2f'(x) = -\tfrac{1}{x^2} gives f′(2)−f′(1)=34,f'(2) - f'(1) = \tfrac34\mathclose{\text{,}} and the two formulas predict ET≈−0.00391E_T \approx -0.00391 and EM≈0.00195,E_M \approx 0.00195\mathclose{\text{,}} close to the true −0.00388-0.00388 and 0.001930.00193 of Example 11.19.

Example 11.20How many subintervals?✓ Checked

How large must nn be for Tn,T_n\mathclose{\text{,}} and for Mn,M_n\mathclose{\text{,}} to approximate ln⁡2=∫12dxx\ln 2 = \int_1^2 \frac{dx}{x} with an error of at most 10−6?10^{-6}\mathclose{\text{?}}

f(x)=1xf(x) = \tfrac1x has f′′(x)=2x3,f''(x) = \tfrac{2}{x^3}\mathclose{\text{,}} which on [1,2][1, 2] is positive and largest at x=1,x = 1\mathclose{\text{,}} so take K=2.K = 2\mathclose{\text{.}} With b−a=1,b - a = 1\mathclose{\text{,}} Theorem 11.8 guarantees

∣ET∣≤212n2=16n2.\abs{E_T} \le \frac{2}{12n^2} = \frac{1}{6n^2}.

This is at most 10−610^{-6} when n2≥1066≈166,667.n^2 \ge \tfrac{10^6}{6} \approx 166{,}667\mathclose{\text{.}} Since 4082=166,464408^2 = 166{,}464 is too small and 4092=167,281409^2 = 167{,}281 is enough, n=409n = 409 subintervals suffice. For the midpoint rule, 112n2≤10−6\tfrac{1}{12n^2} \le 10^{-6} needs n2≥83,334,n^2 \ge 83{,}334\mathclose{\text{,}} and n=289n = 289 suffices (2882=82,944,288^2 = 82{,}944\mathclose{\text{,}} 2892=83,521).289^2 = 83{,}521\mathclose{\text{).}} These values of nn are guaranteed to be enough; they may be more than necessary, because over most of [1,2][1, 2] the second derivative is much smaller than K.K\mathclose{\text{.}}

Watch out

KK must bound ∣f′′∣\abs{f''} on the whole interval: take its largest value, not its value at a convenient point. With K=f′′(2)=14K = f''(2) = \tfrac14 for 1x\tfrac1x on [1,2],[1, 2]\mathclose{\text{,}} the “bound” for T4T_4 would be 1768≈0.0013,\tfrac{1}{768} \approx 0.0013\mathclose{\text{,}} less than the actual error, 0.0039. And a bound is a guarantee, not an estimate: the true error may be much smaller.

Simpson’s rule

The trapezoidal rule replaces the graph by chords, straight lines through two points. A parabola through three points can follow a curve much more closely, and the area under one is easy to find. Let y=Ax2+Bx+Cy = Ax^2 + Bx + C pass through the points (−h,y0),(-h, y_0)\mathclose{\text{,}} (0,y1)(0, y_1) and (h,y2),(h, y_2)\mathclose{\text{,}} where h>0.h > 0\mathclose{\text{.}} Then, since the odd term BxBx contributes 0,

∫−hh(Ax2+Bx+C) dx=23Ah3+2Ch=h3(2Ah2+6C).\begin{aligned} \int_{-h}^{h} \big(Ax^2 + Bx + C\big)\,dx &= \frac23Ah^3 + 2Ch \\ &= \frac{h}{3}\big(2Ah^2 + 6C\big). \end{aligned}

The three points give y0=Ah2−Bh+C,y_0 = Ah^2 - Bh + C\mathclose{\text{,}} y1=Cy_1 = C and y2=Ah2+Bh+C,y_2 = Ah^2 + Bh + C\mathclose{\text{,}} so y0+4y1+y2=2Ah2+6C,y_0 + 4y_1 + y_2 = 2Ah^2 + 6C\mathclose{\text{,}} and the area is

h3(y0+4y1+y2).\frac{h}{3}\big(y_0 + 4y_1 + y_2\big).

Such a parabola always exists: C=y1,C = y_1\mathclose{\text{,}} B=y2−y02hB = \tfrac{y_2 - y_0}{2h} and A=y0−2y1+y22h2A = \tfrac{y_0 - 2y_1 + y_2}{2h^2} (a straight line if A=0).A = 0\mathclose{\text{).}} The area depends only on the three heights and the spacing h,h\mathclose{\text{,}} so it is the same for any three equally spaced points, wherever they are on the xx-axis: sliding the picture sideways does not change it. Now cut [a,b][a, b] into an even number nn of subintervals, pass a parabola through the points of the graph above x0,x_0\mathclose{\text{,}} x1x_1 and x2,x_2\mathclose{\text{,}} another through those above x2,x_2\mathclose{\text{,}} x3x_3 and x4,x_4\mathclose{\text{,}} and so on, and add up the areas under them (Figure 11.5, left).

Definition 11.5Simpson’s rule

Let nn be even, Δx=b−an\Delta x = \tfrac{b - a}{n} and xi=a+i Δx.x_i = a + i\,\Delta x\mathclose{\text{.}} Simpson’s rule with nn subintervals is

Sn=Δx3[f(x0)+4f(x1)+2f(x2)+4f(x3)+⋯+2f(xn−2)+4f(xn−1)+f(xn)].\begin{aligned} S_n = \frac{\Delta x}{3}\big[&f(x_0) + 4f(x_1) + 2f(x_2) \\ &+ 4f(x_3) + \dots + 2f(x_{n-2}) \\ &+ 4f(x_{n-1}) + f(x_n)\big]. \end{aligned}

The coefficients follow the pattern 1,4,2,4,2,…,4,1:1, 4, 2, 4, 2, \dots, 4, 1\mathclose{\text{:}} each point with an odd index is the middle of a pair of subintervals, with weight 4, and each interior point with an even index is shared by two pairs, with weight 1+1=2.1 + 1 = 2\mathclose{\text{.}} The error is ES=∫abf(x) dx−Sn.E_S = \int_a^b f(x)\,dx - S_n\mathclose{\text{.}}

Example 11.21Simpson’s rule for ln 2✓ Checked

Compute S4S_4 for ∫12dxx.\displaystyle\int_1^2 \frac{dx}{x}\mathclose{\text{.}}

With Δx=0.25\Delta x = 0.25 and the values of 1x\tfrac1x used in Example 11.19,

S4=0.253[1+4⋅45+2⋅23+4⋅47+12]=17472520≈0.693254.\begin{aligned} S_4 &= \frac{0.25}{3}\Big[1 + 4\cdot\frac45 + 2\cdot\frac23 \\ &\qquad + 4\cdot\frac47 + \frac12\Big] \\ &= \frac{1747}{2520} \approx 0.693254. \end{aligned}

Its error is ES=ln⁡2−S4≈−0.000107,E_S = \ln 2 - S_4 \approx -0.000107\mathclose{\text{,}} about 36 times smaller than the error of T4,T_4\mathclose{\text{,}} from the same five values of f.f\mathclose{\text{.}}

Simpson’s rule is in fact a weighted average of the other two. The points of S2nS_{2n} are those of TnT_n together with the midpoints used by Mn,M_n\mathclose{\text{,}} and grouping the terms shows that

S2n=Tn+2Mn3.S_{2n} = \frac{T_n + 2M_n}{3}.

Here, with T2=1724T_2 = \tfrac{17}{24} and M2=2435,M_2 = \tfrac{24}{35}\mathclose{\text{,}} 13(1724+4835)=17472520=S4.\tfrac13\big(\tfrac{17}{24} + \tfrac{48}{35}\big) = \tfrac{1747}{2520} = S_4\mathclose{\text{.}} Since ET≈−2EM,E_T \approx -2E_M\mathclose{\text{,}} the weights 1 and 2 make the two errors nearly cancel.

A rule built to be exact for parabolas turns out to be exact for more.

Theorem 11.9Simpson’s rule is exact for cubics

If ff is a polynomial of degree at most 3, then Sn=∫abf(x) dxS_n = \int_a^b f(x)\,dx for every even n.n\mathclose{\text{.}}

Proof

SnS_n adds up the rule over pairs of subintervals, and the integral adds up over them too, so it is enough to show that the rule is exact on one pair, [m−h,m+h].[m - h, m + h]\mathclose{\text{.}} Substituting x=m+sx = m + s and expanding the powers (m+s)k(m + s)^k writes ff as c0+c1(x−m)+c2(x−m)2+c3(x−m)3,c_0 + c_1(x - m) + c_2(x - m)^2 + c_3(x - m)^3\mathclose{\text{,}} with constants cj.c_j\mathclose{\text{.}} The part c0+c1(x−m)+c2(x−m)2c_0 + c_1(x - m) + c_2(x - m)^2 is a parabola or a line, so the rule gives its integral exactly, by construction. For (x−m)3,(x - m)^3\mathclose{\text{,}} the integral over [m−h,m+h][m - h, m + h] is 0, because the function is odd about m;m\mathclose{\text{;}} and the rule gives h3((−h)3+4⋅0+h3)=0\tfrac{h}{3}\big((-h)^3 + 4\cdot 0 + h^3\big) = 0 too. Both the integral and the rule are linear (the value for a sum of functions is the sum of the values, and constant factors come out), so the rule is exact for f.f\mathclose{\text{.}}

∎

The error bound for Simpson’s rule involves the fourth derivative f(4).f^{(4)}\mathclose{\text{.}}

Theorem 11.10Error bound for Simpson’s rule

Let f(4)f^{(4)} be continuous on [a,b],[a, b]\mathclose{\text{,}} and let KK be a number with ∣f(4)(x)∣≤K\abs{f^{(4)}(x)} \le K for every xx in [a,b].[a, b]\mathclose{\text{.}} Then, for every even n,n\mathclose{\text{,}}

∣ES∣≤K(b−a)5180n4.\abs{E_S} \le \frac{K(b - a)^5}{180n^4}.

The proof uses the idea of the Going deeper box with a longer calculation, and this series omits it. The bound agrees with Theorem 11.9: for a cubic, f(4)=0,f^{(4)} = 0\mathclose{\text{,}} so K=0K = 0 and the error is 0. It shrinks like 1n4:\tfrac{1}{n^4}\mathclose{\text{:}} doubling nn divides it by 24=16,2^4 = 16\mathclose{\text{,}} and for a smooth ff the error itself usually falls by about the same factor, as the Compute it box below shows. For ln⁡2,\ln 2\mathclose{\text{,}} f(4)(x)=24x5≤24f^{(4)}(x) = \tfrac{24}{x^5} \le 24 on [1,2],[1, 2]\mathclose{\text{,}} and 24180n4≤10−6\tfrac{24}{180n^4} \le 10^{-6} needs n4≥133,334,n^4 \ge 133{,}334\mathclose{\text{,}} that is, n≥19.11.n \ge 19.11\mathclose{\text{.}} With nn even, n=20n = 20 suffices: twenty subintervals, where the trapezoidal rule needed 409.

Compute itThe three rules side by side

Each rule is a few lines of Python. The test integral ∫01e−x2 dx\int_0^1 e^{-x^2}\,dx has no elementary antiderivative, but Python’s math.erf gives its value, π2erf⁡1,\tfrac{\sqrt\pi}{2}\operatorname{erf} 1\mathclose{\text{,}} to about 16 significant digits:

Python
import math

def midpoint(f, a, b, n):
    dx = (b - a)/n
    return dx*sum(f(a + (i + 0.5)*dx) for i in range(n))

def trapezoid(f, a, b, n):
    dx = (b - a)/n
    return dx*(f(a)/2 + sum(f(a + i*dx) for i in range(1, n)) + f(b)/2)

def simpson(f, a, b, n):                    # n must be even
    dx = (b - a)/n
    inner = sum((4 if i % 2 else 2)*f(a + i*dx) for i in range(1, n))
    return dx/3*(f(a) + inner + f(b))

Now the errors as nn doubles, and the ratio of each error to the next:

Python
f = lambda x: math.exp(-x**2)
exact = math.sqrt(math.pi)/2*math.erf(1)        # the integral from 0 to 1
ns = [4, 8, 16, 32, 64]
rules = {'M': midpoint, 'T': trapezoid, 'S': simpson}
err = {r: [exact - rule(f, 0, 1, n) for n in ns] for r, rule in rules.items()}
print('  n        E_M        E_T        E_S')
for k, n in enumerate(ns):
    print(f'{n:3d}' + ''.join(f'{err[r][k]:11.2e}' for r in rules))
for r in rules:
    print(r, [round(err[r][k - 1]/err[r][k], 2) for k in range(1, len(ns))])
Output
  n        E_M        E_T        E_S
  4  -1.92e-03   3.84e-03  -3.12e-05
  8  -4.79e-04   9.59e-04  -1.99e-06
 16  -1.20e-04   2.40e-04  -1.25e-07
 32  -2.99e-05   5.99e-05  -7.79e-09
 64  -7.48e-06   1.50e-05  -4.87e-10
M [4.01, 4.0, 4.0, 4.0]
T [4.01, 4.0, 4.0, 4.0]
S [15.72, 15.95, 15.99, 16.0]

The midpoint and trapezoidal errors fall by a factor of 4 at each doubling, and Simpson’s by a factor close to 16, as their bounds in Theorems 11.8 and 11.10 do. With 16 subintervals Simpson’s rule is already within 2×10−72 \times 10^{-7} of the integral, closer than the trapezoidal rule with 64. The midpoint rule overestimates here, because the graph of e−x2e^{-x^2} is concave down on (−12,12),\big(-\tfrac{1}{\sqrt2}, \tfrac{1}{\sqrt2}\big)\mathclose{\text{,}} an interval that covers most of [0,1][0, 1] (more precisely, because f′(1)−f′(0)=−2ef'(1) - f'(0) = -\tfrac{2}{e} is negative, in the estimate of the Going deeper box); and ET≈−2EME_T \approx -2E_M once more.

Simpson's rule. Left: with n = 4, two parabolas (purple, dashed), each through three points of the graph of f(x) = 1 + tfrac12sin 2x + tfrac{x}{4} (blue), replace the graph on [0, 4]; the shaded areas under them add up to S4. Right: the size of the errors of the three rules for int0^1 e^{-x^2},dx against n, on logarithmic scales, on which a power C/n^p is a straight line of slope -p. The midpoint and trapezoidal errors fall along lines of slope -2, the errors of Simpson's rule along a line of slope -4.
Figure 11.5

Simpson’s rule. Left: with n=4,n = 4\mathclose{\text{,}} two parabolas (purple, dashed), each through three points of the graph of f(x)=1+12sin⁡2x+x4f(x) = 1 + \tfrac12\sin 2x + \tfrac{x}{4} (blue), replace the graph on [0,4];[0, 4]\mathclose{\text{;}} the shaded areas under them add up to S4.S_4\mathclose{\text{.}} Right: the size of the errors of the three rules for ∫01e−x2 dx\int_0^1 e^{-x^2}\,dx against n,n\mathclose{\text{,}} on logarithmic scales, on which a power C/npC/n^p is a straight line of slope −p.-p\mathclose{\text{.}} The midpoint and trapezoidal errors fall along lines of slope −2,-2\mathclose{\text{,}} the errors of Simpson’s rule along a line of slope −4.-4\mathclose{\text{.}}

Try it

Choose exe^x on [0,1],[0, 1]\mathclose{\text{,}} the trapezoid rule and n=4:n = 4\mathclose{\text{:}} the shaded trapezoids hug the curve, and T4≈1.72722T_4 \approx 1.72722 is a little more than the integral e−1≈1.71828.e - 1 \approx 1.71828\mathclose{\text{.}} Press Double n three times. The table keeps the error at each nn and the ratio of each error to the next: close to 4 every time. Switch to the midpoint rule, move nn back to 4 and do the same: at each nn the error is about half the trapezoidal one, with the opposite sign, and the ratios are again close to 4. Then do the same with Simpson’s rule: the purple curves are the parabolas, and the ratios are close to 16. Two experiments to finish. Choose type your own, keep x3−xx^3 - x on [0,2][0, 2] and choose Simpson’s rule: the error is 0, to within rounding error, for every even nn (Theorem 11.9). And choose x\sqrt x on [0,1][0, 1] with Simpson’s rule, and double nn again: the ratios are only about 2.8, because the derivatives of x\sqrt x are unbounded near 0, and Theorem 11.10 does not apply.

Which rule to use

  • A smooth function given by a formula. Simpson’s rule, or a library routine. Doubling nn is a practical check: for Simpson’s rule the error of S2nS_{2n} is about 115(S2n−Sn),\tfrac{1}{15}(S_{2n} - S_n)\mathclose{\text{,}} since S2n−Sn=ES(n)−ES(2n)≈16ES(2n)−ES(2n).S_{2n} - S_n = E_S(n) - E_S(2n) \approx 16E_S(2n) - E_S(2n)\mathclose{\text{.}} Library routines go further: they use adaptive rules, which keep halving the subintervals only where the integrand changes fast. The widget computes its accurate value of the integral that way, with Simpson’s rule.
  • Measurements. Readings at equally spaced times suit the trapezoidal rule, or Simpson’s rule when the number of intervals is even; the midpoint rule needs values at the midpoints, which you usually do not have. Readings at unequal spacing are added up as trapezoids, one interval at a time.
  • A kink or an infinite slope. The error bounds need a bounded f′′f'' or f(4).f^{(4)}\mathclose{\text{.}} For x\sqrt x on [0,1],[0, 1]\mathclose{\text{,}} (x)′′=−14x−3/2\big(\sqrt x\big)'' = -\tfrac14x^{-3/2} is unbounded near 0, and doubling nn divides the error of Simpson’s rule by only about 2.8, not 16. Split the interval at a kink, or remove the trouble with a substitution: x=t2x = t^2 turns ∫01x dx\int_0^1 \sqrt x\,dx into ∫012t2 dt,\int_0^1 2t^2\,dt\mathclose{\text{,}} which Simpson’s rule integrates exactly.
  • Very many subintervals. Every value of ff carries a rounding error of about 10−1610^{-16} of its size (Module 2), and adding up millions of them can add those errors up. A good rule with a moderate nn is both faster and more accurate.
Watch out

Three slips with Simpson’s rule. (1) It needs an even number of subintervals: five readings give four intervals and can be used, six readings give five intervals and cannot (use the trapezoidal rule, or Simpson’s rule on four of the intervals and a trapezoid for the last). (2) The weights are 1,4,2,4,…,2,4,1,1, 4, 2, 4, \dots, 2, 4, 1\mathclose{\text{,}} starting and ending with 1 and with 4 next to each end. (3) The factor in front is Δx3,\tfrac{\Delta x}{3}\mathclose{\text{,}} not Δx2\tfrac{\Delta x}{2} as in the trapezoidal rule.

8

What you learned

  • Integration by parts reverses the product rule: ∫u dv=uv−∫v du,\int u\,dv = uv - \int v\,du\mathclose{\text{,}} and ∫abfg′ dx=[fg]ab−∫abf′g dx\int_a^b f g'\,dx = \big[fg\big]_a^b - \int_a^b f'g\,dx for definite integrals. Choose uu to get simpler when differentiated (LIATE is a rough guide) and dvdv to be integrable. Repeat it, organise the rounds in a table, solve for an integral that comes back (∫exsin⁡x dx),\int e^x\sin x\,dx\mathclose{\text{),}} or derive a reduction formula (∫sin⁡nx dx).\int \sin^n x\,dx\mathclose{\text{).}}
  • Trigonometric integrals: for sin⁡mxcos⁡nx,\sin^m x\cos^n x\mathclose{\text{,}} save one factor of an odd power and substitute, or use the half-angle identities sin⁡2x=12(1−cos⁡2x)\sin^2 x = \tfrac12(1 - \cos 2x) and cos⁡2x=12(1+cos⁡2x);\cos^2 x = \tfrac12(1 + \cos 2x)\mathclose{\text{;}} for tan⁡mxsec⁡nx,\tan^m x\sec^n x\mathclose{\text{,}} save sec⁡2x\sec^2 x or sec⁡xtan⁡x.\sec x\tan x\mathclose{\text{.}} ∫sec⁡x dx=ln⁡∣sec⁡x+tan⁡x∣+C.\int \sec x\,dx = \ln\abs{\sec x + \tan x} + C\mathclose{\text{.}}
  • Trigonometric substitution: x=asin⁡θ,x = a\sin\theta\mathclose{\text{,}} atan⁡θa\tan\theta or asec⁡θa\sec\theta removes a2−x2,\sqrt{a^2 - x^2}\mathclose{\text{,}} a2+x2\sqrt{a^2 + x^2} or x2−a2;\sqrt{x^2 - a^2}\mathclose{\text{;}} on the ranges of θ\theta in the table the square roots need no absolute value signs (the secant row is for x≥a),x \ge a\mathclose{\text{),}} and a right triangle takes the answer back to x.x\mathclose{\text{.}} It gives the areas πr2\pi r^2 of a disc and πab\pi ab of an ellipse.
  • Partial fractions: divide first if the rational function is improper; then write it as a sum of terms A(x−r)j\dfrac{A}{(x - r)^j} and Bx+C(x2+px+q)j.\dfrac{Bx + C}{(x^2 + px + q)^j}\mathclose{\text{.}} The cover-up method finds the coefficients of distinct linear factors, because multiplying by x−rx - r and letting x→rx \to r isolates them.
  • Strategy: simplify, substitute, classify (parts, trigonometric, substitution, partial fractions, roots), try again. Check every antiderivative by differentiating it.
  • By computer: SymPy’s antiderivatives may differ from yours by a constant, drop absolute values or use complex logarithms; differentiate to check. Elementary functions need not have elementary antiderivatives: by Liouville’s theorem (quoted here, not proved) e−x2,e^{-x^2}\mathclose{\text{,}} sin⁡xx\tfrac{\sin x}{x} and 1ln⁡x\tfrac{1}{\ln x} have none, and their antiderivatives are named by integrals: erf⁡,\operatorname{erf}\mathclose{\text{,}} Si⁡,\operatorname{Si}\mathclose{\text{,}} Li⁡.\operatorname{Li}\mathclose{\text{.}}
  • Numerical integration: the midpoint rule Mn,M_n\mathclose{\text{,}} the trapezoidal rule Tn=12(Ln+Rn)T_n = \tfrac12(L_n + R_n) and Simpson’s rule SnS_n (nn even, weights 1,4,2,…,4,1).1, 4, 2, \dots, 4, 1\mathclose{\text{).}} With ∣f′′∣≤K,\abs{f''} \le K\mathclose{\text{,}} ∣ET∣≤K(b−a)312n2\abs{E_T} \le \tfrac{K(b - a)^3}{12n^2} and ∣EM∣≤K(b−a)324n2;\abs{E_M} \le \tfrac{K(b - a)^3}{24n^2}\mathclose{\text{;}} with ∣f(4)∣≤K,\abs{f^{(4)}} \le K\mathclose{\text{,}} ∣ES∣≤K(b−a)5180n4.\abs{E_S} \le \tfrac{K(b - a)^5}{180n^4}\mathclose{\text{.}} Doubling nn divides the errors by about 4, 4 and 16; Simpson’s rule is exact for cubics; concavity gives the signs of ETE_T and EM.E_M\mathclose{\text{.}}
9

Exercises

Exercise 11.1★Integration by parts

Find:

  • (a) ∫xsin⁡2x dx\displaystyle\int x\sin 2x\,dx
  • (b) ∫x2ln⁡x dx,\displaystyle\int x^2\ln x\,dx\mathclose{\text{,}} for x>0x > 0
  • (c) ∫01xe−x dx,\displaystyle\int_0^1 xe^{-x}\,dx\mathclose{\text{,}} exactly and to four decimal places
Show solution✓ Checked

(a) u=x,u = x\mathclose{\text{,}} dv=sin⁡2x dx,dv = \sin 2x\,dx\mathclose{\text{,}} so du=dxdu = dx and v=−12cos⁡2x:v = -\tfrac12\cos 2x\mathclose{\text{:}}

∫xsin⁡2x dx=−12xcos⁡2x+12∫cos⁡2x dx=−12xcos⁡2x+14sin⁡2x+C.\begin{aligned} &\int x\sin 2x\,dx \\ &\quad= -\tfrac12x\cos 2x \\ &\qquad + \tfrac12\int \cos 2x\,dx \\ &\quad= -\tfrac12x\cos 2x + \tfrac14\sin 2x + C. \end{aligned}

(b) By LIATE, u=ln⁡xu = \ln x and dv=x2 dx,dv = x^2\,dx\mathclose{\text{,}} so du=dxxdu = \dfrac{dx}{x} and v=x33:v = \dfrac{x^3}{3}\mathclose{\text{:}}

∫x2ln⁡x dx=x33ln⁡x−∫x33⋅1x dx=x33ln⁡x−x39+C.\begin{aligned} &\int x^2\ln x\,dx \\ &\quad= \frac{x^3}{3}\ln x - \int \frac{x^3}{3}\cdot\frac{1}{x}\,dx \\ &\quad= \frac{x^3}{3}\ln x - \frac{x^3}{9} + C. \end{aligned}

The other choice, u=x2u = x^2 and dv=ln⁡x dx,dv = \ln x\,dx\mathclose{\text{,}} needs v=xln⁡x−xv = x\ln x - x (Example 11.1(b)), and the new integral, ∫2x(xln⁡x−x) dx=2∫x2ln⁡x dx−2∫x2 dx,\int 2x(x\ln x - x)\,dx = 2\int x^2\ln x\,dx - 2\int x^2\,dx\mathclose{\text{,}} contains the original one again. Solving for it, as in Example 11.6, gives the same answer, with more work.

(c) Example 11.1(a) gives the antiderivative −xe−x−e−x=−(x+1)e−x,-xe^{-x} - e^{-x} = -(x + 1)e^{-x}\mathclose{\text{,}} so

∫01xe−x dx=[−(x+1)e−x]01=−2e−1+1=1−2e≈0.2642.\begin{aligned} \int_0^1 xe^{-x}\,dx &= \big[-(x + 1)e^{-x}\big]_0^1 \\ &= -2e^{-1} + 1 \\ &= 1 - \frac{2}{e} \approx 0.2642. \end{aligned}
Exercise 11.2★Trigonometric integrals

Find:

  • (a) ∫cos⁡3x dx\displaystyle\int \cos^3 x\,dx
  • (b) ∫sin⁡2xcos⁡2x dx\displaystyle\int \sin^2 x\cos^2 x\,dx
  • (c) ∫0π/4sec⁡4x dx\displaystyle\int_0^{\pi/4} \sec^4 x\,dx
Show solution✓ Checked

(a) The power of the cosine is odd: cos⁡3x=(1−sin⁡2x)cos⁡x.\cos^3 x = \big(1 - \sin^2 x\big)\cos x\mathclose{\text{.}} With u=sin⁡x,u = \sin x\mathclose{\text{,}}

∫(1−u2) du=sin⁡x−13sin⁡3x+C.\begin{aligned} &\int \big(1 - u^2\big)\,du \\ &\quad= \sin x - \tfrac13\sin^3 x + C. \end{aligned}

(b) Both powers are even. Use sin⁡xcos⁡x=12sin⁡2x,\sin x\cos x = \tfrac12\sin 2x\mathclose{\text{,}} then the half-angle identity with 2x2x in place of x:x\mathclose{\text{:}}

sin⁡2xcos⁡2x=14sin⁡22x=18(1−cos⁡4x),\begin{aligned} \sin^2 x\cos^2 x &= \tfrac14\sin^2 2x \\ &= \tfrac18\big(1 - \cos 4x\big), \end{aligned}

so

∫sin⁡2xcos⁡2x dx=x8−sin⁡4x32+C.\begin{aligned} &\int \sin^2 x\cos^2 x\,dx \\ &\quad= \frac{x}{8} - \frac{\sin 4x}{32} + C. \end{aligned}

(c) The power of the secant is even: sec⁡4x=(1+tan⁡2x)sec⁡2x.\sec^4 x = \big(1 + \tan^2 x\big)\sec^2 x\mathclose{\text{.}} With u=tan⁡x,u = \tan x\mathclose{\text{,}} the limits become tan⁡0=0\tan 0 = 0 and tan⁡π4=1:\tan\tfrac{\pi}{4} = 1\mathclose{\text{:}}

∫0π/4sec⁡4x dx=∫01(1+u2) du=1+13=43.\begin{aligned} &\int_0^{\pi/4} \sec^4 x\,dx \\ &\quad= \int_0^1 \big(1 + u^2\big)\,du \\ &\quad= 1 + \frac13 = \frac43. \end{aligned}
Exercise 11.3★Partial fractions
  • (a) Find ∫x+7x2−x−6 dx.\displaystyle\int \frac{x + 7}{x^2 - x - 6}\,dx\mathclose{\text{.}}
  • (b) Evaluate ∫01dx(x+1)(x+2),\displaystyle\int_0^1 \frac{dx}{(x + 1)(x + 2)}\mathclose{\text{,}} exactly and to four decimal places.
  • (c) Explain why ∫x2+1x2−1 dx\displaystyle\int \frac{x^2 + 1}{x^2 - 1}\,dx needs long division first, and find it.
Show solution✓ Checked

(a) x2−x−6=(x−3)(x+2).x^2 - x - 6 = (x - 3)(x + 2)\mathclose{\text{.}} Cover-up: the coefficient of 1x−3\dfrac{1}{x - 3} is 3+73+2=2,\dfrac{3 + 7}{3 + 2} = 2\mathclose{\text{,}} and that of 1x+2\dfrac{1}{x + 2} is −2+7−2−3=−1.\dfrac{-2 + 7}{-2 - 3} = -1\mathclose{\text{.}} So

∫x+7x2−x−6 dx=2ln⁡∣x−3∣−ln⁡∣x+2∣+C.\begin{aligned} &\int \frac{x + 7}{x^2 - x - 6}\,dx \\ &\quad= 2\ln\abs{x - 3} \\ &\qquad - \ln\abs{x + 2} + C. \end{aligned}

(b) Cover-up: 1(x+1)(x+2)=1x+1−1x+2.\dfrac{1}{(x + 1)(x + 2)} = \dfrac{1}{x + 1} - \dfrac{1}{x + 2}\mathclose{\text{.}} On [0,1][0, 1] both factors are positive, so

∫01dx(x+1)(x+2)=[ln⁡(x+1)−ln⁡(x+2)]01=(ln⁡2−ln⁡3)−(0−ln⁡2)=2ln⁡2−ln⁡3=ln⁡43≈0.2877.\begin{aligned} &\int_0^1 \frac{dx}{(x + 1)(x + 2)} \\ &\quad= \big[\ln(x + 1) - \ln(x + 2)\big]_0^1 \\ &\quad= (\ln 2 - \ln 3) - (0 - \ln 2) \\ &\quad= 2\ln 2 - \ln 3 \\ &\quad= \ln\frac43 \approx 0.2877. \end{aligned}

(c) The numerator and the denominator have the same degree, 2, so the fraction is improper, and Theorem 11.7 does not apply to it. Divide: x2+1=1⋅(x2−1)+2,x^2 + 1 = 1\cdot\big(x^2 - 1\big) + 2\mathclose{\text{,}} so the integrand is 1+2x2−1,1 + \dfrac{2}{x^2 - 1}\mathclose{\text{,}} and by Example 11.15(b) with a=1,a = 1\mathclose{\text{,}}

∫x2+1x2−1 dx=x+ln⁡∣x−1x+1∣+C.\begin{aligned} &\int \frac{x^2 + 1}{x^2 - 1}\,dx \\ &\quad= x + \ln\Big|\frac{x - 1}{x + 1}\Big| + C. \end{aligned}

Trying Ax−1+Bx+1\dfrac{A}{x - 1} + \dfrac{B}{x + 1} directly fails: that sum is always a proper fraction.

Exercise 11.4★A power log, revisited

In Exercise 9.9, a program logged a GPU’s power draw every 10 seconds during a one-minute job. The made-up readings were 120, 180, 250, 260, 240, 200 and 150 W at t=0,10,…,60t = 0, 10, \dots, 60 s.

  • (a) Estimate the energy E=∫060P(t) dtE = \int_0^{60} P(t)\,dt with the trapezoidal rule and with Simpson’s rule.
  • (b) Compare the trapezoidal estimate with the left and right sums of Exercise 9.9, 12,500 J and 12,800 J.
  • (c) Why can you not use the midpoint rule with 6 subintervals here? Which midpoint estimate can you make, and how is it related to the others?
Show solution✓ Checked

(a) There are n=6n = 6 intervals of Δt=10\Delta t = 10 s, an even number, so both rules apply:

T6=102[120+2(180+250+260+240+200)+150]=5⋅2530=12,650 J,S6=103[120+4⋅180+2⋅250+4⋅260+2⋅240+4⋅200+150]=103⋅3810=12,700 J.\begin{aligned} T_6 &= \frac{10}{2}\big[120 + 2(180 \\ &\qquad + 250 + 260 + 240 \\ &\qquad + 200) + 150\big] \\ &= 5\cdot 2530 = 12{,}650 \text{ J}, \\ S_6 &= \frac{10}{3}\big[120 + 4\cdot 180 \\ &\qquad + 2\cdot 250 + 4\cdot 260 \\ &\qquad + 2\cdot 240 + 4\cdot 200 \\ &\qquad + 150\big] \\ &= \frac{10}{3}\cdot 3810 \\ &= 12{,}700 \text{ J}. \end{aligned}

(b) T6=12,650T_6 = 12{,}650 J is the average of 12,500 J and 12,800 J, as Definition 11.4 says it must be.

(c) M6M_6 needs the power at the midpoints 5, 15, …, 55 s, which were not measured. With 3 subintervals of 20 s, though, the midpoints are 10, 30 and 50 s, which were: M3=20(180+260+200)=12,800M_3 = 20(180 + 260 + 200) = 12{,}800 J. With T3=202(120+2⋅250+2⋅240+150)=12,500T_3 = \tfrac{20}{2}(120 + 2\cdot 250 + 2\cdot 240 + 150) = 12{,}500 J, the relation of Example 11.21 gives back Simpson’s estimate: 13(T3+2M3)=13(12,500+25,600)=12,700\tfrac13(T_3 + 2M_3) = \tfrac13(12{,}500 + 25{,}600) = 12{,}700 J =S6.= S_6\mathclose{\text{.}} None of these estimates comes with a guarantee: ten-second readings say nothing about the power between them.

Exercise 11.5★★Repeated parts

Find:

  • (a) ∫x3e−x dx,\displaystyle\int x^3e^{-x}\,dx\mathclose{\text{,}} with the tabular method
  • (b) ∫e2xcos⁡x dx\displaystyle\int e^{2x}\cos x\,dx
  • (c) ∫(ln⁡x)2 dx,\displaystyle\int (\ln x)^2\,dx\mathclose{\text{,}} for x>0x > 0
Show solution✓ Checked

(a) Differentiate x3x^3 in column D and integrate e−xe^{-x} in column I:

Sign D I
++ x3x^3 e−xe^{-x}
−- 3x23x^2 −e−x-e^{-x}
++ 6x6x e−xe^{-x}
−- 66 −e−x-e^{-x}
00 e−xe^{-x}

Multiplying along the diagonals with the signs,

∫x3e−x dx=−x3e−x−3x2e−x−6xe−x−6e−x+C=−e−x(x3+3x2+6x+6)+C.\begin{aligned} &\int x^3e^{-x}\,dx \\ &\quad= -x^3e^{-x} - 3x^2e^{-x} \\ &\qquad - 6xe^{-x} - 6e^{-x} + C \\ &\quad= -e^{-x}\big(x^3 + 3x^2 \\ &\qquad + 6x + 6\big) + C. \end{aligned}

(b) Call it I.I\mathclose{\text{.}} With u=cos⁡xu = \cos x and dv=e2x dx,dv = e^{2x}\,dx\mathclose{\text{,}} so v=12e2x:v = \tfrac12e^{2x}\mathclose{\text{:}}

I=12e2xcos⁡x+12∫e2xsin⁡x dx.\begin{aligned} I &= \tfrac12e^{2x}\cos x \\ &\quad + \tfrac12\int e^{2x}\sin x\,dx. \end{aligned}

Again, keeping the roles, with u=sin⁡x:u = \sin x\mathclose{\text{:}} ∫e2xsin⁡x dx=12e2xsin⁡x−12I.\int e^{2x}\sin x\,dx = \tfrac12e^{2x}\sin x - \tfrac12I\mathclose{\text{.}} So

I=12e2xcos⁡x+14e2xsin⁡x−14I,I = \tfrac12e^{2x}\cos x + \tfrac14e^{2x}\sin x - \tfrac14I,

and solving, 54I=14e2x(2cos⁡x+sin⁡x):\tfrac54I = \tfrac14e^{2x}(2\cos x + \sin x)\mathclose{\text{:}}

∫e2xcos⁡x dx=15e2x(2cos⁡x+sin⁡x)+C.\begin{aligned} &\int e^{2x}\cos x\,dx \\ &\quad= \tfrac15e^{2x}(2\cos x + \sin x) + C. \end{aligned}

(c) u=(ln⁡x)2u = (\ln x)^2 and dv=dx,dv = dx\mathclose{\text{,}} so du=2ln⁡xx dxdu = \dfrac{2\ln x}{x}\,dx and v=x.v = x\mathclose{\text{.}} Then, with Example 11.1(b),

∫(ln⁡x)2 dx=x(ln⁡x)2−2∫ln⁡x dx=x(ln⁡x)2−2xln⁡x+2x+C.\begin{aligned} &\int (\ln x)^2\,dx \\ &\quad= x(\ln x)^2 - 2\int \ln x\,dx \\ &\quad= x(\ln x)^2 - 2x\ln x \\ &\qquad + 2x + C. \end{aligned}
Exercise 11.6★★Trigonometric substitutions
  • (a) Find ∫x29−x2 dx,\displaystyle\int \frac{x^2}{\sqrt{9 - x^2}}\,dx\mathclose{\text{,}} for −3<x<3.-3 < x < 3\mathclose{\text{.}}
  • (b) Find ∫dx(x2+9)3/2.\displaystyle\int \frac{dx}{\big(x^2 + 9\big)^{3/2}}\mathclose{\text{.}}
  • (c) Evaluate ∫011+x2 dx,\displaystyle\int_0^1 \sqrt{1 + x^2}\,dx\mathclose{\text{,}} exactly and to four decimal places. (By the arc length formula of Module 12, it is the length of the parabola y=12x2y = \tfrac12x^2 from x=0x = 0 to x=1.)x = 1\mathclose{\text{.)}}
Show solution✓ Checked

(a) x=3sin⁡θx = 3\sin\theta with −π2<θ<π2,-\tfrac{\pi}{2} < \theta < \tfrac{\pi}{2}\mathclose{\text{,}} so dx=3cos⁡θ dθdx = 3\cos\theta\,d\theta and 9−x2=3cos⁡θ:\sqrt{9 - x^2} = 3\cos\theta\mathclose{\text{:}}

∫9sin⁡2θ3cos⁡θ 3cos⁡θ dθ=9∫sin⁡2θ dθ=92(θ−sin⁡θcos⁡θ)+C,\begin{aligned} &\int \frac{9\sin^2\theta}{3\cos\theta}\,3\cos\theta\,d\theta \\ &\quad= 9\int \sin^2\theta\,d\theta \\ &\quad= \frac92(\theta - \sin\theta\cos\theta) + C, \end{aligned}

by Example 11.7(a). The left triangle of Figure 11.2, with a=3,a = 3\mathclose{\text{,}} gives sin⁡θ=x3\sin\theta = \tfrac{x}{3} and cos⁡θ=9−x23,\cos\theta = \tfrac{\sqrt{9 - x^2}}{3}\mathclose{\text{,}} so

∫x29−x2 dx=92arcsin⁡x3−x29−x2+C.\begin{aligned} &\int \frac{x^2}{\sqrt{9 - x^2}}\,dx \\ &\quad= \frac92\arcsin\frac{x}{3} \\ &\qquad - \frac{x}{2}\sqrt{9 - x^2} + C. \end{aligned}

(b) x=3tan⁡θx = 3\tan\theta with −π2<θ<π2,-\tfrac{\pi}{2} < \theta < \tfrac{\pi}{2}\mathclose{\text{,}} so dx=3sec⁡2θ dθdx = 3\sec^2\theta\,d\theta and (x2+9)3/2=(9sec⁡2θ)3/2=27sec⁡3θ:\big(x^2 + 9\big)^{3/2} = \big(9\sec^2\theta\big)^{3/2} = 27\sec^3\theta\mathclose{\text{:}}

∫3sec⁡2θ27sec⁡3θ dθ=19∫cos⁡θ dθ=19sin⁡θ+C.\begin{aligned} &\int \frac{3\sec^2\theta}{27\sec^3\theta}\,d\theta \\ &\quad= \frac19\int \cos\theta\,d\theta \\ &\quad= \frac19\sin\theta + C. \end{aligned}

The middle triangle gives sin⁡θ=xx2+9,\sin\theta = \dfrac{x}{\sqrt{x^2 + 9}}\mathclose{\text{,}} so the integral is x9x2+9+C.\dfrac{x}{9\sqrt{x^2 + 9}} + C\mathclose{\text{.}}

(c) x=tan⁡θ,x = \tan\theta\mathclose{\text{,}} so dx=sec⁡2θ dθdx = \sec^2\theta\,d\theta and 1+x2=sec⁡θ;\sqrt{1 + x^2} = \sec\theta\mathclose{\text{;}} x=0x = 0 and x=1x = 1 give θ=0\theta = 0 and θ=π4.\theta = \tfrac{\pi}{4}\mathclose{\text{.}} By Example 11.11,

∫011+x2 dx=∫0π/4sec⁡3θ dθ=[12sec⁡θtan⁡θ+12ln⁡∣sec⁡θ+tan⁡θ∣]0π/4=122+12ln⁡(2+1)≈1.1478,\begin{aligned} &\int_0^1 \sqrt{1 + x^2}\,dx \\ &\quad= \int_0^{\pi/4} \sec^3\theta\,d\theta \\ &\quad= \Big[\tfrac12\sec\theta\tan\theta \\ &\qquad + \tfrac12\ln\abs{\sec\theta + \tan\theta}\Big]_0^{\pi/4} \\ &\quad= \tfrac12\sqrt2 + \tfrac12\ln\big(\sqrt2 + 1\big) \\ &\quad\approx 1.1478, \end{aligned}

since sec⁡π4=2,\sec\tfrac{\pi}{4} = \sqrt2\mathclose{\text{,}} tan⁡π4=1,\tan\tfrac{\pi}{4} = 1\mathclose{\text{,}} and the bracket is 0 at θ=0.\theta = 0\mathclose{\text{.}}

Exercise 11.7★★More partial fractions
  • (a) Find ∫x2+2x(x+1)2 dx.\displaystyle\int \frac{x^2 + 2}{x(x + 1)^2}\,dx\mathclose{\text{.}}
  • (b) Find ∫3x+1x3+x dx.\displaystyle\int \frac{3x + 1}{x^3 + x}\,dx\mathclose{\text{.}}
  • (c) In a model of a population yy that cannot exceed a size K>0K > 0 (Module 13), the integral ∫dyy(K−y)\displaystyle\int \frac{dy}{y(K - y)} appears, for 0<y<K.0 < y < K\mathclose{\text{.}} Find it.
Show solution✓ Checked

(a) By Theorem 11.7, x2+2x(x+1)2=Ax+Bx+1+D(x+1)2.\dfrac{x^2 + 2}{x(x + 1)^2} = \dfrac{A}{x} + \dfrac{B}{x + 1} + \dfrac{D}{(x + 1)^2}\mathclose{\text{.}} Cover-up: A=0+2(0+1)2=2,A = \dfrac{0 + 2}{(0 + 1)^2} = 2\mathclose{\text{,}} and for the highest power of x+1,x + 1\mathclose{\text{,}} D=1+2−1=−3.D = \dfrac{1 + 2}{-1} = -3\mathclose{\text{.}} Multiplying by the denominator, x2+2=A(x+1)2+Bx(x+1)+Dx,x^2 + 2 = A(x + 1)^2 + Bx(x + 1) + Dx\mathclose{\text{,}} and the coefficients of x2x^2 give 1=A+B,1 = A + B\mathclose{\text{,}} so B=−1.B = -1\mathclose{\text{.}} So

∫x2+2x(x+1)2 dx=∫(2x−1x+1−3(x+1)2) dx=2ln⁡∣x∣−ln⁡∣x+1∣+3x+1+C.\begin{aligned} &\int \frac{x^2 + 2}{x(x + 1)^2}\,dx \\ &\quad= \int \Big(\frac2x - \frac{1}{x + 1} \\ &\qquad - \frac{3}{(x + 1)^2}\Big)\,dx \\ &\quad= 2\ln\abs{x} - \ln\abs{x + 1} \\ &\qquad + \frac{3}{x + 1} + C. \end{aligned}

(b) x3+x=x(x2+1),x^3 + x = x\big(x^2 + 1\big)\mathclose{\text{,}} with x2+1x^2 + 1 irreducible: 3x+1x(x2+1)=Ax+Bx+Dx2+1.\dfrac{3x + 1}{x(x^2 + 1)} = \dfrac{A}{x} + \dfrac{Bx + D}{x^2 + 1}\mathclose{\text{.}} Cover-up: A=11=1.A = \dfrac{1}{1} = 1\mathclose{\text{.}} Then 3x+1=(x2+1)+(Bx+D)x;3x + 1 = \big(x^2 + 1\big) + (Bx + D)x\mathclose{\text{;}} the coefficients of x2x^2 give 0=1+B,0 = 1 + B\mathclose{\text{,}} so B=−1,B = -1\mathclose{\text{,}} and those of xx give D=3.D = 3\mathclose{\text{.}} So

∫3x+1x3+x dx=∫(1x−xx2+1+3x2+1) dx=ln⁡∣x∣−12ln⁡(x2+1)+3arctan⁡x+C.\begin{aligned} &\int \frac{3x + 1}{x^3 + x}\,dx \\ &\quad= \int \Big(\frac1x - \frac{x}{x^2 + 1} \\ &\qquad + \frac{3}{x^2 + 1}\Big)\,dx \\ &\quad= \ln\abs{x} - \tfrac12\ln\big(x^2 + 1\big) \\ &\qquad + 3\arctan x + C. \end{aligned}

(c) The two factors yy and K−y=−(y−K)K - y = -(y - K) are distinct linear factors. Cover-up: at y=0y = 0 the coefficient of 1y\dfrac1y is 1K,\dfrac{1}{K}\mathclose{\text{,}} and covering up K−yK - y and putting y=Ky = K gives the coefficient 1K\dfrac1K of 1K−y.\dfrac{1}{K - y}\mathclose{\text{.}} So

1y(K−y)=1K(1y+1K−y),\frac{1}{y(K - y)} = \frac1K\Big(\frac1y + \frac{1}{K - y}\Big),

and, since y>0y > 0 and K−y>0,K - y > 0\mathclose{\text{,}} and ∫dyK−y=−ln⁡(K−y)+C\int \frac{dy}{K - y} = -\ln(K - y) + C (substitute w=K−y),w = K - y\mathclose{\text{),}}

∫dyy(K−y)=ln⁡y−ln⁡(K−y)K+C=1Kln⁡yK−y+C.\begin{aligned} &\int \frac{dy}{y(K - y)} \\ &\quad= \frac{\ln y - \ln(K - y)}{K} + C \\ &\quad= \frac1K\ln\frac{y}{K - y} + C. \end{aligned}
Exercise 11.8★★Choosing a method

Choose a method for each integral, and evaluate it.

  • (a) ∫xcos⁡(x2) dx\displaystyle\int x\cos\big(x^2\big)\,dx
  • (b) ∫x2cos⁡x dx\displaystyle\int x^2\cos x\,dx
  • (c) ∫dxx2+2x+2\displaystyle\int \frac{dx}{x^2 + 2x + 2}
  • (d) ∫x1−x4 dx,\displaystyle\int \frac{x}{\sqrt{1 - x^4}}\,dx\mathclose{\text{,}} for −1<x<1-1 < x < 1
  • (e) SymPy answers ∫x2ex2 dx\int x^2e^{x^2}\,dx with 12xex2−π4erfi⁡x,\tfrac12xe^{x^2} - \tfrac{\sqrt\pi}{4}\operatorname{erfi} x\mathclose{\text{,}} where erfi⁡\operatorname{erfi} is a function defined by an integral, like erf⁡,\operatorname{erf}\mathclose{\text{,}} with derivative 2πex2.\tfrac{2}{\sqrt\pi}e^{x^2}\mathclose{\text{.}} Check the answer by differentiating it. Then integrate by parts with u=xu = x to explain why no elementary formula would do.
Show solution✓ Checked

(a) A function of x2x^2 times x,x\mathclose{\text{,}} half the derivative of x2:x^2\mathclose{\text{:}} substitute u=x2,u = x^2\mathclose{\text{,}} du=2x dx,du = 2x\,dx\mathclose{\text{,}} to get 12∫cos⁡u du=12sin⁡(x2)+C.\tfrac12\int \cos u\,du = \tfrac12\sin\big(x^2\big) + C\mathclose{\text{.}} Parts would only make it worse.

(b) A power times a cosine: parts, twice (tabular). With the signs +,−,++, -, + and the antiderivatives sin⁡x,\sin x\mathclose{\text{,}} −cos⁡x,-\cos x\mathclose{\text{,}} −sin⁡x-\sin x of cos⁡x,\cos x\mathclose{\text{,}}

∫x2cos⁡x dx=x2sin⁡x+2xcos⁡x−2sin⁡x+C.\begin{aligned} &\int x^2\cos x\,dx \\ &\quad= x^2\sin x + 2x\cos x \\ &\qquad - 2\sin x + C. \end{aligned}

(c) A rational function with an irreducible denominator: 22−4⋅2=−4<0.2^2 - 4\cdot 2 = -4 < 0\mathclose{\text{.}} Complete the square, x2+2x+2=(x+1)2+1,x^2 + 2x + 2 = (x + 1)^2 + 1\mathclose{\text{,}} and substitute u=x+1:u = x + 1\mathclose{\text{:}}

∫dxx2+2x+2=∫duu2+1=arctan⁡(x+1)+C.\begin{aligned} &\int \frac{dx}{x^2 + 2x + 2} \\ &\quad= \int \frac{du}{u^2 + 1} \\ &\quad= \arctan(x + 1) + C. \end{aligned}

(d) It looks like a trigonometric substitution, but a substitution comes first: x4=(x2)2,x^4 = \big(x^2\big)^2\mathclose{\text{,}} and xx is half the derivative of x2.x^2\mathclose{\text{.}} With u=x2,u = x^2\mathclose{\text{,}} du=2x dx,du = 2x\,dx\mathclose{\text{,}} and 0≤u<1,0 \le u < 1\mathclose{\text{,}}

∫x1−x4 dx=12∫du1−u2=12arcsin⁡(x2)+C.\begin{aligned} &\int \frac{x}{\sqrt{1 - x^4}}\,dx \\ &\quad= \frac12\int \frac{du}{\sqrt{1 - u^2}} \\ &\quad= \frac12\arcsin\big(x^2\big) + C. \end{aligned}

(e) By the product and chain rules, ddx(12xex2)=12ex2+x2ex2,\dfrac{d}{dx}\big(\tfrac12xe^{x^2}\big) = \tfrac12e^{x^2} + x^2e^{x^2}\mathclose{\text{,}} and ddx(π4erfi⁡x)=π4⋅2πex2=12ex2.\dfrac{d}{dx}\big(\tfrac{\sqrt\pi}{4}\operatorname{erfi} x\big) = \tfrac{\sqrt\pi}{4}\cdot\tfrac{2}{\sqrt\pi}e^{x^2} = \tfrac12e^{x^2}\mathclose{\text{.}} The difference is x2ex2,x^2e^{x^2}\mathclose{\text{,}} so SymPy’s answer is right. By parts, with u=xu = x and dv=xex2 dx,dv = xe^{x^2}\,dx\mathclose{\text{,}} so that du=dxdu = dx and v=12ex2:v = \tfrac12e^{x^2}\mathclose{\text{:}}

∫x2ex2 dx=12xex2−12∫ex2 dx.\begin{aligned} &\int x^2e^{x^2}\,dx \\ &\quad= \tfrac12xe^{x^2} - \tfrac12\int e^{x^2}\,dx. \end{aligned}

If x2ex2x^2e^{x^2} had an elementary antiderivative F,F\mathclose{\text{,}} then xex2−2Fxe^{x^2} - 2F would be an elementary antiderivative of ex2:e^{x^2}\mathclose{\text{:}} its derivative is ex2+2x2ex2−2x2ex2=ex2.e^{x^2} + 2x^2e^{x^2} - 2x^2e^{x^2} = e^{x^2}\mathclose{\text{.}} Section 11.6 says that there is none. So the answer needs a function such as erfi⁡,\operatorname{erfi}\mathclose{\text{,}} as SymPy’s does. The odd powers are different: ∫xex2 dx=12ex2+C,\int xe^{x^2}\,dx = \tfrac12e^{x^2} + C\mathclose{\text{,}} and Example 11.2 found ∫x3ex2 dx.\int x^3e^{x^2}\,dx\mathclose{\text{.}}

Exercise 11.9★★How many subintervals?

Let f(x)=e−x2.f(x) = e^{-x^2}\mathclose{\text{.}}

  • (a) Find f′′(x)f''(x) and f(4)(x),f^{(4)}(x)\mathclose{\text{,}} and show that ∣f′′(x)∣≤2\abs{f''(x)} \le 2 and ∣f(4)(x)∣≤20\abs{f^{(4)}(x)} \le 20 for 0≤x≤1.0 \le x \le 1\mathclose{\text{.}}
  • (b) How large must nn be to guarantee that Tn,T_n\mathclose{\text{,}} and that Sn,S_n\mathclose{\text{,}} approximates ∫01e−x2 dx\int_0^1 e^{-x^2}\,dx with an error of at most 10−6?10^{-6}\mathclose{\text{?}}
  • (c) Compare with the errors printed in the Compute it box of Section 11.7.
Show solution✓ Checked

(a) By the chain and product rules, f′(x)=−2xe−x2f'(x) = -2xe^{-x^2} and f′′(x)=(4x2−2)e−x2;f''(x) = \big(4x^2 - 2\big)e^{-x^2}\mathclose{\text{;}} differentiating twice more, f′′′(x)=(12x−8x3)e−x2f'''(x) = \big(12x - 8x^3\big)e^{-x^2} and f(4)(x)=(16x4−48x2+12)e−x2.f^{(4)}(x) = \big(16x^4 - 48x^2 + 12\big)e^{-x^2}\mathclose{\text{.}} For 0≤x≤1,0 \le x \le 1\mathclose{\text{,}} 0<e−x2≤1.0 < e^{-x^2} \le 1\mathclose{\text{.}} And 4x2−24x^2 - 2 lies between −2-2 and 2, so ∣f′′(x)∣≤2.\abs{f''(x)} \le 2\mathclose{\text{.}} With s=x2,s = x^2\mathclose{\text{,}} which lies in [0,1],[0, 1]\mathclose{\text{,}} the polynomial 16s2−48s+1216s^2 - 48s + 12 has derivative 32s−48<0,32s - 48 < 0\mathclose{\text{,}} so it decreases from 12 at s=0s = 0 to −20-20 at s=1;s = 1\mathclose{\text{;}} so ∣16x4−48x2+12∣≤20,\abs{16x^4 - 48x^2 + 12} \le 20\mathclose{\text{,}} and ∣f(4)(x)∣≤20.\abs{f^{(4)}(x)} \le 20\mathclose{\text{.}}

(b) Trapezoidal rule, with K=2K = 2 and b−a=1:b - a = 1\mathclose{\text{:}} 212n2≤10−6\dfrac{2}{12n^2} \le 10^{-6} needs n2≥166,667,n^2 \ge 166{,}667\mathclose{\text{,}} so n=409n = 409 suffices, as in Example 11.20. Simpson’s rule, with K=20:K = 20\mathclose{\text{:}} 20180n4≤10−6\dfrac{20}{180n^4} \le 10^{-6} needs n4≥111,112,n^4 \ge 111{,}112\mathclose{\text{,}} that is, n≥18.26;n \ge 18.26\mathclose{\text{;}} with nn even, n=20n = 20 suffices.

(c) The box shows ∣ET∣≈1.5×10−5\abs{E_T} \approx 1.5 \times 10^{-5} at n=64,n = 64\mathclose{\text{,}} still too big; since the errors fall like 1n2,\tfrac{1}{n^2}\mathclose{\text{,}} the trapezoidal rule reaches 10−610^{-6} near n=250,n = 250\mathclose{\text{,}} before the guaranteed 409. Simpson’s rule has ∣ES∣≈2×10−6\abs{E_S} \approx 2 \times 10^{-6} at n=8,n = 8\mathclose{\text{,}} still too big, and 1.25×10−71.25 \times 10^{-7} at n=16.n = 16\mathclose{\text{.}} Since its errors fall like 1n4,\tfrac{1}{n^4}\mathclose{\text{,}} n=10n = 10 should give about 2×10−6⋅0.84≈8×10−7,2 \times 10^{-6}\cdot 0.8^4 \approx 8 \times 10^{-7}\mathclose{\text{,}} and the box’s simpson function confirms it: ∣ES∣≈8.2×10−7\abs{E_S} \approx 8.2 \times 10^{-7} at n=10.n = 10\mathclose{\text{.}} That is half the guaranteed 20. The bounds are guarantees, and cautious ones: ∣f(4)∣\abs{f^{(4)}} is in fact at most 12 on [0,1],[0, 1]\mathclose{\text{,}} which would give n=18.n = 18\mathclose{\text{.}}

Exercise 11.10★★★Wallis’s integrals

Let In=∫0π/2sin⁡nx dxI_n = \displaystyle\int_0^{\pi/2} \sin^n x\,dx for n=0,1,2,…n = 0, 1, 2, \dots

  • (a) Show that I0=π2,I_0 = \tfrac{\pi}{2}\mathclose{\text{,}} I1=1,I_1 = 1\mathclose{\text{,}} and In=n−1nIn−2I_n = \dfrac{n - 1}{n}I_{n-2} for n≥2.n \ge 2\mathclose{\text{.}}
  • (b) Find I5I_5 and I6.I_6\mathclose{\text{.}}
  • (c) Prove that nInIn−1=π2nI_nI_{n-1} = \dfrac{\pi}{2} for every n≥1.n \ge 1\mathclose{\text{.}}
Show solution✓ Checked

(a) I0=∫0π/21 dx=π2I_0 = \int_0^{\pi/2} 1\,dx = \tfrac{\pi}{2} and I1=[−cos⁡x]0π/2=0+1=1.I_1 = \big[-\cos x\big]_0^{\pi/2} = 0 + 1 = 1\mathclose{\text{.}} For n≥2,n \ge 2\mathclose{\text{,}} Theorem 11.3 in its definite form (Example 11.7(c)) gives

In=[−sin⁡n−1xcos⁡xn]0π/2+n−1nIn−2,\begin{aligned} I_n &= \Big[-\frac{\sin^{n-1}x\cos x}{n}\Big]_0^{\pi/2} \\ &\quad + \frac{n - 1}{n}I_{n-2}, \end{aligned}

and the bracket is 0: at x=π2x = \tfrac{\pi}{2} because cos⁡π2=0,\cos\tfrac{\pi}{2} = 0\mathclose{\text{,}} and at x=0x = 0 because sin⁡0=0\sin 0 = 0 and n−1≥1.n - 1 \ge 1\mathclose{\text{.}}

(b) I5=45⋅23⋅I1=815I_5 = \tfrac45\cdot\tfrac23\cdot I_1 = \tfrac{8}{15} and I6=56⋅34⋅12⋅I0=1548⋅π2=5π32≈0.4909.I_6 = \tfrac56\cdot\tfrac34\cdot\tfrac12\cdot I_0 = \tfrac{15}{48}\cdot\tfrac{\pi}{2} = \tfrac{5\pi}{32} \approx 0.4909\mathclose{\text{.}}

(c) By induction on n.n\mathclose{\text{.}} For n=1:n = 1\mathclose{\text{:}} 1⋅I1I0=π2.1\cdot I_1I_0 = \tfrac{\pi}{2}\mathclose{\text{.}} Suppose nInIn−1=π2nI_nI_{n-1} = \tfrac{\pi}{2} for some n≥1.n \ge 1\mathclose{\text{.}} By (a), In+1=nn+1In−1,I_{n+1} = \tfrac{n}{n + 1}I_{n-1}\mathclose{\text{,}} so

(n+1)In+1In=(n+1)⋅nn+1In−1⋅In=nInIn−1=π2.\begin{aligned} &(n + 1)I_{n+1}I_n \\ &\quad= (n + 1)\cdot\frac{n}{n + 1}I_{n-1}\cdot I_n \\ &\quad= nI_nI_{n-1} = \frac{\pi}{2}. \end{aligned}

So the statement holds for every n≥1.n \ge 1\mathclose{\text{.}}

Exercise 11.11★★★Simpson’s rule and x⁴
  • (a) Show that Simpson’s rule with n=2n = 2 gives the exact values of ∫−11x3 dx\int_{-1}^{1} x^3\,dx and ∫02x3 dx,\int_0^2 x^3\,dx\mathclose{\text{,}} but not of ∫−11x4 dx.\int_{-1}^{1} x^4\,dx\mathclose{\text{.}}
  • (b) Find the error ESE_S for ∫−11x4 dx\int_{-1}^{1} x^4\,dx with n=2,n = 2\mathclose{\text{,}} and compare it with the bound of Theorem 11.10.
  • (c) Do the same with n=4.n = 4\mathclose{\text{.}} What do you conclude about the bound?
Show solution✓ Checked

(a) With n=2n = 2 on [−1,1],[-1, 1]\mathclose{\text{,}} Δx=1\Delta x = 1 and S2=13[f(−1)+4f(0)+f(1)].S_2 = \tfrac13\big[f(-1) + 4f(0) + f(1)\big]\mathclose{\text{.}} For x3:x^3\mathclose{\text{:}} 13(−1+0+1)=0=∫−11x3 dx.\tfrac13(-1 + 0 + 1) = 0 = \int_{-1}^{1} x^3\,dx\mathclose{\text{.}} On [0,2]:[0, 2]\mathclose{\text{:}} 13(0+4⋅1+8)=4=∫02x3 dx.\tfrac13(0 + 4\cdot 1 + 8) = 4 = \int_0^2 x^3\,dx\mathclose{\text{.}} For x4:x^4\mathclose{\text{:}} S2=13(1+0+1)=23,S_2 = \tfrac13(1 + 0 + 1) = \tfrac23\mathclose{\text{,}} but ∫−11x4 dx=25.\int_{-1}^{1} x^4\,dx = \tfrac25\mathclose{\text{.}}

(b) ES=25−23=−415.E_S = \tfrac25 - \tfrac23 = -\tfrac{4}{15}\mathclose{\text{.}} The fourth derivative of x4x^4 is the constant 24, so K=24,K = 24\mathclose{\text{,}} and the bound is

24⋅25180⋅24=7682880=415.\frac{24\cdot 2^5}{180\cdot 2^4} = \frac{768}{2880} = \frac{4}{15}.

The size of the error, ∣ES∣=415,\abs{E_S} = \tfrac{4}{15}\mathclose{\text{,}} equals the bound.

(c) With n=4,n = 4\mathclose{\text{,}} Δx=12\Delta x = \tfrac12 and the points −1,−12,0,12,1:-1, -\tfrac12, 0, \tfrac12, 1\mathclose{\text{:}}

S4=16[1+4⋅116+0+4⋅116+1]=16⋅52=512,\begin{aligned} S_4 &= \frac{1}{6}\Big[1 + 4\cdot\frac{1}{16} + 0 \\ &\qquad + 4\cdot\frac{1}{16} + 1\Big] \\ &= \frac16\cdot\frac52 = \frac{5}{12}, \end{aligned}

so ES=25−512=−160,E_S = \tfrac25 - \tfrac{5}{12} = -\tfrac{1}{60}\mathclose{\text{,}} exactly 16 times smaller than with n=2.n = 2\mathclose{\text{.}} The bound is 24⋅25180⋅44=160:\dfrac{24\cdot 2^5}{180\cdot 4^4} = \dfrac{1}{60}\mathclose{\text{:}} equal to ∣ES∣\abs{E_S} again. So the constant 180 in Theorem 11.10 cannot be replaced by a larger number: for x4x^4 the bound is attained. (The same happens for x2x^2 with the bounds of Theorem 11.8.)

Exercise 11.12★★★The midpoint error

This exercise proves the midpoint half of Theorem 11.8. Centre a subinterval at 0: for a subinterval [m−h,m+h],[m - h, m + h]\mathclose{\text{,}} apply what follows to g(t)=f(m+t),g(t) = f(m + t)\mathclose{\text{,}} whose integral over [−h,h][-h, h] is the integral of ff over [m−h,m+h].[m - h, m + h]\mathclose{\text{.}} So let f′′f'' be continuous on [−h,h],[-h, h]\mathclose{\text{,}} where h>0.h > 0\mathclose{\text{.}}

  • (a) Integrate by parts twice to show that
    ∫0hf(x) dx=hf(0)+h22f′(0)+12∫0h(h−x)2f′′(x) dx.\begin{aligned} &\int_0^h f(x)\,dx \\ &\quad= hf(0) + \frac{h^2}{2}f'(0) \\ &\qquad + \frac12\int_0^h (h - x)^2 f''(x)\,dx. \end{aligned}
    (Start with u=f(x)u = f(x) and dv=dx,dv = dx\mathclose{\text{,}} taking v=x−h.)v = x - h\mathclose{\text{.)}}
  • (b) Find the corresponding formula for ∫−h0f(x) dx,\int_{-h}^0 f(x)\,dx\mathclose{\text{,}} and deduce that
    ∫−hhf(x) dx−2hf(0)=12∫−hh(h−∣x∣)2f′′(x) dx.\begin{aligned} &\int_{-h}^{h} f(x)\,dx - 2hf(0) \\ &\quad= \frac12\int_{-h}^{h} \big(h - \abs{x}\big)^2 f''(x)\,dx. \end{aligned}
  • (c) Deduce the bound for ∣EM∣\abs{E_M} in Theorem 11.8, and that Mn≤∫abf(x) dxM_n \le \int_a^b f(x)\,dx when f′′≥0.f'' \ge 0\mathclose{\text{.}}
Show solution✓ Checked

(a) With u=f(x),u = f(x)\mathclose{\text{,}} dv=dxdv = dx and v=x−h,v = x - h\mathclose{\text{,}} which is 0 at x=h,x = h\mathclose{\text{,}}

∫0hf dx=[f(x)(x−h)]0h−∫0hf′(x)(x−h) dx=hf(0)+∫0h(h−x)f′(x) dx.\begin{aligned} &\int_0^h f\,dx \\ &\quad= \big[f(x)(x - h)\big]_0^h \\ &\qquad - \int_0^h f'(x)(x - h)\,dx \\ &\quad= hf(0) \\ &\qquad + \int_0^h (h - x)f'(x)\,dx. \end{aligned}

Again, with u=f′(x)u = f'(x) and dv=(h−x) dx,dv = (h - x)\,dx\mathclose{\text{,}} so that v=−12(h−x)2:v = -\tfrac12(h - x)^2\mathclose{\text{:}}

∫0h(h−x)f′(x) dx=[−12(h−x)2f′(x)]0h+12∫0h(h−x)2f′′(x) dx=h22f′(0)+12∫0h(h−x)2f′′(x) dx.\begin{aligned} &\int_0^h (h - x)f'(x)\,dx \\ &\quad= \Big[-\tfrac12(h - x)^2f'(x)\Big]_0^h \\ &\qquad + \frac12\int_0^h (h - x)^2f''(x)\,dx \\ &\quad= \frac{h^2}{2}f'(0) \\ &\qquad + \frac12\int_0^h (h - x)^2f''(x)\,dx. \end{aligned}

Putting this into the first result gives the formula.

(b) In the same way, with v=x+hv = x + h and then v=12(x+h)2,v = \tfrac12(x + h)^2\mathclose{\text{,}}

∫−h0f dx=hf(0)−h22f′(0)+12∫−h0(x+h)2f′′(x) dx.\begin{aligned} &\int_{-h}^0 f\,dx \\ &\quad= hf(0) - \frac{h^2}{2}f'(0) \\ &\qquad + \frac12\int_{-h}^0 (x + h)^2f''(x)\,dx. \end{aligned}

Add the two formulas: the terms in f′(0)f'(0) cancel. On [0,h],[0, h]\mathclose{\text{,}} h−x=h−∣x∣,h - x = h - \abs{x}\mathclose{\text{,}} and on [−h,0],[-h, 0]\mathclose{\text{,}} x+h=h−∣x∣,x + h = h - \abs{x}\mathclose{\text{,}} so the two integrals combine into the one stated.

(c) 2hf(0)2hf(0) is the midpoint rule on [−h,h],[-h, h]\mathclose{\text{,}} a subinterval of width w=2h,w = 2h\mathclose{\text{,}} so the left side of (b) is the error of the midpoint rule on one subinterval. The weight 12(h−∣x∣)2\tfrac12(h - \abs{x})^2 is at least 0, and

12∫−hh(h−∣x∣)2 dx=∫0h(h−x)2 dx=h33=w324.\begin{aligned} &\frac12\int_{-h}^{h} \big(h - \abs{x}\big)^2\,dx \\ &\quad= \int_0^h (h - x)^2\,dx \\ &\quad= \frac{h^3}{3} = \frac{w^3}{24}. \end{aligned}

So, if ∣f′′∣≤K,\abs{f''} \le K\mathclose{\text{,}} the comparison theorem bounds the error of one subinterval by Kw324,\tfrac{Kw^3}{24}\mathclose{\text{,}} and adding up nn subintervals of width b−an\tfrac{b - a}{n} gives ∣EM∣≤K(b−a)324n2.\abs{E_M} \le \tfrac{K(b - a)^3}{24n^2}\mathclose{\text{.}} If f′′≥0,f'' \ge 0\mathclose{\text{,}} each error is at least 0, so EM≥0,E_M \ge 0\mathclose{\text{,}} that is, Mn≤∫abf(x) dx.M_n \le \int_a^b f(x)\,dx\mathclose{\text{.}}

10

Check yourself

1
Which choice of uu and dvdv makes ∫xe3x dx\displaystyle\int xe^{3x}\,dx easier?
2
The best first step for ∫sin⁡3xcos⁡2x dx\displaystyle\int \sin^3 x\cos^2 x\,dx is
3
Which substitution suits ∫dxx2x2+16?\displaystyle\int \frac{dx}{x^2\sqrt{x^2 + 16}}\mathclose{\text{?}}
4
The form of the partial fraction decomposition of x+3x2(x−1)\dfrac{x + 3}{x^2(x - 1)} is
5
You find ∫dxx2+4=ln⁡(x+x2+4)+C,\displaystyle\int \frac{dx}{\sqrt{x^2 + 4}} = \ln\big(x + \sqrt{x^2 + 4}\big) + C\mathclose{\text{,}} and SymPy prints asinh(x/2). Which is true?
6
Which of these integrands has no elementary antiderivative?
7
If ∣f′′(x)∣≤3\abs{f''(x)} \le 3 on [0,2],[0, 2]\mathclose{\text{,}} the error bound of Theorem 11.8 for T10T_{10} is
8
For a smooth function such as exe^x on [0,1],[0, 1]\mathclose{\text{,}} doubling nn in Simpson’s rule divides the error by about
Finished this module?