How to use integration by parts three times

With a polynomial times a trig function, one round of integration by parts can leave us with another product. The next product is easier because differentiating the polynomial lowers its degree. We’ll repeat that until the integral is just a trig function.

Choose the part whose derivative gets simpler

Use ∫udv=uv-∫vdu. For ∫x3cosxdx, set u=x3 and dv=cosxdx.

x3sinx-3∫x2sinxdx

Apply the rule to the two remaining products

For ∫x2sinxdx, use u=x2 and v=-cosx. Carry that minus sign into the expression.

x3sinx+3x2cosx-6∫xcosxdx

The last application gives ∫xcosxdx=xsinx+cosx+C. Putting everything together gives

x3sinx+3x2cosx-6xsinx-6cosx+C

Differentiating the answer cancels the lower-degree terms and leaves x3cosx.