Steply

Integrate ∫ x^2 cos x dx

Step by step, with the reason for every step · Integration by parts · Calculus 2

Step by step

The question

Question: find the integral of x² cos x.

∫ x2 cos x dx =

1 Choose u and dv

Choose u = x²: its derivative is simpler.

dv is the rest: cos x dx, which we can integrate.

u = x2, dv = cos x dx

2 Find du and v

du: the derivative of u, times dx.

v: the integral of dv.

cos gives sin.

du = 2x dx, v = sin x

3 Use the rule

The rule: the integral of u dv is u v, minus the integral of v du.

It comes from the product rule, backwards.

∫ u dv = uv − ∫ v du

u times v, minus the integral of v times du.

= x2 sin x − ∫ 2x sin x dx

Careful!

It is u v minus the integral of v du.

Not plus!

Careful: not uv + ∫ v du ✗

4 Parts again

The new integral has x in it again: parts again.

Choose u = 2x: its derivative is simpler, just a number.

dv is the rest: sin x dx, which we can integrate.

u = 2x, dv = sin x dx

5 Find du and v

du: the derivative of u, times dx.

v: the integral of dv.

sin gives minus cos.

du = 2 dx, v = −cos x

6 Use the rule

u times v, minus the integral of v times du.

∫ 2x sin x dx = −2x cos x − ∫ (−2 cos x) dx

7 The new integral

The new integral is easy: just a number times cos.

cos integrates to sin.

= −2x cos x − (−2 sin x)

Open the bracket.

= −2x cos x + 2 sin x

Put that back in its place.

= x2 sin x − (−2x cos x + 2 sin x)

Open the bracket: a minus in front of a bracket changes the sign of every part inside.

Add C.

So the answer is x² sin x + 2x cos x − 2 sin x + C.

= x2 sin x + 2x cos x − 2 sin x + C

8 Check

Let's check: take the derivative of our answer.

The product rule on each term: the first's slope times the second, plus the first times the second's slope.

derivative: 2x sin x + x2 cos x + 2 cos x − 2x sin x − 2 cos x

The other terms cancel, and we get x² cos x: the question again.

Right!

= x2 cos x

Let's look back.

First: choose u and dv.

Then: find du and v.

Then: use the rule.

Then: parts again.

Then: find du and v.

Then: use the rule.

Then: the new integral.

Last: check.

Answer
= x2 sin x + 2x cos x − 2 sin x + C

Your turn

Try this one yourself, then check:

∫ 4x2 sin x dx
Show the answer
−4x2 cos x + 8x sin x + 8 cos x + C

More from Integration by parts

The whole lesson: Integration by parts →