Trigonometric Substitution
Square roots like describe circles, and integrals containing them (areas of circular segments, ellipses, arc lengths) resist ordinary substitution. Trigonometric substitution replaces with a trig function of a new variable so that a Pythagorean identity removes the root. This lesson explains the three standard substitutions, why they are legitimate (an inverse substitution needs an invertible map), and computes circle segment areas the way collision and anti-aliasing code does.
The three substitutions
| Expression | Substitution | Range of | Identity |
|---|---|---|---|
| or |
These are inverse substitutions: instead of setting , we set . The Substitution Rule still applies, read right to left, provided is one-to-one on the chosen range of (so that makes sense when we convert back). The ranges in the table are chosen so that is invertible and the root simplifies without absolute values: for with in , , so exactly.
Example: the area of an ellipse
The ellipse has upper half . By symmetry its area is . With , , limits and :
With this proves the circle's area is , from the definition of the integral rather than from a picture.
import sympy as sp
x, th = sp.symbols('x theta', real=True)
a, b = sp.symbols('a b', positive=True)
quarter = sp.integrate(a**2 * sp.cos(th)**2, (th, 0, sp.pi / 2)) # after x = a sin θ
print("∫_0^a √(a²−x²) dx =", quarter)
print("ellipse area =", sp.simplify(4 * b / a * quarter))
print("SymPy directly =", sp.integrate(4 * b / a * sp.sqrt(a**2 - x**2), (x, 0, a)))∫_0^a √(a²−x²) dx = pi*a**2/4
ellipse area = pi*a*b
SymPy directly = pi*a*b
Converting back to x
For indefinite integrals, draw the reference triangle. With : opposite side , hypotenuse , adjacent side . Then every trig function of becomes an expression in .
using , . This formula gives the area of any circular segment, a quantity graphics code needs often.
A tangent substitution. : , , :
(the constant is absorbed into ). The answer is also : substituting is the hyperbolic alternative, often shorter (Hyperbolic Functions).
Completing the square first
A quadratic under a root becomes one of the three forms after completing the square. For : , so with and then the result is .
import sympy as sp
x = sp.symbols('x', real=True)
for f in [1 / sp.sqrt(x**2 + 4), 1 / sp.sqrt(5 + 4*x - x**2), x**2 / sp.sqrt(9 - x**2)]:
print(f"∫ {f} dx = {sp.integrate(f, x)}")∫ 1/sqrt(x**2 + 4) dx = asinh(x/2)
∫ 1/sqrt(-x**2 + 4*x + 5) dx = asin(x/3 - 2/3)
∫ x**2/sqrt(9 - x**2) dx = -x*sqrt(9 - x**2)/2 + 9*asin(x/3)/2
asinh(x/2) equals , so it agrees with our answer up to a constant.
Application: overlap of two circles
The intersection area of two circles appears in collision response, in "intersection over union" scores for circular object detections, and in Venn-diagram layout. It is the sum of two circular segments, each given by the formula above:
import math
from scipy.integrate import quad
def segment(r, h):
"""Area of the part of a radius-r disc beyond a chord at distance h from the centre."""
F = lambda x: 0.5 * r * r * math.asin(x / r) + 0.5 * x * math.sqrt(r * r - x * x)
return 2 * (F(r) - F(h)) # 2∫_h^r √(r² − x²) dx
r1, r2, d = 3.0, 2.0, 4.0 # radii and distance between centres
x0 = (d * d + r1 * r1 - r2 * r2) / (2 * d) # chord position measured from centre 1
area = segment(r1, x0) + segment(r2, d - x0)
print(f"overlap area (formula) = {area:.6f}")
# brute-force check: integrate the overlap's vertical extent numerically
top = lambda x: min(math.sqrt(max(r1*r1 - x*x, 0)), math.sqrt(max(r2*r2 - (x - d)**2, 0)))
print(f"overlap area (quadrature) = {2 * quad(top, d - r2, r1, points=[x0])[0]:.6f}")overlap area (formula) = 1.989792
overlap area (quadrature) = 1.989792
In software
- Anti-aliased circles. Renderers that shade a pixel by the fraction of it covered by a disc evaluate circular-segment areas like the one above, often from a precomputed table.
- Physics and games. Buoyancy of a circle in water (the submerged area), overlap penalties and soft collisions between round bodies all use segment areas.
- Arc length. The arc length of a parabola, , needs ; font and path libraries face such integrals when they measure curves (Arc Length).
Exercises
Exercise 1: Sine substitution
Compute .
Answer
.
Solution
Exercise 2: Tangent substitution
Compute .
Answer
.
Solution
import sympy as sp
x = sp.symbols('x')
print(sp.integrate(1 / (1 + x**2)**sp.Rational(3, 2), (x, 0, 1)))sqrt(2)/2
Exercise 3: Secant substitution
Compute for .
Answer
.
Solution
Exercise 4: Half a segment
Find the area of the part of the unit disc with .
Answer
.
Solution
.
Test yourself
Which substitution simplifies ?
Why is restricted to for ?
- To make one-to-one there and , so
- Because is undefined elsewhere
- To avoid complex numbers in
- No reason
Before substituting in , what should you do?
- Integrate by parts
- Use partial fractions
- Complete the square:
- Nothing