Class 12 Maths, Worked in Full Past papersGet updates
Chapter 7 · Integrals

Example 17: ∫xcos⁡x dx\int x\cos x\,dx

ExamplesIntegration by parts · Section 7.6
The question

Find

∫xcos⁡x dx\int x\cos x\,dx
Exam answer

Let I=∫xcos⁡x dxI = \displaystyle\int x\cos x\,dx⁠.

Taking xx as the first function and cos⁡x\cos x as the second, by parts:

I=xsin⁡x−∫1⋅sin⁡x dx=xsin⁡x−(−cos⁡x)+C\begin{aligned} I &= x\sin x - \int 1\cdot\sin x\,dx \\ &= x\sin x - (-\cos x) + C \end{aligned}

∴ I=xsin⁡x+cos⁡x+C\therefore\ I = x\sin x + \cos x + C⁠.

Want the reason behind every step, the basics and the checks?

The one idea this problem is built on

The integrand is a product of two functions, and no basic formula fits it. Integration by parts trades ∫xcos⁡x dx\int x\cos x\,dx for a new integral in which xx has been differentiated (to 1) while cos⁡x\cos x has been integrated (to sin⁡x\sin x⁠). Differentiating xx makes it simpler, and integrating cos⁡x\cos x does not make it harder, so the new integral, ∫sin⁡x dx\int \sin x\,dx⁠, is easy. Choosing the two functions the other way round would make things worse.

Given, to find, and the plan
Given
The integrand xcos⁡xx\cos x⁠, defined and continuous for every real xx⁠.
To find
∫xcos⁡x dx\int x\cos x\,dx⁠.
Plan
(1) Recall the integration by parts formula. (2) Choose the first and second functions. (3) Apply the formula. (4) See what the opposite choice does. (5) See why no constant is needed for the integral of the second function. (6) Differentiate back.

Basics you need

1Integration by parts

From the product rule ddx(uv)=udvdx+vdudx\frac{d}{dx}(uv) = u\frac{dv}{dx} + v\frac{du}{dx}⁠, integrating both sides gives (Section 7.6, equation (1))

∫udvdx dx=uv−∫vdudx dx.\int u\frac{dv}{dx}\,dx = uv - \int v\frac{du}{dx}\,dx.

With u=f(x)u = f(x) as the first function and dvdx=g(x)\frac{dv}{dx} = g(x) as the second:

