AP Calculus BC

Integral of x cos x: Answer, Parts, Mistakes

The integral of x cos x with respect to x is cos x + x sin x + C. Integration by parts with u = x and dv = cos x dx gives x sin x minus the integral of sin x, so the answer is x sin x + cos x + C. Differentiating it with the product rule returns x cos x.

xcosxdx=cosx+xsinx+C\int x\cos x\,dx = \cos x + x\sin x + C

How to integrate x cos x by parts

The integrand pairs an algebraic factor with a trig factor, and neither is the derivative of the other, so substitution stalls and integration by parts takes over. Parts is the reverse of the product rule.

udv=uvvdu\int u\,dv = uv - \int v\,du

Let uu be the factor that simplifies when differentiated. Here xx becomes 11, while cosx\cos x only cycles, so take u=xu = x and dv=cosxdxdv = \cos x\,dx.

u=x,du=dx,dv=cosxdx,v=sinxu = x, \quad du = dx, \quad dv = \cos x\,dx, \quad v = \sin x

Substitute. The uvuv term is xsinxx\sin x, and the new integral vdu=sinxdx\int v\,du = \int \sin x\,dx is elementary.

xcosxdx=xsinxsinxdx=xsinx+cosx+C\int x\cos x\,dx = x\sin x - \int \sin x\,dx = x\sin x + \cos x + C

Written with the cosine first, that is cosx+xsinx+C\cos x + x\sin x + C.

Check it by differentiating

Differentiate cosx+xsinx\cos x + x\sin x: sinx+[sinx+xcosx]=sinx+sinx+xcosx=xcosx-\sin x + \left[\sin x + x\cos x\right] = -\sin x + \sin x + x\cos x = x\cos x. The sine terms cancel and the integrand comes back.

Why u = x, plus a definite example

Parts pays off only when vdu\int v\,du is simpler. Taking u=cosxu = \cos x and dv=xdxdv = x\,dx makes v=x22v = \frac{x^2}{2} and raises the power, so the leftover integral is worse than the original. LIATE confirms the choice: the algebraic xx outranks the trig cosx\cos x, so u=xu = x.

0π/2xcosxdx=[cosx+xsinx]0π/2=(0+π2)(1+0)=π21\int_{0}^{\pi/2} x\cos x\,dx = \left[\cos x + x\sin x\right]_{0}^{\pi/2} = \left(0 + \frac{\pi}{2}\right) - (1 + 0) = \frac{\pi}{2} - 1

This is a Topic 6.11 integration by parts problem in Unit 6, which weights 15 to 20 percent of the exam. Its close relative xsinxdx=sinxxcosx+C\int x\sin x\,dx = \sin x - x\cos x + C uses the same setup with the roles of sine and cosine swapped.

Common mistakes with the integral of x cos x

  • Multiplying antiderivatives. There is no product rule for integrals, so sinxx22\sin x \cdot \frac{x^2}{2} is not the answer.
  • Getting the sign of vv wrong. Antidifferentiating cosx\cos x gives v=sinxv = \sin x; it is differentiating that flips the sign, not antidifferentiating.
  • Dropping the minus before vdu\int v\,du and writing xsinxcosx+Cx\sin x - \cos x + C. Differentiate to check and the error shows up at once.
  • Choosing u=cosxu = \cos x. Legal but self-defeating, since v=x22v = \frac{x^2}{2} makes the remaining integral harder.

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 is the integral of x cos x?

It is cosx+xsinx+C\cos x + x\sin x + C, equivalently xsinx+cosx+Cx\sin x + \cos x + C. Integration by parts with u=xu = x and dv=cosxdxdv = \cos x\,dx gives xsinxsinxdx=xsinx+cosx+Cx\sin x - \int \sin x\,dx = x\sin x + \cos x + C.

Why does x cos x need integration by parts?

Because it is a product of two unrelated factors. Neither xx nor cosx\cos x is the derivative of the other, so substitution has nothing to cancel. Parts reverses the product rule and reduces xcosxx\cos x to the elementary integral of sinx\sin x.

What is the definite integral of x cos x from 0 to pi/2?

It equals π21\frac{\pi}{2} - 1. Evaluate cosx+xsinx\cos x + x\sin x: at x=π2x = \frac{\pi}{2} it is 0+π20 + \frac{\pi}{2}, and at x=0x = 0 it is 11, so the difference is π21\frac{\pi}{2} - 1.