Trading Dev AcademyFree quant education

Free lesson · Integral calculus

Integration techniques: substitution and integration by parts

Open interactive lessonPractice calculationsExplore labs

Start with the idea

  • Substitution reverses the chain rule.
  • Integration by parts reverses the product rule.
  • Both techniques transform an integral into a form you already know rather than changing its mathematical value.
Symbols, units & horizon
  • u=g(x): substituted inner variable, or the chosen factor in integration by parts
  • du=g′(x)dx: its differential
  • dv=v′(x)dx: differential of the other factor
  • [uv]ₐᵇ: u(b)v(b)−u(a)v(a)
  • a,b: original bounds
  • g(a),g(b): transformed bounds
  • f: outer integrand after substitution

When and why to use this

Use substitution when an inner function and its derivative appear together; use integration by parts for products such as a polynomial times an exponential. Verify the transformed domain.

  • For substitution, choose an inner expression u=g(x) whose derivative appears as another factor.
  • Change the differential and, for a definite integral, the bounds too.
  • Do not mix x-bounds with a u-integrand.
  • For integration by parts, choose u and dv so that differentiating u simplifies it and integrating dv is feasible.
  • The technique rearranges one unknown integral into a boundary term and another integral.
  • It does not guarantee the new integral is easier.
∫abf(g(x))g′(x)dx=∫g(a)g(b)f(u)du,∫abudv=[uv]ab−∫abvdu
Calculus: derivation and arithmetic

Integration techniques: substitution and integration by parts

  1. For ∫012xex2dx, set u=x2 and du=2xdx. The transformed endpoints are still 0 and 1.
  2. Substitute and integrate: ∫01eudu=[eu]01=e−1. Differentiate ex2 to check the original integrand.
  3. The product rule is (uv)′=u′v+uv′. Integrating yields [uv]ab=∫abvdu+∫abudv. Subtract the first integral to obtain integration by parts.
  4. For ∫01xexdx, choose u=x, dv=exdx, so du=dx, v=ex. Substitute: [xex]01−∫01exdx=e−(e−1)=1.
Work it by hand

Check the indefinite answers by differentiation: derivative of exp(x²) is 2x exp(x²), and derivative of (x−1)exp(x) is x exp(x).

An analogy to remember

Substitution is changing the unit on a ruler while also changing the interval labels. Integration by parts transfers some of the work from one factor to the other.

How this becomes a building block

Substitution underlies transformations between distributions and simplifications of discounting integrals. Integration by parts appears in expectation identities and continuous cash-flow manipulations. These operations often simplify one term within a larger pricing or risk calculation.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

from math import exp

def integrate_2x_exp_square(a,b):
    return exp(b*b)-exp(a*a)

def integrate_x_exp(a,b):
    primitive=lambda x:(x-1)*exp(x)
    return primitive(b)-primitive(a)

print(integrate_2x_exp_square(0,1),integrate_x_exp(0,1))

Continue learning

Integral Calculus: Accumulation & Area — all lessons
  1. Start with rectangles: rate × time = amount
  2. Definite integrals: adding many small contributions
  3. Core integral rules: undo a derivative, then check
  4. Antiderivatives and the fundamental theorem
  5. Integration techniques: substitution and integration by parts
  6. Improper integrals, densities and continuous expectations
  7. Numerical integration and a continuous cash-flow building block

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations