# integrateByParts

Integration by parts

Since R2019b

## Description

example

G = integrateByParts(F,du) applies integration by parts to the integrals in F, in which the differential du is integrated. For more information, see Integration by Parts.

When specifying the integrals in F, you can return the unevaluated form of the integrals by using the int function with the 'Hold' option set to true. You can then use integrateByParts to show the steps of integration by parts.

## Examples

collapse all

Create a symbolic expression F that is the integral of a product of functions.

syms u(x) v(x)
F = int(u*diff(v))
F(x) =

Apply integration by parts to F.

g = integrateByParts(F,diff(u))
g =

Apply integration by parts to the integral $\int {\mathit{x}}^{2}\text{\hspace{0.17em}}{\mathit{e}}^{\mathit{x}}\mathit{dx}$.

Define the integral using the int function. Show the result without evaluating the integral by setting the 'Hold' option to true.

syms x
F = int(x^2*exp(x),'Hold',true)
F =

To show the steps of integration, apply integration by parts to F and use exp(x) as the differential to be integrated.

G = integrateByParts(F,exp(x))
G =

H = integrateByParts(G,exp(x))
H =

Evaluate the integral in H by using the release function to ignore the 'Hold' option.

F1 = release(H)
F1 = $2 {\mathrm{e}}^{x}+{x}^{2} {\mathrm{e}}^{x}-2 x {\mathrm{e}}^{x}$

Compare the result to the integration result returned by the int function without setting the 'Hold' option to true.

F2 = int(x^2*exp(x))
F2 = ${\mathrm{e}}^{x} \left({x}^{2}-2 x+2\right)$

Apply integration by parts to the integral $\int {\mathit{e}}^{\mathit{ax}}\text{\hspace{0.17em}}\mathrm{sin}\left(\mathit{bx}\right)\text{\hspace{0.17em}}\mathit{dx}$.

Define the integral using the int function. Show the integral without evaluating it by setting the 'Hold' option to true.

syms x a b
F = int(exp(a*x)*sin(b*x),'Hold',true)
F =

To show the steps of integration, apply integration by parts to F and use ${\mathit{u}}^{\prime }\left(\mathit{x}\right)={\mathit{e}}^{\mathit{ax}}$ as the differential to be integrated.

G = integrateByParts(F,exp(a*x))
G =

Evaluate the integral in G by using the release function to ignore the 'Hold' option.

F1 = release(G)
F1 =

$\frac{{\mathrm{e}}^{a x} \mathrm{sin}\left(b x\right)}{a}-\frac{b {\mathrm{e}}^{a x} \left(a \mathrm{cos}\left(b x\right)+b \mathrm{sin}\left(b x\right)\right)}{a \left({a}^{2}+{b}^{2}\right)}$

Simplify the result.

F2 = simplify(F1)
F2 =

$-\frac{{\mathrm{e}}^{a x} \left(b \mathrm{cos}\left(b x\right)-a \mathrm{sin}\left(b x\right)\right)}{{a}^{2}+{b}^{2}}$

## Input Arguments

collapse all

Expression containing integrals, specified as a symbolic expression, function, vector, or matrix.

Example: int(u*diff(v))

Differential to be integrated, specified as a symbolic variable, expression, or function.

Example: diff(u)

collapse all

### Integration by Parts

Mathematically, the rule of integration by parts is formally defined for indefinite integrals as

$\int u\text{'}\left(x\right)\text{\hspace{0.17em}}v\left(x\right)\text{\hspace{0.17em}}dx=u\left(x\right)\text{\hspace{0.17em}}v\left(x\right)-\int u\left(x\right)\text{\hspace{0.17em}}v\text{'}\left(x\right)\text{\hspace{0.17em}}dx$

and for definite integrals as

$\underset{a}{\overset{b}{\int }}u\text{'}\left(x\right)\text{\hspace{0.17em}}v\left(x\right)\text{\hspace{0.17em}}dx=u\left(b\right)\text{\hspace{0.17em}}v\left(b\right)-u\left(a\right)\text{\hspace{0.17em}}v\left(a\right)-\underset{a}{\overset{b}{\int }}u\left(x\right)\text{\hspace{0.17em}}v\text{'}\left(x\right)\text{\hspace{0.17em}}dx.$

## Version History

Introduced in R2019b