Integration by parts is another technique for simplifying integrands. As we saw in previous posts, each differentiation rule has a corresponding integration rule. In the case of integration by parts, the corresponding differentiation rule is the Product Rule. The technique of integration by parts allows us to simplify integrands of the form: ∫f(x)g(x)dx
Examples of this form include: ∫xcosx dx,∫excosx dx,∫x2ex dx
As integration by parts is the product rule applied to integrals, it helps to state the Product Rule again. The Product Rule is defined as: ddx[f(x)g(x)]=f′(x)g(x)+f(x)g′(x)
When we apply the product rule to indefinite integrals, we can restate the rule as:
∫ddx[f(x)g(x)] dx=∫[f′g(x)+f(x)g′(x)] dxThen, rearranging so we get f(x)g′(x) dx on the left side of the equation:
∫f(x)g′(x) dx=∫ddx[f(x)g(x)] dx−∫f′(x)g(x) dxWhich gives us the integration by parts formula! The formula is typically written in differential form:
∫u dv=uv−∫v duExamples¶
The following examples walkthrough several problems that can be solved using integration by parts. We also employ the wonderful SymPy package for symbolic computation to confirm our answers. To use SymPy later to verify our answers, we load the modules we will require and initialize several variables for use with the SymPy library.
from sympy import symbols, limit, diff, sin, cos, log, tan, sqrt, init_printing, plot, integrate
from mpmath import ln, e, pi, cosh, sinh
init_printing()
x = symbols('x')
y = symbols('y')
Example 1: Evaluate the integrand ∫xsinx2 dx
Recalling the differential form of the integration by parts formula, ∫u dv=uv−∫v du, we set u=x and dv=sinx2
Solving for the derivative of u, we arrive at du=1 dx=dx. Next, we find the antiderivative of dv. To find this antiderivative, we employ the Substitution Rule.
u=12x,du=12 dx,dudx=2y=sinu,dy=−cosu du,dydu=−cosuTherefore, v=−2cosx2
Entering these into the integration by parts formula:
−2xcosx2−(−2)∫cosx2Then, solving for the integrand ∫cosx2, we employ the Substitution Rule again as before to arrive at 2sinx2 (the steps in solving this integrand are the same as before when we solved for ∫sinx2). Thus, the integral is evaluated as:
−2xcosx2+4sinx2+CUsing SymPy's integrate
, we can verify our answer is correct (SymPy does not include the constant of integration C).
integrate(x * sin(x / 2), x)
Example 2: Evaluate ∫t2cost dt
We start by setting u=t2 and dv=cost. The derivative of t2 is 2t, thus du=2t dt, or dudt=2t. Integrating dv=cost gives us v=sint du. Entering these into the integration by parts formula:
t2sint−2∫tsintTherefore, we must do another round of integration by parts to solve ∫tsint.
u=t,du=dtdv=sint,v=−cost du
Putting these together into the integration by parts formula with the above:
t2sint−2(−tcost+∫cost dt)Which gives us the solution:
t2sint+2tcost−2sint+CAs before, we can verify that our answer is correct by leveraging SymPy.
t = symbols('t')
integrate(t ** 2 * cos(t), t)
Example 3: ∫xex dx
Here, we set u=x and dv=ex. Therefore, du=dx and v=ex dx. Putting these together in the integration by parts formula:
xex−∫exAs the integral of ex is just ex, our answer is:
xex−ex+CWe can again verify our answer is accurate using SymPy.
integrate(x * e ** x, x)