∫f(x) g(x) dx=f(x)∫g(x) dx−∫[f′(x)∫g(x) dx]dx.\begin{aligned} \int f(x)\,g(x)\,dx &= f(x)\int g(x)\,dx \\ &\quad - \int\Big[f'(x)\int g(x)\,dx\Big]dx. \end{aligned}

Lesson: integration by parts

2Two basic integrals

Standard formulae (ii) and (iii): ∫cos⁡x dx=sin⁡x+C\int\cos x\,dx = \sin x + C and ∫sin⁡x dx=−cos⁡x+C\int\sin x\,dx = -\cos x + C⁠. Basics: trigonometric functions

3The product rule

(fg)′=f′g+fg′(fg)' = f'g + fg'⁠, used for the final check. Basics: integration undoes differentiation

Solution

  1. Why integration by parts?

    xcos⁡xx\cos x is a product of an algebraic function (xx⁠) and a trigonometric one (cos⁡x\cos x⁠). It is not in the list of standard formulae, it is not a sum we can split, and no simple substitution turns it into a standard form. Integration by parts is the method designed for exactly this kind of product.

    The formula comes from reading the product rule backwards: since (uv)′=uv′+vu′(uv)' = uv' + vu'⁠, the integral of one of the two products, uv′uv'⁠, can be traded for the integral of the other, vu′vu'⁠. It helps when the second integral is easier than the first.
    Section 7.6: "the integral of the product of two functions = (first function) × (integral of the second function) − integral of [(differential coefficient of the first function) × (integral of the second function)]". Lesson: integration by parts
  2. Choose the first and second functions

    Take

    f(x)=x  (first),g(x)=cos⁡x  (second).f(x) = x \ \ (\text{first}), \qquad g(x) = \cos x \ \ (\text{second}).

    Then f′(x)=1f'(x) = 1 and ∫g(x) dx=sin⁡x\int g(x)\,dx = \sin x⁠.

    The first function gets differentiated, the second gets integrated. Differentiating xx turns it into the constant 1, which removes the troublesome factor; integrating cos⁡x\cos x just gives sin⁡x\sin x⁠, no harder. This is the book's Remark (iii): a power of xx or a polynomial is usually taken as the first function.
    ddxx=1\frac{d}{dx}x = 1⁠; ∫cos⁡x dx=sin⁡x+C\int\cos x\,dx = \sin x + C (formula (ii)). Basics: powers of x
  3. Apply the formula

    ∫xcos⁡x dx=x∫cos⁡x dx−∫[ddx(x)∫cos⁡x dx]dx=xsin⁡x−∫1⋅sin⁡x dx=xsin⁡x−(−cos⁡x)+C=xsin⁡x+cos⁡x+C.\begin{aligned} \int x\cos x\,dx &= x\int\cos x\,dx - \int\Big[\frac{d}{dx}(x)\int\cos x\,dx\Big]dx \\ &= x\sin x - \int 1\cdot\sin x\,dx \\ &= x\sin x - (-\cos x) + C \\ &= x\sin x + \cos x + C. \end{aligned}
    After one use of the formula the remaining integral is ∫sin⁡x dx\int\sin x\,dx⁠, a standard one. The minus in front of it and the minus in ∫sin⁡x dx=−cos⁡x\int\sin x\,dx = -\cos x multiply to give +cos⁡x+\cos x⁠.
    ∫sin⁡x dx=−cos⁡x+C\int\sin x\,dx = -\cos x + C (formula (iii)). Basics: trigonometric functions
  4. What the opposite choice would do

    Suppose instead f(x)=cos⁡xf(x) = \cos x (first) and g(x)=xg(x) = x (second). Then f′(x)=−sin⁡xf'(x) = -\sin x and ∫x dx=x22\int x\,dx = \frac{x^2}{2}⁠, so

    ∫xcos⁡x dx=cos⁡x⋅x22−∫(−sin⁡x)x22 dx=x22cos⁡x+∫x22sin⁡x dx.\begin{aligned} \int x\cos x\,dx &= \cos x\cdot\frac{x^2}{2} - \int(-\sin x)\frac{x^2}{2}\,dx \\ &= \frac{x^2}{2}\cos x + \int\frac{x^2}{2}\sin x\,dx. \end{aligned}

    This is true, but the new integral contains x2x^2 instead of xx⁠: it is harder than the one we started with.

    Integrating xx raises its power, so the algebraic factor grows instead of disappearing. The formula is always correct; the choice only decides whether it is useful. That is why the order of the two functions matters.
    ∫x dx=x22+C\int x\,dx = \frac{x^2}{2} + C (power rule, formula (i)). Lesson: integration by parts
  5. Why no constant in ∫cos⁡x dx\int\cos x\,dx

    In Step 3 we wrote ∫cos⁡x dx=sin⁡x\int\cos x\,dx = \sin x⁠, without a constant. If we used sin⁡x+k\sin x + k for any constant kk⁠:

    ∫xcos⁡x dx=x(sin⁡x+k)−∫(sin⁡x+k) dx=xsin⁡x+kx+cos⁡x−kx+C=xsin⁡x+cos⁡x+C.\begin{aligned} \int x\cos x\,dx &= x(\sin x + k) - \int(\sin x + k)\,dx \\ &= x\sin x + kx + \cos x - kx + C \\ &= x\sin x + \cos x + C. \end{aligned}

    The kk terms cancel, so adding a constant there changes nothing.

    This is the book's Remark (ii). The extra kxkx from the first part is removed by −∫k dx=−kx-\int k\,dx = -kx from the second part. Only one constant, CC⁠, is needed, at the very end.
    ∫k dx=kx+C\int k\,dx = kx + C⁠. Lesson: integration by parts
  6. Check: differentiate the answer

    By the product rule, ddx(xsin⁡x)=1⋅sin⁡x+xcos⁡x\frac{d}{dx}(x\sin x) = 1\cdot\sin x + x\cos x⁠. So

    ddx(xsin⁡x+cos⁡x)=sin⁡x+xcos⁡x−sin⁡x=xcos⁡x.\begin{aligned} \frac{d}{dx}\big(x\sin x + \cos x\big) &= \sin x + x\cos x - \sin x \\ &= x\cos x. \end{aligned}
    The derivative is the integrand, for every real xx⁠. Integration by parts is the product rule run backwards, so it is natural that the product rule confirms the answer.
    Product rule; ddxcos⁡x=−sin⁡x\frac{d}{dx}\cos x = -\sin x⁠. Basics: integration undoes differentiation
Result ∫xcos⁡x dx=xsin⁡x+cos⁡x+C,\int x\cos x\,dx = x\sin x + \cos x + C,

valid for every real xx⁠. This is the book's answer.

Check it with numbers

At a point. At x=1x = 1⁠: the integrand is cos⁡1=0.5403023…\cos 1 = 0.5403023\ldots⁠; the derivative of our answer is sin⁡1+cos⁡1−sin⁡1\sin 1 + \cos 1 - \sin 1⁠, the same 0.5403023…0.5403023\ldots

Over an interval. On [0,π2]\left[0, \frac\pi2\right]⁠:

F(π2)−F(0)=(π2+0)−(0+1)=π2−1≈0.5707963268\begin{aligned} F\left(\tfrac\pi2\right) - F(0) &= \left(\tfrac\pi2 + 0\right) - (0 + 1) \\ &= \tfrac\pi2 - 1 \approx 0.5707963268 \end{aligned}

Numerical integration of xcos⁡xx\cos x over [0,π2]\left[0, \frac\pi2\right] gives 0.57079632680.5707963268 to ten decimal places, the same.

Common mistakes
  1. Choosing cos⁡x\cos x as the first function. The new integral gets harder (Step 4).
  2. Sign of the last term. −∫sin⁡x dx=+cos⁡x-\int\sin x\,dx = +\cos x⁠, not −cos⁡x-\cos x⁠.
  3. Writing ∫xcos⁡x dx=∫x dx⋅∫cos⁡x dx\int x\cos x\,dx = \int x\,dx\cdot\int\cos x\,dx⁠. The integral of a product is not the product of the integrals: x22sin⁡x\frac{x^2}{2}\sin x differentiates to something else.
What to take away
  1. By parts: first function differentiated, second integrated. Choose the first so that differentiating simplifies it.
  2. No constant is needed when integrating the second function; add one CC at the end.
  3. Integration by parts does not finish every product. The book's Remark (i) gives ∫xsin⁡x dx\int\sqrt{x}\sin x\,dx⁠. Strictly, xsin⁡x\sqrt{x}\sin x does have antiderivatives on x≥0x \ge 0⁠: it is continuous there, and by Theorem 1 of Section 7.8.2 (stated in the book without proof) its area function is one. What is true is that no antiderivative can be written with the functions of this chapter (a result beyond this book), so no choice of first and second function finishes it.

Every fact used, and where it comes from

FactUsed inSource
Integration by parts formulaSteps 1, 3, 4, 5Section 7.6, equation (1) and the rule after it (Lesson: integration by parts)
Choice of first function (polynomial first)Step 2Remark (iii) after Example 17, Section 7.6
No constant needed for ∫g dx\int g\,dxStep 5Remark (ii) after Example 17, Section 7.6
∫cos⁡x dx=sin⁡x+C\int\cos x\,dx = \sin x + C⁠; ∫sin⁡x dx=−cos⁡x+C\int\sin x\,dx = -\cos x + C⁠; ∫xndx\int x^n dxSteps 3, 4Standard formulae (ii), (iii), (i), Section 7.2
Product ruleSteps 1, 6Chapter 5, Section 5.3
A continuous function has an antiderivative (its area function)Take-away 3First fundamental theorem (Theorem 1), Section 7.8.2, stated without proof
xsin⁡x\sqrt{x}\sin x has no antiderivative built from the functions of this chapterTake-away 3Beyond this book (stated, not proved)
Found an error, or want more?

Tell us if something on this page is wrong or unclear, or if you would like a fuller explanation, another method or a new feature. Send feedback on this problem →