Previous Up Next

6.20.5  Integration by parts

Recall the integration by parts formula:

u(x)v′(x)dx = u(x)v(x)−v(x)u′(x)dx.  

If you want to integrate a function f(x) by parts, you need to specify how to write f(x) as u(x)v′(x), which you can do by either specifying u(x) or v(x). The result will be in the form F(x) + ∫g(x)dx, where F(x)=u(x)v(x) and g(x)=−v(x)u′(x).

In some cases, to finish an integral you need to integrate by parts more than once. After one integrating by parts once and getting F(x) + ∫g(x)dx, you may have to integrate ∫g(x) dx by parts and add F(x) to the result.

Xcas has two commands for integrating by parts: ibpdv (where you specify v(x)) and ibpu (where you specify u(x)), both of which return the result as a list [F(x),g(x)]. Both of these commands allow you to keep track of the function F(x) you may need to add to the result of a subsequent integration by parts.

ibpdv

The ibpdv command is used to search the primitive of an expression written as u(x)v′(x) by specifying v(x).

Hence, ibpdv returns the terms computed in an integration by parts, with the possibility of doing several ibpdvs successively.
When the answer of ibpdv(u(x)*v’(x),v(x)) is computed, to obtain a primitive of u(x) v′(x), it remains to compute the integral of the second term of this answer and then to sum this integral with the first term of this answer: to do this, just use ibpdv command with the answer as first argument and a new v(x) (or 0 to terminate the integration) as second argument.


Example.
Input:

ibpdv(ln(x),x)

Output:


x lnx,−1

then:

ibpdv([x*ln(x),-1],0)

or:

ibpdv(ans(),0)

Output:

x+x lnx

Remark.
When the first argument of ibpdv is a list of two elements, ibpdv works only on the last element of this list and adds the integrated term to the first element of this list. (therefore it is possible to do several ibpdvs successively).


Example. To evaluate ∫(ln(x))2dx:
Input:

ibpdv((ln(x))^2,x)

Output:


x ln2x,−2 lnx

It remains to integrate -(2*ln(x)):
Input:

ibpdv([x*(ln(x))^2,-(2*log(x))],x)

or:

ibpdv(ans(),x)

Output:


x ln2x−2 x lnx,2

And now it remains to integrate 2:
Input:

ibpdv([x*(ln(x))^2+x*(-(2*log(x))),2],0)

or:

ibpdv(ans(),0)

Output:

x ln2x−2 x lnx+2 x

ibpu

The ibpu command is used to search the primitive of an expression written as u(x)v′(x) by specifying u(x).

Hence, ibpu returns the terms computed in an integration by parts, with the possibility of doing several ibpus successively.
When the answer of ibpu(u(x)*v’(x),u(x)) is computed, to obtain a primitive of u(x) v′(x), it remains to compute the integral of the second term of this answer and then to sum this integral with the first term of this answer: to do this, just use the ibpu command with the answer as first argument and a new u(x) (or 0 to terminate the integration) as second argument.


Example.
Input:

ibpu(ln(x),ln(x))

Output:


x lnx,−1

then:

ibpu([x*ln(x),-1],0)

or:

ibpu(ans(),0)

Output:

x+x lnx


Remark.
When the first argument of ibpu is a list of two elements, ibpu works only on the last element of this list and adds the integrated term to the first element of this list. Therefore it is possible to do several ibpus successively, similarly to how you can do several ibpdvs successively.


Example.
To evaluate ∫(ln(x))2dx:
Input:

ibpu((ln(x))^2,(ln(x))^2)

Output:


x ln2x,−2 lnx

It remains to integrate -(2*ln(x)):
Input:

ibpu([x*(ln(x))^2,-(2*ln(x))],ln(x))

or:

ibpu(ans(),ln(x))

Output:


x ln2x−2 x lnx,2

Finally, it remains to integrate 2: Input:

ibpu([x*(ln(x))^2+x*(-(2*ln(x))),2],0)

or:

ibpu(ans(),0)

Output:

x ln2x−2 x lnx+2 x

Previous Up Next