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.

∫xcos⁡x dx=cos⁡x+xsin⁡x+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.

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

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

u=x,du=dx,dv=cos⁡x dx,v=sin⁡xu = x, \quad du = dx, \quad dv = \cos x\,dx, \quad v = \sin x

Substitute. The uvuv term is xsin⁡xx\sin x, and the new integral ∫v du=∫sin⁡x dx\int v\,du = \int \sin x\,dx is elementary.

∫xcos⁡x dx=xsin⁡x−∫sin⁡x dx=xsin⁡x+cos⁡x+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 cos⁡x+xsin⁡x+C\cos x + x\sin x + C.

Check it by differentiating

Differentiate cos⁡x+xsin⁡x\cos x + x\sin x: −sin⁡x+[sin⁡x+xcos⁡x]=−sin⁡x+sin⁡x+xcos⁡x=xcos⁡x-\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 ∫v du\int v\,du is simpler. Taking u=cos⁡xu = \cos x and dv=x dxdv = 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 cos⁡x\cos x, so u=xu = x.

∫0π/2xcos⁡x dx=[cos⁡x+xsin⁡x]0π/2=(0+π2)−(1+0)=π2−1\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 ∫xsin⁡x dx=sin⁡x−xcos⁡x+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 sin⁡x⋅x22\sin x \cdot \frac{x^2}{2} is not the answer.
  • Getting the sign of vv wrong. Antidifferentiating cos⁡x\cos x gives v=sin⁡xv = \sin x; it is differentiating that flips the sign, not antidifferentiating.
  • Dropping the minus before ∫v du\int v\,du and writing xsin⁡x−cos⁡x+Cx\sin x - \cos x + C. Differentiate to check and the error shows up at once.
  • Choosing u=cos⁡xu = \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 cos⁡x+xsin⁡x+C\cos x + x\sin x + C, equivalently xsin⁡x+cos⁡x+Cx\sin x + \cos x + C. Integration by parts with u=xu = x and dv=cos⁡x dxdv = \cos x\,dx gives xsin⁡x−∫sin⁡x dx=xsin⁡x+cos⁡x+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 cos⁡x\cos x is the derivative of the other, so substitution has nothing to cancel. Parts reverses the product rule and reduces xcos⁡xx\cos x to the elementary integral of sin⁡x\sin x.

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

It equals π2−1\frac{\pi}{2} - 1. Evaluate cos⁡x+xsin⁡x\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 π2−1\frac{\pi}{2} - 1.