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

Example 21: ∫exsin⁡x dx\int e^x\sin x\,dx

ExamplesIntegration by parts · Section 7.6
The question

Find

∫exsin⁡x dx\int e^x\sin x\,dx
Exam answer

Let I=∫exsin⁡x dxI = \displaystyle\int e^x\sin x\,dx⁠.

Taking exe^x as the first function, by parts:

I=ex(−cos⁡x)−∫ex(−cos⁡x) dx=−excos⁡x+∫excos⁡x dx…(i)\begin{aligned} I &= e^x(-\cos x) \\ &\quad - \int e^x(-\cos x)\,dx \\ &= -e^x\cos x \\ &\quad + \int e^x\cos x\,dx\quad\ldots(\text{i}) \end{aligned}

Again by parts, with exe^x as the first function:

∫excos⁡x dx=exsin⁡x−∫exsin⁡x dx=exsin⁡x−I…(ii)\begin{aligned} &\int e^x\cos x\,dx \\ &= e^x\sin x \\ &\quad - \int e^x\sin x\,dx \\ &= e^x\sin x - I\quad\ldots(\text{ii}) \end{aligned}

Using (ii) in (i):

I=−excos⁡x+exsin⁡x−I⇒ 2I=ex(sin⁡x−cos⁡x)\begin{aligned} I &= -e^x\cos x + e^x\sin x - I \\ \Rightarrow\ 2I &= e^x(\sin x - \cos x) \end{aligned}

∴ I=ex2(sin⁡x−cos⁡x)+C\therefore\ I = \dfrac{e^x}{2}(\sin x - \cos x) + C⁠.

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

The one idea this problem is built on

Neither factor ever disappears: exe^x stays exe^x⁠, and sin⁡x\sin x cycles through cos⁡x\cos x⁠, −sin⁡x-\sin x⁠, −cos⁡x-\cos x⁠. So integrating by parts once gives ∫excos⁡x dx\int e^x\cos x\,dx⁠, and integrating by parts again brings back ∫exsin⁡x dx\int e^x\sin x\,dx⁠, the integral we started with. Calling it II⁠, we get an equation for II⁠, and we simply solve it.

Given, to find, and the plan
Given
exsin⁡xe^x\sin x⁠, defined and continuous for every real xx⁠.
To find
I=∫exsin⁡x dxI = \int e^x\sin x\,dx⁠.
Plan
(1) By parts once (exe^x first, sin⁡x\sin x second), giving I1=∫excos⁡x dxI_1 = \int e^x\cos x\,dx⁠. (2) By parts on I1I_1 with the same kind of choice. (3) Substitute and solve for II⁠. (4) See why the choice must be kept. (5) Differentiate back.

Basics you need

1Integration by parts

