Skip to content
Tutorials Center
My learning

Topics

Lesson 19 of 68 ยท Integrals

Integration Techniques

Master the main integration techniques: u-substitution, integration by parts, partial fractions and trig substitution, and learn when sympy beats hand work.

Differentiation is mechanical: with the product, quotient and chain rules, any formula you can write can be differentiated. Integration is an art. There is no rule that always works, and many perfectly ordinary functions, like e**(-x**2), have no antiderivative in terms of elementary functions at all.

What you do have is a small set of techniques that cover most practical cases. Each one is a derivative rule played backwards. This lesson shows when to reach for which, and then shows how sympy can do the grind while you do the thinking.

flowchart TD
    Q["Look at the integrand"] --> S{"Inner function and its derivative both present?"}
    S -->|"yes"| U["u-substitution"]
    S -->|"no"| P{"Product of two different kinds?"}
    P -->|"yes"| IBP["Integration by parts"]
    P -->|"no"| R{"Rational function?"}
    R -->|"yes"| PF["Partial fractions"]
    R -->|"no"| T["Trig substitution or a table"]

A rough decision path. Techniques often combine.

The standard table and the basic rules

Every technique below ends by reducing your integral to entries of a short table, so it pays to know the table well. The indefinite integral integral of f(x) dx stands for all antiderivatives of f, and because any two antiderivatives of the same function differ by a constant, you write the family as F(x) + C, where C is the constant of integration. Leave out the C and the answer is incomplete; a definite integral needs no C, because it cancels in F(b) - F(a) (see The Fundamental Theorem of Calculus).

Each row is a derivative rule read backwards (see Differentiation Rules and Derivatives of Exponentials, Logarithms and Trig Functions). In the table, a is a positive constant and C is omitted to save space.

Integrand Antiderivative
x**n (n != -1) x**(n+1) / (n+1)
1/x ln abs(x)
e**(a x) e**(a x) / a
a**x (a != 1) a**x / ln a
sin(a x) -cos(a x) / a
cos(a x) sin(a x) / a
1 / cos(x)**2 tan x
tan x -ln abs(cos x)
sinh x cosh x
1 / (a**2 + x**2) (1/a) arctan(x/a)
1 / sqrt(a**2 - x**2) arcsin(x/a)
ln x x ln x - x

The last row is not a reversed rule but a result of integration by parts, shown below. The absolute value in ln abs(x) matters: 1/x is also defined for negative x, and ln abs(x) has slope 1/x on both sides of zero.

Three properties let you break complicated integrals into table pieces:

  • Constant multiple: the integral of k f(x) is k times the integral of f(x).
  • Sum and difference: the integral of f(x) + g(x) is the integral of f(x) plus the integral of g(x). Together with the first rule this is linearity.
  • Derivative undoes integral: d/dx (integral of f(x) dx) = f(x), and integral of F'(x) dx = F(x) + C.

Notice what is missing: there is no product rule or quotient rule for integrals. The integral of a product is not the product of the integrals, and the integral of f g has no simple formula. That gap is why integration by parts, substitution and partial fractions exist.

Python Verify the table by differentiating each answer

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Every row passes its derivative check, and the numeric slope of ln abs(x) at x = -2 is -0.5, matching 1/x. The check is the key habit: if you are ever unsure of an antiderivative, differentiate it. Many more entries (for example, sec x, 1/sqrt(x**2 + a**2) and 1/(x**2 - a**2)) can be derived with the techniques in the rest of this lesson, and sympy confirms any table entry you doubt.

u-substitution: the chain rule backwards

If the integrand contains a function g(x) together with its derivative g'(x), set u = g(x), so du = g'(x) dx. The integral becomes simpler in u.

Example: the integral of 2x * cos(x**2) dx. Let u = x**2, so du = 2x dx. The integral becomes the integral of cos(u) du = sin(u) + C = sin(x**2) + C.

For definite integrals you can change the limits to match u, so you never convert back. The integral of 2x*cos(x**2) from 0 to sqrt(pi) becomes the integral of cos(u) from u = 0 to u = pi, which equals sin(pi) - sin(0) = 0.

Python Substitution checked by sympy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For x * e**(x**2) you need du = 2x dx, so the integrand is half of e**u du, giving e**(x**2)/2. Constant factors are fixed by multiplying and dividing.

Integration by parts: the product rule backwards

The product rule (u*v)' = u'*v + u*v' integrates to

integral of u dv = u*v - integral of v du

Choose u to be the piece that gets simpler when differentiated, and dv the piece you can integrate. A common memory aid is LIATE: Logarithmic, Inverse trig, Algebraic, Trigonometric, Exponential. Pick u from the earliest type in that list.

For x * e**x: let u = x (algebraic) and dv = e**x dx. Then du = dx and v = e**x, so

integral = x*e**x - integral of e**x dx = (x - 1)*e**x + C

For ln(x), a trick: let u = ln(x) and dv = dx. Then v = x and du = dx/x, so the integral is x*ln(x) - x + C.

Python Parts, including repeated parts

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The last one, e**x * sin(x), is a classic: parts twice returns the original integral, and you solve algebraically for it, giving e**x*(sin(x) - cos(x))/2.

Partial fractions: pulling a rational function apart

A rational function such as (3x + 5)/((x + 1)(x + 2)) is hard to integrate as written but easy as a sum of simple pieces:

(3x + 5)/((x + 1)(x + 2)) = A/(x + 1) + B/(x + 2)

Multiply through and compare, or substitute the roots. At x = -1: 2 = A*1, so A = 2. At x = -2: -1 = B*(-1), so B = 1. The integral is then 2*ln|x + 1| + ln|x + 2| + C.

If the numerator's degree is at least the denominator's, do polynomial long division first. Repeated factors like (x - 1)**2 need a term for each power, and irreducible quadratics need a linear numerator.

Python apart() splits fractions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Trig substitution: removing square roots

Radicals of the form sqrt(a**2 - x**2), sqrt(a**2 + x**2) and sqrt(x**2 - a**2) suggest a substitution that uses a Pythagorean identity to cancel the root:

Expression Substitution Identity used
sqrt(a**2 - x**2) x = a*sin(t) 1 - sin**2 = cos**2
sqrt(a**2 + x**2) x = a*tan(t) 1 + tan**2 = sec**2
sqrt(x**2 - a**2) x = a*sec(t) sec**2 - 1 = tan**2

Take the area of a quarter circle: the integral of sqrt(1 - x**2) from 0 to 1. With x = sin(t), dx = cos(t) dt, the integrand becomes cos(t)**2, and the limits become t = 0 to pi/2. The result is pi/4, one quarter of the circle's area pi.

Python Quarter circle by trig substitution

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The numeric value is slightly below pi/4 = 0.7853981... because the curve is very steep at x = 1, a hint of numerical trouble examined in Numerical Integration.

When sympy beats hand work, and when it does not

Let sympy handle long algebra, repeated parts and big partial-fraction problems. Use it to check your hand answer: differentiate your result and compare, as shown in The Fundamental Theorem of Calculus.

But know the limits. Some integrals have no closed form; the Gaussian e**(-x**2) has an antiderivative only through the special function erf. When sympy returns an unevaluated Integral(...), or a special function, it is telling you to switch to a numerical method. And a symbolic answer can be huge and unreadable even when correct; a number plus an error estimate is often more useful.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which technique is the best first attempt for the integral of x*cos(x**2) dx?

    The inner function x2 has derivative 2x, and an x factor is present. Substituting u = x2 turns the integral into cos(u)/2 du.
  2. 2. In integration by parts, what do you want from the choice of u?

    Differentiating u should simplify the new integral. LIATE is a reminder, with algebraic terms like x often a good u.
  3. 3. What must you do before partial fractions if the numerator's degree is at least the denominator's?

    Partial fractions apply to proper fractions. Long division leaves a polynomial plus a proper fraction.
  4. 4. Which substitution suits sqrt(4 - x**2)?

    With x = 2sin(t), 4 - x**2 = 4cos(t)**2, so the root simplifies to 2*cos(t).

Summary

  • u-substitution reverses the chain rule; change the limits too when the integral is definite.
  • Integration by parts reverses the product rule: integral of u dv = u*v - integral of v du.
  • Partial fractions split a proper rational function into simple terms that integrate to logs and arctans.
  • Trig substitution removes square-root expressions using Pythagorean identities.
  • Use sympy for the algebra and for checks, and a numerical method when no closed form exists.

Next: Numerical Integration.