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: ∫x⋅cos(x)dx

This video shows how to find the antiderivative of x*cos(x) using integration by parts. It assigns f(x)=x and g'(x)=cos(x), making f'(x)=1 and g(x)=sin(x). The formula becomes x*sin(x) - ∫sin(x)dx, which simplifies to x*sin(x) + cos(x) + C. Created by Sal Khan.

Want to join the conversation?

  • blobby green style avatar for user paymahn
    Sal, firstly thanks for all these videos. Im really getting alot from them!

    Secondly, in the final solution for this video, why is the Constant C not negative? Shouldn't the subtraction reverse the sign? I got: x*sinx+cosx-C.

    Correct me if Im wrong please. I'm always making errors on the signs and I want to understand why
    (65 votes)
    Default Khan Academy avatar avatar for user
    • piceratops seed style avatar for user sachchit123
      The sign for C doesn't really matter as much to the solution of the problem because either way you will get the right equation. Because C is just a constant of integration it is usually put as +C because if the constant is supposed to be negative then you will get C= -3 and if you put -C you will get C=3, which are both the same answers. Not sure if you got it, I explained it as well as I could.
      (18 votes)
  • purple pi purple style avatar for user Nishant
    Is integration by parts same thing as using [uv - INTEGRAL(vdu)]?
    (18 votes)
    Default Khan Academy avatar avatar for user
  • leafers tree style avatar for user SConstable978
    At and onwards, how come the 1 in "anti-deriv: 1+sinx" isnt accounted for? shouldn't its anti-derivative be x?
    (12 votes)
    Default Khan Academy avatar avatar for user
  • spunky sam blue style avatar for user Chunmun
    What is the antiderivative of x ?
    (0 votes)
    Default Khan Academy avatar avatar for user
  • leaf blue style avatar for user kumar.aks99
    Would you still get the same answer even if you assigned the more complicated values to f(x) and the simpler values to g(x)?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Daniel Schneider
      I'm not exactly sure what you mean by "values." Are you asking if you'd get the same answer if you switched your choices of function for f(x) and g'(x)? The short answer is no--it basically results in a more complicated integral than the one you started with (Sal references this around -), which makes the problem worse! So you do have to be careful with your choices. The good news is that if you choose the wrong functions (which will be readily apparent when you see the resulting integral), then you can just go back and choose the other combination. Does that help?
      (13 votes)
  • leaf green style avatar for user adityankane921
    I have seen techniques to solve integration , but i am still confused about use of integration . what is use of it !
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf blue style avatar for user Stefen
      There are so many uses
      There are some great examples here:
      http://www.intmath.com/applications-integration/applications-integrals-intro.php

      When I am not helping on Khan, I like to work in my recording and music production studio. An effect that gets used a lot in music production is called reverb. Reverb is essentially echos, but the echos are so close together, your ear hears them as one sound and not as distinct replications. The current state of reverb technology now allows you to take a special type of sample, called an impulse response, of an environment you for which you like the reverb, for example, the Sydney Opera House and then, using a process called convolution, a signal, such as a voice that was recorded without reverb, can be transformed by the convolution process using the Sydney Opera House impulse response to produce a voice that has the exact same reverb quality as if it were recorded there! And, you may have guessed it, the convolution algorithm uses integration!
      https://en.wikipedia.org/wiki/Convolution#Definition
      Here is the website of the makers of the reverb I like to use: https://www.audioease.com/altiverb/

      So for me, the process of integration is used on a daily basis!
      (14 votes)
  • piceratops ultimate style avatar for user Raphaël Dunant
    At , isnt the antiderivative of cos(x), sin(x)+c ? Why didn't Sal added the constant ?
    Thank-you for your answer
    (4 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user Jesse
      Technically, there is an arbitrary constant at this point, but it is never used in practice. The reason is that there is still an indefinite integral in the expression. When you perform that integration, you will get another arbitrary constant. The sum of two arbitrary constants is again an arbitrary constant, so the one at would be unnecessary.
      (9 votes)
  • leaf green style avatar for user Mariam Suri
    What do we do if it is the anti-derivative of xcos5xdx? Would the answer be xsinx + cos5x + C?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Matthew Kuo
      it would be (1/5)xsin5x + (1/25)cos5x + C.
      If we assign f(x) to x and g'(x) to cos5x then f(x) is x, f'(x) is 1, g(x) is (1/5)sin5x, and g'(x) is cos5x. g(x) is (1/5)*sin5x because the derivative of that is 5(1/5)cos5x which is just cos5x, the original g'(x). Therefore, when we plug it all back into the formula, we get x(1/5)sin5x - antiderivative of (1(1/5)*sin5x). The antiderivative of (1/5)*sin5x is just (1/25)*-cos5x by the same method that I used earlier. After evaluating the antiderivative, I get (1/5)xsin5x + (1/25)cos5x + C.
      (10 votes)
  • male robot hal style avatar for user Enn
    Can Integration by Parts be used whenever the integral of the product of any two functions have to be determined ?
    Such as can the integral of the expression x√(2x+3) be found by integration by parts ?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Just Keith
      Yes, but it is not necessarily the easiest method. Sometimes, no matter what you pick as f and what you pick as g, you won't get something easy to integrate.

      For more difficult problems, you may have to apply multiple techniques -- you might need to use parts, u sub and trig sub all mixed together.

      So, unfortunately, there is not a simple, works every time, procedure. In fact, there are some seemingly simple-looking integrals that no one has ever solved.

      For example, ∫ (x^x) dx has no known solution with a finite number of terms.
      (5 votes)
  • starky ultimate style avatar for user Amr Saber
    Mr. sal how do I integrate some thing complicated like
    f(x)=(x²+5x+2)^7 * (3x²+4x-3)^5 ?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Just Keith
      Yes, you do have to expand it out. There isn't a nifty trick to get around that, AFAIK. I have done the expansion, but not the integration. Here is what (x²+5x+2)^7 * (3x²+4x-3)^5 expands out to:
      243x^24 + 10125x^23 + 190782x^22 + 2146320x^21 + 16021392x^20 + 83306224x^19 + 307462580x^18 + 801041036x^17 + 1415351830x^16 + 1484141906x^15 + 365199968x^14 - 1298344660x^13 - 1744602848x^12 - 491343800x^11 + 752887052x^10 + 682621828x^9 + 25150015x^8 - 208849223x^7 - 79943230x^6 + 17032052x^5 + 17080584x^4 + 2251440x^3 - 959904x^2 - 336960x - 31104
      (6 votes)

Video transcript

In the last video, I claimed that this formula would come handy for solving or for figuring out the antiderivative of a class of functions. Let's see if that really is the case. So let's say I want to take the antiderivative of x times cosine of x dx. Now if you look at this formula right over here, you want to assign part of this to f of x and some part of it to g prime of x. And the question is, well do I assign f of x to x and g prime of x to cosine of x or the other way around? Do I make f of x cosine of x and g prime of x, x? And that thing to realize is to look at the other part of the formula and realize that you're essentially going to have to solve this right over here. And here where we have the derivative of f of x times g of x. So what you want to do is assign f of x so that the derivative of f of x is actually simpler than f of x. And assign g prime of x that, if you were to take its antiderivative, it doesn't really become any more complicated. So in this case, if we assign f of x to be equal to x, f prime of x is definitely simpler, f prime of x is equal to 1. If we assign g prime of x to be cosine of x, once again, if we take its antiderivative, that sine of x, it's not any more complicated. If we did it the other way around, if we set f of x to be cosine of x, then we're taking its derivative here. That's not that much more complicated. But if we set g prime of x equaling to x and then we had to take its antiderivative, we get x squared over 2, that is more complicated. So let me make it clear over here. We are assigning f of x to be equal to x. And that means that the derivative of f is going to be equal to 1. We are assigning-- I'll write it right here-- g prime of x to be equal to cosine of x, which means g of x is equal to sine of x, the antiderivative of cosine of x. Now let's see, given these assumptions, let's see if we can apply this formula. So this has all of this. Let's see, the right-hand side says f of x times g of x. So f of x is x. g of x is sine of x. And then from that, we are going to subtract the antiderivative of f prime of x-- well, that's just 1-- times g of x, times sine of x dx. Now this was a huge simplification. Now I went from trying to solve the antiderivative of x cosine of x to now I just have to find the antiderivative of sine of x. And we know the antiderivative of sine of x dx is just equal to negative cosine of x. And of course, we can throw the plus c in now, now that we're pretty done with taking all of our antiderivatives. So all of this is going to be equal to x sine of x, x times sine of x, minus the antiderivative of this, which is just negative cosine of x. And then we could throw in a plus c right at the end of it. And doesn't matter if we subtract a c or add the c. We're saying this is some arbitrary constant which could even be negative. And so this is all going to be equal to-- we get our drum roll now-- it's going to be x times sine of x, subtract a negative, that becomes a positive, plus cosine of x plus c. And we are done. We were able to take the antiderivative of something that we didn't know how to take the antiderivative of before. That was pretty interesting.