∫fg dx=f∫g dx−∫[f′∫g dx]dx\int f g\,dx = f\int g\,dx - \int\big[f'\int g\,dx\big]dx (Section 7.6). Lesson: integration by parts

2Derivatives and integrals that cycle

ddxex=ex\frac{d}{dx}e^x = e^x⁠; ∫sin⁡x dx=−cos⁡x\int\sin x\,dx = -\cos x⁠, ∫cos⁡x dx=sin⁡x\int\cos x\,dx = \sin x (standard formulae (iii) and (ii)). Basics: trigonometric functions

3Antiderivatives differ by constants

Two antiderivatives of the same function differ by a constant (Section 7.2), so an equation between indefinite integrals holds "up to a constant"; the constant is added at the end. Basics: integration undoes differentiation

Solution

  1. Integrate by parts once

    Take exe^x as the first function and sin⁡x\sin x as the second. Then the derivative of the first is exe^x and the integral of the second is −cos⁡x-\cos x⁠:

    I=∫exsin⁡x dx=ex(−cos⁡x)−∫ex(−cos⁡x) dx=−excos⁡x+∫excos⁡x dx.\begin{aligned} I = \int e^x\sin x\,dx &= e^x(-\cos x) - \int e^x(-\cos x)\,dx \\ &= -e^x\cos x + \int e^x\cos x\,dx. \end{aligned}

    Write I1=∫excos⁡x dxI_1 = \int e^x\cos x\,dx⁠, so

    I=−excos⁡x+I1.(1)I = -e^x\cos x + I_1. \qquad (1)
    Here neither choice makes the integral simpler; it only turns sin⁡x\sin x into cos⁡x\cos x⁠. That is fine: the point is to do it twice and come back to II⁠.
    ∫sin⁡x dx=−cos⁡x\int\sin x\,dx = -\cos x (formula (iii)). Lesson: integration by parts
  2. Integrate I1I_1 by parts, keeping exe^x as the first function

    Now exe^x is first and cos⁡x\cos x second; the integral of cos⁡x\cos x is sin⁡x\sin x⁠:

    I1=∫excos⁡x dx=exsin⁡x−∫exsin⁡x dx=exsin⁡x−I.\begin{aligned} I_1 = \int e^x\cos x\,dx &= e^x\sin x - \int e^x\sin x\,dx \\ &= e^x\sin x - I. \end{aligned}
    The last integral is exactly the original II⁠. That is not a failure; it is what makes the method work, because now II appears on both sides of an equation.
    ∫cos⁡x dx=sin⁡x\int\cos x\,dx = \sin x (formula (ii)). Lesson: integration by parts
  3. Substitute and solve for II

    Put I1=exsin⁡x−II_1 = e^x\sin x - I into (1):

    I=−excos⁡x+exsin⁡x−I.I = -e^x\cos x + e^x\sin x - I.

    Add II to both sides:

    2I=ex(sin⁡x−cos⁡x),2I = e^x(\sin x - \cos x), I=∫exsin⁡x dx=ex2(sin⁡x−cos⁡x)+C.I = \int e^x\sin x\,dx = \frac{e^x}{2}(\sin x - \cos x) + C.
    We treat II like an unknown in an ordinary linear equation. Strictly, each ∫\int stands for an antiderivative, determined only up to a constant, so the equation holds up to a constant; that is why one arbitrary constant CC is added after solving.
    Solving I=a−II = a - I gives I=a2I = \frac a2⁠. Basics: integration undoes differentiation
  4. Why the choice must be kept the second time

    Suppose in Step 2 we had switched, taking cos⁡x\cos x first and exe^x second. Then

    I1=cos⁡x⋅ex−∫(−sin⁡x) ex dx=excos⁡x+I,\begin{aligned} I_1 &= \cos x\cdot e^x - \int(-\sin x)\,e^x\,dx \\ &= e^x\cos x + I, \end{aligned}

    and (1) would become I=−excos⁡x+excos⁡x+II = -e^x\cos x + e^x\cos x + I⁠, that is I=II = I⁠: true, but useless.

    Switching the roles in the second round simply undoes the first round. Keep the same type of function (here the exponential) as the first function both times. The book also notes that taking sin⁡x\sin x first and exe^x second in both rounds works equally well and gives the same answer.
    Integration by parts is the product rule read backwards; applying it forwards and then backwards returns to the start. Lesson: integration by parts
  5. Check: differentiate the answer

    ddx[ex2(sin⁡x−cos⁡x)]=ex2(sin⁡x−cos⁡x)+ex2(cos⁡x+sin⁡x)=ex2⋅2sin⁡x=exsin⁡x.\begin{aligned} &\frac{d}{dx}\left[\frac{e^x}{2}(\sin x - \cos x)\right] \\ &= \frac{e^x}{2}(\sin x - \cos x) + \frac{e^x}{2}(\cos x + \sin x) \\ &= \frac{e^x}{2}\cdot 2\sin x = e^x\sin x. \end{aligned}
    By the product rule: exe^x differentiates to itself, and sin⁡x−cos⁡x\sin x - \cos x differentiates to cos⁡x+sin⁡x\cos x + \sin x⁠. The cosines cancel and the sines add, giving exactly the integrand for every real xx⁠.
    Product rule; ddxsin⁡x=cos⁡x\frac{d}{dx}\sin x = \cos x⁠, ddxcos⁡x=−sin⁡x\frac{d}{dx}\cos x = -\sin x⁠. Basics: integration undoes differentiation
Result ∫exsin⁡x dx=ex2(sin⁡x−cos⁡x)+C,\int e^x\sin x\,dx = \frac{e^x}{2}(\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=π2x = \frac\pi2⁠: the integrand is eπ/2⋅1=4.8104773809…e^{\pi/2}\cdot 1 = 4.8104773809\ldots⁠; the derivative from Step 5 is eπ/22(1−0)+eπ/22(0+1)\frac{e^{\pi/2}}{2}(1 - 0) + \frac{e^{\pi/2}}{2}(0 + 1)⁠, the same value.

Over an interval. On [0,π][0, \pi]⁠:

F(π)−F(0)=eπ2(0+1)−12(0−1)=eπ+12≈12.0703463164\begin{aligned} F(\pi) - F(0) &= \frac{e^\pi}{2}(0 + 1) - \frac12(0 - 1) \\ &= \frac{e^\pi + 1}{2} \approx 12.0703463164 \end{aligned}

Numerical integration of exsin⁡xe^x\sin x over [0,π][0, \pi] gives 12.070346316412.0703463164 to ten decimal places, the same.

Common mistakes
  1. Switching the first and second functions in the second round. You get I=II = I (Step 4).
  2. Thinking the method has failed when II reappears. Move it to the left side and solve.
  3. Sign slips. ∫sin⁡x dx=−cos⁡x\int\sin x\,dx = -\cos x⁠, so the first round gives −excos⁡x+∫excos⁡x dx-e^x\cos x + \int e^x\cos x\,dx⁠, with a plus in front of the integral.
  4. Forgetting to divide by 2 after collecting 2I2I⁠.
What to take away
  1. For eaxsin⁡bxe^{ax}\sin bx or eaxcos⁡bxe^{ax}\cos bx⁠: integrate by parts twice with the same choice, then solve the equation for II⁠.
  2. ∫exsin⁡x dx=ex2(sin⁡x−cos⁡x)+C\int e^x\sin x\,dx = \frac{e^x}{2}(\sin x - \cos x) + C⁠; similarly ∫excos⁡x dx=ex2(sin⁡x+cos⁡x)+C\int e^x\cos x\,dx = \frac{e^x}{2}(\sin x + \cos x) + C⁠.

Every fact used, and where it comes from

FactUsed inSource
Integration by partsSteps 1, 2, 4Section 7.6 (Lesson: integration by parts)
∫sin⁡x dx=−cos⁡x+C\int\sin x\,dx = -\cos x + C⁠; ∫cos⁡x dx=sin⁡x+C\int\cos x\,dx = \sin x + CSteps 1, 2Standard formulae (iii), (ii), Section 7.2
Antiderivatives differ by a constantStep 3Section 7.2
Product rule; derivatives of exe^x⁠, sin⁡x\sin x⁠, cos⁡x\cos xStep 5Chapter 5
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 →