If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Integration by parts: ∫𝑒ˣ⋅cos(x)dx

AP.CALC:
FUN‑6 (EU)
,
FUN‑6.E (LO)
,
FUN‑6.E.1 (EK)
Worked example of finding an indefinite integral by applying integration by parts twice, and then obtaining an equation for the desired indefinite integral. Created by Sal Khan.

Want to join the conversation?

  • leaf green style avatar for user Jacob Denson
    Could the answer be simplified to e^x/2, due to sin x + cos x = 1?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • spunky sam blue style avatar for user Chunmun
    Is the word integration means the same as antiderivatives ?
    (10 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Lucky
      Simon, you're correct, but I think your explanation is far too cumbersome to be of any help the person who may ask this kind of question.
      Simply put, yes. Integrating and finding the anti-derivative mean the same thing.
      (12 votes)
  • duskpin ultimate style avatar for user #1 βooκs ρroρonεnτ
    So taking derivatives of sin and cosine would end up in an infinite loop? i.e.
    Each entry is the derivative of the last.
    sinx , cosx, -sinx, - cosx , sinx ... until ∞
    (5 votes)
    Default Khan Academy avatar avatar for user
    • leaf red style avatar for user Blaze
      Yes, exactly.
      sin(x)
      cos(x)
      -sin(x)
      -cos(x)

      The interesting part about taking the derivative of sin(x) over and over and over is when you begin to have to solve dy^941/d^941x sin(x) = ?.

      (Also, a personal milestone, this is my 800th answer! Yay!)
      (21 votes)
  • leaf green style avatar for user HJ
    Is there a way to solve this problem with the tabular method?
    (6 votes)
    Default Khan Academy avatar avatar for user
  • leaf green style avatar for user Leonard Zuniga
    Can anybody please tell me why whenever I try to change which is f(x) and g'(x), the answer is different?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • female robot grace style avatar for user tyersome
      In this case the answer is the same, but in many cases one choice will make things more complicated and you will only get an answer by making a mistake!

      ADDENDUM: It is also important to note that the substitution that works for the second integration depends on what substitution you did in the first integration.
      (4 votes)
  • orange juice squid orange style avatar for user Samer Muhareb
    How would you integrate by parts for lets say, arc-cosine or arc-tangent?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Derek Edrich
      you would use the identity property of multiplication to make arccos into 1•arccos, then use integration by parts.
      ⌠arccosx dx=x•arccosx +⌠x/√(1-x²) dx (u=1-x²) = x•arccosx +(1/4)√(1-x²) + C
      ⌠arctanx dx=x•arctanx +⌠x/(1+x²) dx (u=1+x²) = x•arctanx + (1/2)ln|1+x²| + C
      or x•arctanx + ln|√(1+x²)| + C
      (7 votes)
  • piceratops ultimate style avatar for user André Spolaor
    Does anyone know a website with exercises of this topic?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user 龚震
    I am confused that why this question can't just leave it at integral by parts once, why need it twice? I mean, isn't the first time clear enough?
    (1 vote)
    Default Khan Academy avatar avatar for user
  • leafers tree style avatar for user RunasSudo
    Mathematica gives the answer as (e^x * cos(x))/(ln x). Is this correct (it probably is) and if so, how complicated is the simplification?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Kyri Nicolai
      I plotted them both and this is not correct (try x=8),
      f(8)=e^8*(sin(8)+cos(8))/2=1257. ....
      g(8)=(e^8 * cos(8))/(ln 8)=-208. ....

      The functions also behave differently at x=1, yours is very clearly 0 (due to the division by ln(0)=0, while Khans is very clearly about 1/2: (cos(1)*e^(1) / 2=0.5*2.7/2=0,7).

      in mathematica, make sure to press 'esc' 'e' 'e' and again 'esc' to enter the 'e' function. For Cos use 'Cos[x]' (so capital letter, and those square brackets).
      (3 votes)
  • leafers seed style avatar for user John Davidson
    So when you write out the second integration by parts equation and re-assign the f(x) and g'(x) values, does it make a difference which function you assign to f/g(x)?

    You initially assigned f(x) = e^x. Then the second time round you assigned f(x) = e^x AGAIN. When I did it the second time I assigned f(x) = sin(x) and then when you substitute back into the original equation it doesn't work out. If I assign f(x) = e^x the second time then it does work out.

    So my question is, how are you supposed to know which function you should assign to f(x) and which to g(x) the second time that you person the integration-by-parts procedure?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Matthew Chen
      Generally, you'd want to pick the same functions that you assigned the first time. I assume that for f(x), you chose a function that has a simple derivative, and for g'(x), you chose a function that has a simple antiderivative. For the most part, that's not going to change the second time.
      (1 vote)

Video transcript

Let's see if we can use integration by parts to find the antiderivative of e to the x cosine of x, dx. And whenever we talk about integration by parts, we always say, well, which of these functions-- we're taking a product of two of these-- which of these functions, either the x or cosine of x, that if I were to take its derivative, becomes simpler. And in this case neither of them become simpler. And neither of them become dramatically more complicated when I take their antiderivative. So here, it's kind of a toss up which one I assign to f of x and which one I assign to g prime of x. And actually, you can solve this problem either way. So let's just assign this one. Let's assign f of x equaling e to the x. And let's assign g prime of x as equaling cosine of x. So let me write it down. We are saying f of x is equal to e to the x, or f prime of x is equal to e to the x. Derivative of e to the x is just e to the x. And we can say that g-- we're making the assignment-- g prime of x is equal to cosine of x. And the antiderivative of that g of x is also. Or the antiderivative of cosine of x is just going to be equal to sine of x. So now let's apply integration by parts. So this thing is going to be equal to f of x times g of x, which is equal to e to the x times sine of x, minus the antiderivative of f prime of x-- f prime of x is e to the x. e to the x times g of x, which is once again, sine of x. Now, it doesn't look like we've made a lot of progress, now we have an indefinite integral that involves a sine of x. So let's see if we can solve that, let's see if we solve this one separately. So let's say if we were trying to find the antiderivative. The antiderivative of e to the x, sine of x dx. How could we do that? Well, similarly, we can set f of x as equal to e to the x. So, and now this is we're reassigning, although we're happening to make the exact same reassignment. So we're saying f of x is equal to e to the x. f prime of x is equal to just the derivative of that, which is still e to the x. And then we could say g of x, in this case, is equal to sine of x. We'll put these assignments in the back of our brain for now. And then-- let me make this clear-- g prime of x, let me, woops, there you go-- so we have g prime of x is equal to sine of x, which means that its antiderivative is negative cosine of x. Derivative of cosine is negative sine, derivative of negative cosine is positive sine. So once again, let's apply integration by parts. So we have f of x times g of x. f of x times g of x is negative-- is I'll put the negative out front-- it's negative e to the x times cosine of x, minus the antiderivative of f prime of xg of x. F prime of x is e to x. And then g of x is negative cosine of x. So I'll put the cosine of x right over here, and then the negative, we can take it out of the integral sign. And so we're subtracting a negative. That becomes a positive. And of course, we have our dx right over there. And you might say, Sal, we're not making any progress. This thing right over here, we now expressed in terms of an integral that was our original integral. We've come back full circle. But let's try to do something interesting. Let's substitute back this-- all right, let me write it this way. Let's substitute back this thing up here. Or actually, let me write it a different way. Let's substitute this for this in our original equation. And let's see if we got anything interesting. So what we'll get is our original integral, on the left hand side here. The indefinite integral or the antiderivative of e to the x cosine of x dx is equal to e to the x sine of x, minus all of this business. So let's just subtract all of this business. We're subtracting all of this. So if you subtract negative e to the x cosine of x, it's going to be positive. It's going to be positive e to the x, cosine of x. And then remember, we're subtracting all of this. So then we're going to subtract. So then we have minus the antiderivative of e to the x, cosine of x,dx. Now this is interesting. Just remember all we did is, we took this part right over here. We said, we used integration by parts to figure out that it's the same thing as this. So we substituted this back in. When you subtracted it. When you subtracted this from this, we got this business right over here. Now what's interesting here is we have essentially an equation where we have our expression, our original expression, twice. We could even assign this to a variable and essentially solve for that variable. So why don't we just add this thing to both sides of the equation? Let me make it clear. Let's just add the integral of e to the x cosine of x dx to both sides. e to the x, cosine of x, dx. And what do you get? Well, on the left hand side, you have two times our original integral. e to the x, cosine of x, dx is equal to all of this business. Is equal to this. I'll copy and paste it. So copy and paste. It's equal to all of that. And then this part, this part right over here, cancels out. And now we can solve for our original expression. The antiderivative of e to the x cosine of x dx. We just have to divide both sides of this, essentially an equation, by 2. So if you divide the left hand side by two, you're left with our original expression. The antiderivative of e to the x cosine of x dx. And on the right hand side you have what it must be equal to. e to the x sine of x, plus e to the x cosine of x over 2. And now we want to be careful because this is an antiderivative of our original expression, but it's not the only one. We always have to remember, even though we've worked hard and we've done-- we've used integration by parts twice. And we've had to back substitute in. We have to remember we should still have a constant here. So if you take the derivative of this business, regardless of what the constant is, you will get e to the x cosine of x. And it's actually a pretty neat looking expression.