AP Calculus BC

Integral of x sec^2 x: Parts Then tan x

Parts with u equal to x turns sec squared x into tan x, and what is left over is the integral of tan x, which has to be done separately. The answer is x tan x plus the natural log of the absolute value of cos x, plus C.

xsec2xdx=xtanx+lncosx+C\int x\sec^{2}x\,dx = x\tan x + \ln\left|\cos x\right| + C

Parts, with tan x waiting at the end

Take u=xu = x and dv=sec2xdxdv = \sec^{2}x\,dx. Then du=dxdu = dx and v=tanxv = \tan x, since sec2x\sec^{2}x is the derivative of tangent. Parts turns the product into a finished piece and a leftover integral.

xsec2xdx=xtanxtanxdx\int x\sec^{2}x\,dx = x\tan x - \int \tan x\,dx

That leftover is not free. tanxdx=lncosx\int \tan x\,dx = -\ln\left|\cos x\right|, which is its own substitution problem with u=cosxu = \cos x. Subtracting that negative is where the plus sign in the final answer comes from.

xsec2xdx=xtanx+lncosx+C\int x\sec^{2}x\,dx = x\tan x + \ln\left|\cos x\right| + C

One problem, two techniques

Parts does not finish this integral. It converts the problem into a smaller one, and you have to recognise the smaller one on sight. Free response questions lean on exactly this: a first move that succeeds only if a second standard result is already in memory.

The absolute value bars matter here. cosx\cos x is negative on half of its period, and the antiderivative breaks at every odd multiple of π2\frac{\pi}{2}, where sec2x\sec^{2}x blows up. The formula is valid on one such interval at a time, and the constant of integration can differ from one interval to the next.

A quick derivative check

Differentiating x tan x by the product rule gives tan x plus x sec^2 x. Differentiating ln|cos x| gives negative tan x. The two tangent terms cancel and you are left with x sec^2 x, which is the point.

The mistakes students make

Almost every wrong answer on this integral comes from the second half of the work, not the first.

  • Writing tanxdx=lncosx\int \tan x\,dx = \ln\left|\cos x\right| with no minus sign. The answer becomes xtanxlncosxx\tan x - \ln\left|\cos x\right|, which differentiates to xsec2x+2tanxx\sec^{2}x + 2\tan x.
  • Choosing u=sec2xu = \sec^{2}x and dv=xdxdv = x\,dx. The leftover integral is x2sec2xtanxdx\int x^{2}\sec^{2}x\tan x\,dx, which is harder than the original.
  • Dropping the absolute value bars and writing ln(cosx)\ln\left(\cos x\right), which is undefined on any interval where cosine is negative.

Every answer on this page is machine checked

An automated test differentiates the antiderivative above and confirms it returns the integrand. A wrong sign or a missing factor fails the build, so it cannot reach you.

Frequently asked questions

What does x sec^2 x integrate to?

To xtanx+lncosx+Cx\tan x + \ln\left|\cos x\right| + C.

Why does the answer have a plus ln|cos x| and not a minus?

Parts leaves tanxdx-\int \tan x\,dx, and tanxdx=lncosx\int \tan x\,dx = -\ln\left|\cos x\right|. Subtracting that negative gives +lncosx+\ln\left|\cos x\right|.

Can I use u-substitution instead of parts?

No. Nothing in xsec2xx\sec^{2}x is the derivative of anything else in it, so substitution has nothing to cancel. The factor xx is what signals parts.