Ten integrals by substitution and by parts — including parts applied twice, a definite integral, an improper one, and the sigmoid whose antiderivative is softplus — with worked solutions and the mistakes that forget the du or pick u and dv the wrong way round.
Before you start
Two techniques cover every integral on this page: substitution, which undoes the chain rule, and integration by parts, which undoes the product rule. The work goes wrong in a few places that recur: a dx replaced without the factor that du brings, u and dv chosen the wrong way round, a sign lost from ,du, limits left unchanged after a substitution, and a value at infinity asserted instead of computed. These ten problems run from single substitutions and single applications of parts to parts applied twice, a definite integral, an improper one, and the integral of the sigmoid.
∫fdx=F+C means :F′=f:F is an antiderivative of ,f, and the constant C stands for any constant, since adding a constant does not change the derivative.
Substitution: set ,u=g(x), so ,du=g′(x)dx, and rewrite the whole integrand, dx included, in terms of .u. In a definite integral, change the limits with it: x=a becomes .u=g(a).
Integration by parts: .∫udv=uv−∫vdu. It is the product rule (uv)′=u′v+uv′ integrated and rearranged. For a definite integral, ,∫abudv=[uv]ab−∫abvdu, where .[F]ab=F(b)−F(a).
u has a meaning local to each problem: in a substitution it is the new variable, in parts it is the factor to be differentiated, with dv the part to be integrated. No problem uses both at once.
An improper integral is a limit: ∫0∞fdx means .limb→∞∫0bfdx.
ln is the natural log, defined for positive arguments; ∫udu=ln∣u∣+C on any interval where .u=0.
Every antiderivative below can be checked by differentiating it — do that before looking at the solution.
∫σ(x)dx where ,σ(x)=1+e−x1, and then .∫−∞0σ(x)dx.
Answers
21ex2+C
ln(1+x2)+C
(x−1)ex+C
xlnx−x+C
xsinx+cosx+C
21ex(sinx−cosx)+C
4π
−ln∣cosx∣+C
1
;ln(1+ex)+C; and ∫−∞0σ=ln2−a→−∞limln(1+ea)=ln2
Worked solutions
Problem 1
∫xex2dx
,u=x2,.du=2xdx.ex2 is eu with inner function ,x2, and the integrand also contains ,x, which is half of that inner function's derivative .2x.
.xdx=21du.Divide both sides of step 1 by 2, so that the xdx in the integral can be replaced as a whole.
.∫xex2dx=∫eu⋅21du=21eu+C.Substitute steps 1 and 2; ,(eu)′=eu, and the constant 21 comes out of the integral.
21ex2+CPut u=x2 back. Check: by the chain rule, .dxd21ex2=21ex2⋅2x=xex2.
Problem 2
∫1+x22xdx
,u=1+x2,.du=2xdx.The numerator 2xdx is exactly the derivative of the denominator, times .dx.
.∫1+x22xdx=∫udu=ln∣u∣+C.The denominator becomes u and the numerator with dx becomes .du.
ln(1+x2)+CPut u=1+x2 back; 1+x2≥1>0 for every ,x, so the absolute value can be dropped and the answer holds on the whole real line.
Problem 3
∫xexdx
,u=x,;dv=exdx;,du=dx,.v=ex.Differentiating x makes it simpler, the constant 1, and ex is its own antiderivative, so the new integral ∫vdu has no factor of x left.
.∫xexdx=xex−∫exdx.Parts: .uv−∫vdu.
.xex−ex+C..∫exdx=ex+C.
(x−1)ex+CFactor out .ex. Check: by the product rule, .((x−1)ex)′=ex+(x−1)ex=xex.
Problem 4
∫lnxdx
,u=lnx,;dv=dx;,du=xdx,.v=x.No antiderivative of lnx is known yet, but its derivative, ,1/x, is simple; the other factor is then 1, and dx integrates to .x.lnx needs .x>0.
.∫lnxdx=xlnx−∫x⋅x1dx.Parts: .uv−∫vdu.
.xlnx−∫1dx=xlnx−x+C.x⋅x1=1 for ,x>0, and .∫1dx=x+C.
xlnx−x+CCheck: .(xlnx−x)′=lnx+x⋅x1−1=lnx.
Problem 5
∫xcosxdx
,u=x,;dv=cosxdx;,du=dx,.v=sinx.Differentiating x removes it, and cosx integrates to sinx without getting harder.
Call the integral .I=∫exsinxdx.Neither factor gets simpler when differentiated, so parts will not finish the job; the plan is to apply parts twice until I reappears, then solve for it.
,u=sinx,;dv=exdx;,du=cosxdx,.v=ex.ex integrates to itself, so v stays as simple as .dv.
.I=exsinx−∫excosxdx.Parts: .uv−∫vdu.
For :∫excosxdx:,u=cosx,;dv=exdx;,du=−sinxdx,.v=ex.Keep the same choice, trig as u and the exponential as .dv. Swapping it would integrate the cosx back to sinx and undo step 3, giving only .I=I.
.∫excosxdx=excosx−∫ex(−sinx)dx=excosx+I.Parts again; the minus from du turns the new integral into .+I.
.I=exsinx−excosx−I.Substitute step 5 into step 3. The original integral now appears on both sides.
.2I=ex(sinx−cosx).Add I to both sides and factor out .ex. The constants of integration from the two applications of parts are gathered into one C in the final line.
21ex(sinx−cosx)+CDivide by 2. Check: .(21ex(sinx−cosx))′=21ex(sinx−cosx)+21ex(cosx+sinx)=exsinx.
Problem 7
∫011+x2dx
y=arctanx means tany=x with .−2π<y<2π.arctan is the inverse of tan on ,(−2π,2π), where cosy>0 and tan is increasing, so each x has exactly one .y.
.cos2y1y′=1.Differentiate tany=x with respect to :x: the chain rule gives the derivative of tan at ,y, which is 1/cos2y (quotient rule on ),siny/cosy), times .y′.
.y′=cos2y=1+tan2y1=1+x21.,1+tan2y=cos2ycos2y+sin2y=cos2y1, and .tany=x.
.∫011+x2dx=[arctanx]01=arctan1−arctan0.Step 3 makes arctanx an antiderivative of the integrand, and a definite integral is the antiderivative's value at the upper limit minus its value at the lower one.
arctan1=4π and .arctan0=0.tan4π=1 and ,tan0=0, and both angles lie in .(−2π,2π).
4π.4π−0. The integrand lies between 21 and 1 on ,[0,1], and 4π≈0.785 is between them.
Problem 8
∫tanxdx
,∫tanxdx=∫cosxsinxdx, on an interval where .cosx=0.tanx is defined only where ;cosx=0; written as a quotient, the numerator is, up to sign, the derivative of the denominator.
,u=cosx,,du=−sinxdx, so .sinxdx=−du.;(cosx)′=−sinx; the minus sign has to be carried into the integral.
.∫cosxsinxdx=∫u−du=−ln∣u∣+C.∫du/u=ln∣u∣+C for ;u=0; the absolute value is needed because cosx is negative on half of the intervals where tanx is defined.
−ln∣cosx∣+CPut u=cosx back. Check: where ,cosx>0, the chain rule gives ;dxdlncosx=cosx−sinx=−tanx; where ,cosx<0, it gives .dxdln(−cosx)=−cosxsinx=−tanx. Either way the minus sign in front makes the derivative .tanx.
Problem 9
∫0∞xe−xdx
.∫0∞xe−xdx=b→∞lim∫0bxe−xdx.The upper limit is not a number, so the integral is defined as the limit of integrals over .[0,b].
,u=x,;dv=e−xdx;,du=dx,.v=−e−x.Differentiating x removes it; (−e−x)′=e−x by the chain rule.
.∫0bxe−xdx=[−xe−x]0b+∫0be−xdx.Parts on :[0,b]:,[uv]0b−∫0bvdu, and .−v=e−x.
[−xe−x]0b=−be−b−0 and .∫0be−xdx=[−e−x]0b=1−e−b.Evaluate each bracket at b and at 0; at x=0 the first bracket is .0⋅e0=0.
.∫0bxe−xdx=1−e−b−be−b.Add the two parts of step 4.
0<be−b=ebb<b2/2b=b2 for ,b>0, so .be−b→0.eb=1+b+2b2+⋯>2b2 for ,b>0, since every term of the series is positive; the bound 2/b goes to 0.
1Take b→∞ in step 5: e−b→0 and, by step 6, .be−b→0. This is the mean of the exponential distribution with rate 1.
Problem 10
∫σ(x)dx where ,σ(x)=1+e−x1, and then .∫−∞0σ(x)dx.
.σ(x)=1+exex.Multiply top and bottom by ,ex, which is never 0, so that the numerator becomes the derivative of the denominator.
,u=1+ex,.du=exdx.The denominator's derivative, ,ex, is the numerator.
.∫1+exexdx=∫udu=ln∣u∣+C.Substitute step 2.
.∫σ(x)dx=ln(1+ex)+C.Put u=1+ex back; ,1+ex>1, so the absolute value can be dropped. This is softplus, whose derivative is σ (Differentiation rules, Problem 4).
.∫−∞0σ(x)dx=a→−∞lim∫a0σ(x)dx=a→−∞lim(ln2−ln(1+ea)).The lower limit is not a number, so the integral is a limit; step 4 evaluated at 0 gives ,ln2, since ,1+e0=2, and at a gives .ln(1+ea).
ln(1+ea)→ln1=0 as .a→−∞.,ea→0, and ln is continuous at 1.
;ln(1+ex)+C; and ∫−∞0σ=ln2−a→−∞limln(1+ea)=ln2Steps 4 to 6. The area is finite although σ never reaches 0, because σ(x)<ex decays exponentially as .x→−∞.
Where this goes wrong
1. Substituting without changing dx
Setting u=x2 turns ex2 into eu at a glance, and the rest of the integrand is easy to wave through.
∫xex2dx with u=x2Right so far: the substitution of Problem 1.
“ex2 becomes ,eu, and xdx becomes .du.”The shortcut that causes the mistake: xdx treated as the whole of .du.
∫xex2dx=∫eudu=ex2+C,du=2xdx, so ,xdx=21du, and the factor 21 is lost. Differentiating the answer shows it: ,(ex2)′=2xex2, twice the integrand. The correct antiderivative is .21ex2+C.
2. Parts with u and dv swapped
Parts works with either choice of u and dv in the sense that the formula stays true, so it is tempting to take the first factor that integrates easily.
∫xexdx by partsRight so far: a product of a polynomial and an exponential, the case parts is for.
“x integrates easily too, so either factor can be .dv.”The reasoning that causes the mistake: choosing dv by what can be integrated, without asking what the new integral will look like.
,u=ex,dv=xdx in ∫xexdxThis gives ,v=2x2,du=exdx and ∫xexdx=2x2ex−∫2x2exdx — true, but the new integral is harder than the old one, which is the sign that the choice is wrong. Pick u to be what gets simpler when differentiated: u=x gives (x−1)ex+C (Problem 3).
3. Sign error in ∫ tan
tanx=sinx/cosx looks like a derivative over a function, and ∫u′/u=ln∣u∣ is the pattern that comes to mind.
∫tanxdx=∫cosxsinxdx with u=cosxRight so far: the substitution of Problem 8.
“The numerator is the derivative of the denominator, so the answer is ln of the denominator.”The pattern that causes the mistake: sinx taken as the derivative of .cosx.
∫tanxdx=ln∣cosx∣+Cdu=−sinxdx brings a minus: ,sinxdx=−du, so the integral is .−ln∣cosx∣+C. Differentiating this line shows it: .(ln∣cosx∣)′=−tanx.
4. Changing the variable but keeping the old limits
A substitution in an indefinite integral changes only the integrand, and the habit carries over to definite integrals.
∫011+x22xdx with ,u=1+x2,du=2xdxRight so far: the substitution of Problem 2.
“The integrand becomes ;du/u; the rest stays.”The habit that causes the mistake: the limits, which are values of ,x, left in place.
∫011+x22xdx=∫01uduThe limits must be values of :u:u(0)=1 and ,u(1)=2, so the integral is .∫12du/u=ln2. With the old limits the integral diverges, because 1/u is not integrable near u=0 — yet the original integrand is continuous and bounded on ,[0,1], so its integral is finite.
5. Evaluating ∞ · 0 by feel
In Problem 9 the boundary term at infinity is ,x, which grows, times ,e−x, which shrinks, and it is tempting to call the product 0 and move on.
∫0∞xe−xdx=[−xe−x]0∞+∫0∞e−xdxRight so far as a plan: parts with ,u=x,,dv=e−xdx, as in Problem 9.
“At infinity e−x is 0, so −xe−x is 0 there.”The reasoning that causes the mistake: ∞⋅0 read as 0.
[−xe−x]0∞=0−0The value happens to be right here, because be−b→0 (Problem 9, step 6), but the line asserts it without a limit, and ∞⋅0 is not a value: ,b⋅b1→1, while .b⋅b−1/2→∞. The same shortcut on ,∫1∞x⋅21x−3/2dx, by parts with u=x and ,v=−x−1/2, calls the boundary term [−x⋅x−1/2]1∞ zero at infinity, but at b it is ,−b→−∞, and that integral diverges. Writing limb→∞ is where the answer and the convergence are decided.