TExcelTAD
Home › Calculus in Depth › Trigonometric Substitution

Trigonometric Substitution

Square roots like a2−x2\sqrt{a^2 - x^2} describe circles, and integrals containing them (areas of circular segments, ellipses, arc lengths) resist ordinary substitution. Trigonometric substitution replaces xx with a trig function of a new variable θ\theta 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 θ\theta Identity
a2−x2\sqrt{a^2 - x^2} x=asin⁡θx = a \sin\theta −π/2≤θ≤π/2-\pi/2 \le \theta \le \pi/2 1−sin⁡2θ=cos⁡2θ1 - \sin^2\theta = \cos^2\theta
a2+x2\sqrt{a^2 + x^2} x=atan⁡θx = a \tan\theta −π/2<θ<π/2-\pi/2 < \theta < \pi/2 1+tan⁡2θ=sec⁡2θ1 + \tan^2\theta = \sec^2\theta
x2−a2\sqrt{x^2 - a^2} x=asec⁡θx = a \sec\theta 0≤θ<π/20 \le \theta < \pi/2 or π≤θ<3π/2\pi \le \theta < 3\pi/2 sec⁡2θ−1=tan⁡2θ\sec^2\theta - 1 = \tan^2\theta

These are inverse substitutions: instead of setting u=g(x)u = g(x), we set x=g(θ)x = g(\theta). The Substitution Rule still applies, read right to left, provided gg is one-to-one on the chosen range of θ\theta (so that θ=g−1(x)\theta = g^{-1}(x) makes sense when we convert back). The ranges in the table are chosen so that gg is invertible and the root simplifies without absolute values: for x=asin⁡θx = a \sin\theta with θ\theta in [−π/2,π/2][-\pi/2, \pi/2], cos⁡θ≥0\cos\theta \ge 0, so a2−a2sin⁡2θ=acos⁡θ\sqrt{a^2 - a^2\sin^2\theta} = a \cos\theta exactly.

Example: the area of an ellipse

The ellipse x2a2+y2b2=1\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1 has upper half y=baa2−x2y = \frac{b}{a}\sqrt{a^2 - x^2}. By symmetry its area is 4ba∫0aa2−x2 dx4\frac{b}{a}\int_0^a \sqrt{a^2 - x^2}\,dx. With x=asin⁡θx = a \sin\theta, dx=acos⁡θ dθdx = a \cos\theta\,d\theta, limits 0→00 \to 0 and a→π/2a \to \pi/2:

∫0aa2−x2 dx=∫0π/2acos⁡θ⋅acos⁡θ dθ=a2∫0π/21+cos⁡2θ2 dθ=πa24A=4 ba⋅πa24=πab\begin{aligned} \int_0^a \sqrt{a^2 - x^2}\,dx &= \int_0^{\pi/2} a \cos\theta \cdot a \cos\theta\,d\theta = a^2 \int_0^{\pi/2} \frac{1 + \cos 2\theta}{2}\,d\theta = \frac{\pi a^2}{4} \\ A &= 4\,\frac{b}{a} \cdot \frac{\pi a^2}{4} = \pi ab \end{aligned}

With a=b=ra = b = r this proves the circle's area is πr2\pi r^2, from the definition of the integral rather than from a picture.

python · try it yourself
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 x=asin⁡θx = a \sin\theta: opposite side xx, hypotenuse aa, adjacent side a2−x2\sqrt{a^2 - x^2}. Then every trig function of θ\theta becomes an expression in xx.

∫a2−x2 dx=a2∫cos⁡2θ dθ=a22(θ+sin⁡θcos⁡θ)+C=a22sin⁡−1xa+x2a2−x2+C\begin{aligned} \int \sqrt{a^2 - x^2}\,dx &= a^2 \int \cos^2\theta\,d\theta = \frac{a^2}{2}(\theta + \sin\theta \cos\theta) + C \\ &= \frac{a^2}{2} \sin^{-1}\frac{x}{a} + \frac{x}{2}\sqrt{a^2 - x^2} + C \end{aligned}

using sin⁡θ=xa\sin\theta = \frac{x}{a}, cos⁡θ=a2−x2a\cos\theta = \frac{\sqrt{a^2 - x^2}}{a}. This formula gives the area of any circular segment, a quantity graphics code needs often.

A tangent substitution. ∫dxx2+4\int \frac{dx}{\sqrt{x^2 + 4}}: x=2tan⁡θx = 2\tan\theta, dx=2sec⁡2θ dθdx = 2\sec^2\theta\,d\theta, x2+4=2sec⁡θ\sqrt{x^2 + 4} = 2\sec\theta:

∫2sec⁡2θ2sec⁡θ dθ=∫sec⁡θ dθ=ln⁡∣sec⁡θ+tan⁡θ∣+C1=ln⁡∣x2+42+x2∣+C1=ln⁡(x+x2+4)+C\begin{aligned} \int \frac{2\sec^2\theta}{2\sec\theta}\,d\theta &= \int \sec\theta\,d\theta = \ln\lvert \sec\theta + \tan\theta \rvert + C_1 \\ &= \ln\Big\lvert \frac{\sqrt{x^2 + 4}}{2} + \frac{x}{2} \Big\rvert + C_1 = \ln\big(x + \sqrt{x^2 + 4}\big) + C \end{aligned}

(the constant −ln⁡2-\ln 2 is absorbed into CC). The answer is also sinh⁡−1(x/2)+C\sinh^{-1}(x/2) + C: substituting x=2sinh⁡tx = 2\sinh t is the hyperbolic alternative, often shorter (Hyperbolic Functions).

Completing the square first

A quadratic ax2+bx+cax^2 + bx + c under a root becomes one of the three forms after completing the square. For ∫dx5+4x−x2\int \frac{dx}{\sqrt{5 + 4x - x^2}}: 5+4x−x2=9−(x−2)25 + 4x - x^2 = 9 - (x - 2)^2, so with u=x−2u = x - 2 and then u=3sin⁡θu = 3\sin\theta the result is sin⁡−1x−23+C\sin^{-1}\frac{x - 2}{3} + C.

python · try it yourself
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 ln⁡(x2+x2/4+1)=ln⁡(x+x2+4)−ln⁡2\ln\big(\frac{x}{2} + \sqrt{x^2/4 + 1}\big) = \ln\big(x + \sqrt{x^2 + 4}\big) - \ln 2, 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:

python · try it yourself
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, ∫1+4x2 dx\int \sqrt{1 + 4x^2}\,dx, needs x=12tan⁡θx = \frac{1}{2}\tan\theta; font and path libraries face such integrals when they measure curves (Arc Length).

Exercises

Exercise 1: Sine substitution

Compute ∫x29−x2 dx\int \frac{x^2}{\sqrt{9 - x^2}}\,dx.

Answer

92sin⁡−1x3−x29−x2+C\frac{9}{2} \sin^{-1}\frac{x}{3} - \frac{x}{2}\sqrt{9 - x^2} + C.

Solution
x=3sin⁡θ, dx=3cos⁡θ dθ, 9−x2=3cos⁡θ∫9sin⁡2θ dθ=92(θ−sin⁡θcos⁡θ)+C=92sin⁡−1x3−92⋅x3⋅9−x23+C\begin{aligned} &x = 3\sin\theta,\ dx = 3\cos\theta\,d\theta,\ \sqrt{9 - x^2} = 3\cos\theta \\ &\int 9\sin^2\theta\,d\theta = \frac{9}{2}(\theta - \sin\theta \cos\theta) + C \\ &\qquad = \frac{9}{2} \sin^{-1}\frac{x}{3} - \frac{9}{2} \cdot \frac{x}{3} \cdot \frac{\sqrt{9 - x^2}}{3} + C \end{aligned}

Exercise 2: Tangent substitution

Compute ∫01dx(1+x2)3/2\int_0^1 \frac{dx}{(1 + x^2)^{3/2}}.

Answer

12≈0.7071\frac{1}{\sqrt{2}} \approx 0.7071.

Solution
x=tan⁡θ: dx=sec⁡2θ dθ, (1+x2)3/2=sec⁡3θ;x:0→1 means θ:0→π/4∫0π/4cos⁡θ dθ=sin⁡(π/4)=12\begin{aligned} &x = \tan\theta:\ dx = \sec^2\theta\,d\theta,\ (1 + x^2)^{3/2} = \sec^3\theta; \qquad x: 0 \to 1 \text{ means } \theta: 0 \to \pi/4 \\ &\int_0^{\pi/4} \cos\theta\,d\theta = \sin(\pi/4) = \frac{1}{\sqrt{2}} \end{aligned}
python · try it yourself
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 ∫x2−1x dx\int \frac{\sqrt{x^2 - 1}}{x}\,dx for x≥1x \ge 1.

Answer

x2−1−sec⁡−1x+C\sqrt{x^2 - 1} - \sec^{-1} x + C.

Solution
x=sec⁡θ (0≤θ<π/2): dx=sec⁡θtan⁡θ dθ, x2−1=tan⁡θ∫tan⁡θsec⁡θ⋅sec⁡θtan⁡θ dθ=∫tan⁡2θ dθ=∫(sec⁡2θ−1) dθ=tan⁡θ−θ+C\begin{aligned} &x = \sec\theta\ (0 \le \theta < \pi/2):\ dx = \sec\theta \tan\theta\,d\theta,\ \sqrt{x^2 - 1} = \tan\theta \\ &\int \frac{\tan\theta}{\sec\theta} \cdot \sec\theta \tan\theta\,d\theta = \int \tan^2\theta\,d\theta = \int (\sec^2\theta - 1)\,d\theta = \tan\theta - \theta + C \end{aligned}

Exercise 4: Half a segment

Find the area of the part of the unit disc with x≥12x \ge \frac{1}{2}.

Answer

π3−34≈0.6142\frac{\pi}{3} - \frac{\sqrt{3}}{4} \approx 0.6142.

Solution

2∫1/211−x2 dx=2[12sin⁡−1x+x21−x2]1/21=2[π4−(π12+38)]=π3−342\int_{1/2}^{1} \sqrt{1 - x^2}\,dx = 2\Big[\frac{1}{2}\sin^{-1} x + \frac{x}{2}\sqrt{1 - x^2}\Big]_{1/2}^{1} = 2\Big[\frac{\pi}{4} - \Big(\frac{\pi}{12} + \frac{\sqrt{3}}{8}\Big)\Big] = \frac{\pi}{3} - \frac{\sqrt{3}}{4}.

Test yourself

Which substitution simplifies 16+x2\sqrt{16 + x^2}?

  1. x=4sin⁡θx = 4\sin\theta
  2. x=4tan⁡θx = 4\tan\theta
  3. x=4sec⁡θx = 4\sec\theta
  4. x=16tan⁡θx = 16\tan\theta

Why is θ\theta restricted to [−π/2,π/2][-\pi/2, \pi/2] for x=asin⁡θx = a\sin\theta?

  1. To make sin⁡\sin one-to-one there and cos⁡θ≥0\cos\theta \ge 0, so a2−x2=acos⁡θ\sqrt{a^2 - x^2} = a\cos\theta
  2. Because sin⁡\sin is undefined elsewhere
  3. To avoid complex numbers in dxdx
  4. No reason

Before substituting in ∫dxx2−6x+13\int \frac{dx}{\sqrt{x^2 - 6x + 13}}, what should you do?

  1. Integrate by parts
  2. Use partial fractions
  3. Complete the square: (x−3)2+4(x - 3)^2 + 4
  4. Nothing