Chapter 9
22 min read
Section 85 of 353

Trigonometric Substitution

The Indefinite Integral and Antiderivatives

Learning Objectives

By the end of this section, you will be able to:

  1. Recognize when trigonometric substitution is the appropriate integration technique
  2. Apply the three standard trigonometric substitutions for integrals containing a2x2\sqrt{a^2 - x^2}, a2+x2\sqrt{a^2 + x^2}, and x2a2\sqrt{x^2 - a^2}
  3. Construct reference triangles to convert back from trigonometric to algebraic expressions
  4. Use completing the square to transform integrals into forms suitable for trigonometric substitution
  5. Evaluate definite integrals by transforming the limits of integration
  6. Connect this technique to physics, engineering, and machine learning applications

The Big Picture: Exploiting the Pythagorean Identity

"Trigonometric substitution transforms algebraic radicals into trigonometric expressions, where identities like sin²θ + cos²θ = 1 simplify the square roots."

Many important integrals contain expressions like a2x2\sqrt{a^2 - x^2}, a2+x2\sqrt{a^2 + x^2}, or x2a2\sqrt{x^2 - a^2}. These square roots of sums and differences of squares appear everywhere in geometry, physics, and engineering — from computing arc lengths to calculating gravitational potentials.

The key insight of trigonometric substitution is that these expressions are related to the Pythagorean theorem. By substituting xx with a trigonometric expression, we transform the radical into a form where the Pythagorean identity eliminates the square root entirely.

The Core Strategy

The Pythagorean identity sin2θ+cos2θ=1\sin^2\theta + \cos^2\theta = 1 can be rearranged as:

  • 1sin2θ=cos2θ1 - \sin^2\theta = \cos^2\theta — helps with a2x2\sqrt{a^2 - x^2}
  • 1+tan2θ=sec2θ1 + \tan^2\theta = \sec^2\theta — helps with a2+x2\sqrt{a^2 + x^2}
  • sec2θ1=tan2θ\sec^2\theta - 1 = \tan^2\theta — helps with x2a2\sqrt{x^2 - a^2}

By choosing the right substitution, the square root simplifies to a single trigonometric function!

When to Use Trigonometric Substitution

Look for integrals containing:

  • a2x2\sqrt{a^2 - x^2} or (a2x2)n/2(a^2 - x^2)^{n/2} for any nn
  • a2+x2\sqrt{a^2 + x^2} or (a2+x2)n/2(a^2 + x^2)^{n/2}
  • x2a2\sqrt{x^2 - a^2} or (x2a2)n/2(x^2 - a^2)^{n/2}
  • Expressions that can be transformed into these forms by completing the square

Historical Context

The connection between geometry and trigonometry has been understood for millennia, but its application to integration was developed during the 17th and 18th centuries.

The Ancient Roots

Ancient Greek mathematicians like Archimedes (287–212 BCE) computed areas of circles and ellipses using geometric methods. The integral r2x2dx\int \sqrt{r^2 - x^2} \, dx gives the area under a semicircle — a problem Archimedes solved using the "method of exhaustion."

Euler and the Calculus Era

Leonhard Euler (1707–1783) systematized the use of trigonometric substitutions in integration. He recognized that the three Pythagorean identities correspond to the three fundamental cases of quadratic radicals. His work connected integration to arc length formulas, gravitational calculations, and the emerging field of mathematical physics.

Why "Trigonometric" Substitution?

The name reflects the method: we substitute xx with a trigonometric function of a new variable θ\theta. This transforms algebraic expressions into trigonometric ones, where powerful identities simplify the calculation.


The Pythagorean Connection

The foundation of trigonometric substitution is the Pythagorean theorem and its trigonometric equivalent. Consider a right triangle with hypotenuse aa and one leg xx. The other leg is a2x2\sqrt{a^2 - x^2}.

If we let x=asinθx = a\sin\theta, then:

a2x2=a2a2sin2θ=a2(1sin2θ)\sqrt{a^2 - x^2} = \sqrt{a^2 - a^2\sin^2\theta} = \sqrt{a^2(1 - \sin^2\theta)}
=a2cos2θ=acosθ=acosθ= \sqrt{a^2\cos^2\theta} = a|\cos\theta| = a\cos\theta

(When π2θπ2-\frac{\pi}{2} \leq \theta \leq \frac{\pi}{2}, we have cosθ0\cos\theta \geq 0)

The square root disappears! This is the magic of trigonometric substitution — the Pythagorean identity transforms the radical into a simple trigonometric function.

Reference Triangle Strategy

After integrating in terms of θ\theta, we need to convert back to xx. The reference triangle shows the relationships:

  • If x=asinθx = a\sin\theta, then sinθ=xa\sin\theta = \frac{x}{a}
  • The adjacent side is a2x2\sqrt{a^2 - x^2}
  • So cosθ=a2x2a\cos\theta = \frac{\sqrt{a^2 - x^2}}{a}

The Three Trigonometric Substitutions

There are exactly three standard trigonometric substitutions, each designed for a specific type of radical expression:

ExpressionSubstitutionIdentity UsedSimplification
√(a² - x²)x = a·sin(θ)1 - sin²θ = cos²θa·cos(θ)
√(a² + x²)x = a·tan(θ)1 + tan²θ = sec²θa·sec(θ)
√(x² - a²)x = a·sec(θ)sec²θ - 1 = tan²θa·tan(θ)

Why These Specific Functions?

Each substitution is chosen so that the expression under the square root matches one side of a Pythagorean identity:

  • a2x2a^2 - x^2 matches a2(1sin2θ)=a2cos2θa^2(1 - \sin^2\theta) = a^2\cos^2\theta
  • a2+x2a^2 + x^2 matches a2(1+tan2θ)=a2sec2θa^2(1 + \tan^2\theta) = a^2\sec^2\theta
  • x2a2x^2 - a^2 matches a2(sec2θ1)=a2tan2θa^2(\sec^2\theta - 1) = a^2\tan^2\theta

Interactive: Exploring Trigonometric Substitution

Explore how each trigonometric substitution transforms the integrand and simplifies the radical:

x = 1.411.41y = √(a² - x²)

Case 1: √(a² - x²)

Substitution:x = a·sin(θ)
Identity:1 - sin²θ = cos²θ
Simplifies to:a·cos(θ)

Current Values

x =1.414
θ =45.0°
√(a² - x²) =1.414
a·cos(θ) =1.414

Used when you have a² minus x² under the square root. Think of a circle equation x² + y² = a².


Case 1: a2x2\sqrt{a^2 - x^2}

When the integrand contains a2x2\sqrt{a^2 - x^2}, use the substitution:

Case 1 Substitution

x=asinθ,dx=acosθdθx = a\sin\theta, \quad dx = a\cos\theta \, d\theta
a2x2=acosθ\sqrt{a^2 - x^2} = a\cos\theta

Valid for π2θπ2-\frac{\pi}{2} \leq \theta \leq \frac{\pi}{2}

Example: dx4x2\int \frac{dx}{\sqrt{4 - x^2}}

Step 1: Identify a

Here a2=4a^2 = 4, so a=2a = 2.

Step 2: Make the substitution

  • x=2sinθx = 2\sin\theta
  • dx=2cosθdθdx = 2\cos\theta \, d\theta
  • 4x2=44sin2θ=2cosθ\sqrt{4 - x^2} = \sqrt{4 - 4\sin^2\theta} = 2\cos\theta

Step 3: Transform the integral

dx4x2=2cosθdθ2cosθ=dθ=θ+C\int \frac{dx}{\sqrt{4 - x^2}} = \int \frac{2\cos\theta \, d\theta}{2\cos\theta} = \int d\theta = \theta + C

Step 4: Convert back to x

Since x=2sinθx = 2\sin\theta, we have sinθ=x2\sin\theta = \frac{x}{2}, so θ=arcsin(x2)\theta = \arcsin\left(\frac{x}{2}\right).

dx4x2=arcsin(x2)+C\int \frac{dx}{\sqrt{4 - x^2}} = \arcsin\left(\frac{x}{2}\right) + C

Interactive: Right Triangle for Case 1

Visualize the reference triangle used to convert back from θ\theta to xx:

Case 1: √(a² - x²)

θ√(a² - x²)= 1.91x= 2.32a= 3.00

x = a·sin(θ), where the hypotenuse is a

Trigonometric Ratios

sin(θ) =
x/a= 0.7723
cos(θ) =
√(a² - x²)/a= 0.6352
tan(θ) =
x/√(a² - x²)= 1.2158

Key Insight: After integration, use this triangle to convert trig functions back to algebraic expressions in x.


Case 2: a2+x2\sqrt{a^2 + x^2}

When the integrand contains a2+x2\sqrt{a^2 + x^2}, use the substitution:

Case 2 Substitution

x=atanθ,dx=asec2θdθx = a\tan\theta, \quad dx = a\sec^2\theta \, d\theta
a2+x2=asecθ\sqrt{a^2 + x^2} = a\sec\theta

Valid for π2<θ<π2-\frac{\pi}{2} < \theta < \frac{\pi}{2}

Example: dx9+x2\int \frac{dx}{\sqrt{9 + x^2}}

Step 1: Here a=3a = 3. Let x=3tanθx = 3\tan\theta, dx=3sec2θdθdx = 3\sec^2\theta \, d\theta.

Step 2: Simplify the radical

9+x2=9+9tan2θ=31+tan2θ=3secθ\sqrt{9 + x^2} = \sqrt{9 + 9\tan^2\theta} = 3\sqrt{1 + \tan^2\theta} = 3\sec\theta

Step 3: Transform and integrate

3sec2θdθ3secθ=secθdθ=lnsecθ+tanθ+C\int \frac{3\sec^2\theta \, d\theta}{3\sec\theta} = \int \sec\theta \, d\theta = \ln|\sec\theta + \tan\theta| + C

Step 4: Convert back

From the triangle: tanθ=x3\tan\theta = \frac{x}{3} and secθ=9+x23\sec\theta = \frac{\sqrt{9 + x^2}}{3}.

dx9+x2=ln9+x23+x3+C=ln9+x2+x+C1\int \frac{dx}{\sqrt{9 + x^2}} = \ln\left|\frac{\sqrt{9 + x^2}}{3} + \frac{x}{3}\right| + C = \ln|\sqrt{9 + x^2} + x| + C_1

Case 3: x2a2\sqrt{x^2 - a^2}

When the integrand contains x2a2\sqrt{x^2 - a^2}, use the substitution:

Case 3 Substitution

x=asecθ,dx=asecθtanθdθx = a\sec\theta, \quad dx = a\sec\theta\tan\theta \, d\theta
x2a2=atanθ\sqrt{x^2 - a^2} = a\tan\theta

Valid for 0θ<π20 \leq \theta < \frac{\pi}{2} when x>ax > a

Example: x24xdx\int \frac{\sqrt{x^2 - 4}}{x} \, dx

Step 1: Here a=2a = 2. Let x=2secθx = 2\sec\theta.

  • dx=2secθtanθdθdx = 2\sec\theta\tan\theta \, d\theta
  • x24=4sec2θ4=2tanθ\sqrt{x^2 - 4} = \sqrt{4\sec^2\theta - 4} = 2\tan\theta

Step 2: Transform and integrate

2tanθ2secθtanθdθ2secθ=2tan2θdθ\int \frac{2\tan\theta \cdot 2\sec\theta\tan\theta \, d\theta}{2\sec\theta} = 2\int \tan^2\theta \, d\theta

Step 3: Use tan2θ=sec2θ1\tan^2\theta = \sec^2\theta - 1:

2(sec2θ1)dθ=2(tanθθ)+C2\int (\sec^2\theta - 1) \, d\theta = 2(\tan\theta - \theta) + C

Step 4: Convert back

tanθ=x242\tan\theta = \frac{\sqrt{x^2-4}}{2} and θ=arcsec(x2)\theta = \text{arcsec}\left(\frac{x}{2}\right).

x24xdx=x242arcsec(x2)+C\int \frac{\sqrt{x^2 - 4}}{x} \, dx = \sqrt{x^2 - 4} - 2\text{arcsec}\left(\frac{x}{2}\right) + C

Worked Examples

Example 1: Area Under a Semicircle

Problem: Find 0aa2x2dx\int_0^a \sqrt{a^2 - x^2} \, dx.

Solution: This represents the area of a quarter circle of radius aa.

Using x=asinθx = a\sin\theta:

  • When x=0x = 0, θ=0\theta = 0
  • When x=ax = a, θ=π2\theta = \frac{\pi}{2}
0aa2x2dx=0π/2acosθacosθdθ=a20π/2cos2θdθ\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} \cos^2\theta \, d\theta

Using cos2θ=1+cos(2θ)2\cos^2\theta = \frac{1 + \cos(2\theta)}{2}:

=a2π4=πa24= a^2 \cdot \frac{\pi}{4} = \frac{\pi a^2}{4}

This confirms the formula for a quarter circle's area!

Example 2: Arc Length of a Circle

Problem: Find the arc length of y=r2x2y = \sqrt{r^2 - x^2} from x=0x = 0 to x=rx = r.

Solution: Arc length formula: L=0r1+(dydx)2dxL = \int_0^r \sqrt{1 + \left(\frac{dy}{dx}\right)^2} \, dx

With dydx=xr2x2\frac{dy}{dx} = \frac{-x}{\sqrt{r^2 - x^2}}:

L=0r1+x2r2x2dx=0rrr2x2dxL = \int_0^r \sqrt{1 + \frac{x^2}{r^2 - x^2}} \, dx = \int_0^r \frac{r}{\sqrt{r^2 - x^2}} \, dx

Using x=rsinθx = r\sin\theta:

L=r0π/2dθ=πr2L = r \int_0^{\pi/2} d\theta = \frac{\pi r}{2}

This is indeed one quarter of the circumference 2πr2\pi r!


Completing the Square

Many integrals don't immediately look like one of our three cases, but can be transformed by completing the square.

Example: dxx2+4x+8\int \frac{dx}{\sqrt{x^2 + 4x + 8}}

Step 1: Complete the square

x2+4x+8=(x2+4x+4)+4=(x+2)2+4x^2 + 4x + 8 = (x^2 + 4x + 4) + 4 = (x + 2)^2 + 4

Step 2: Substitute u = x + 2

dx(x+2)2+4=duu2+4\int \frac{dx}{\sqrt{(x+2)^2 + 4}} = \int \frac{du}{\sqrt{u^2 + 4}}

Step 3: Now it's Case 2 with a = 2

Let u=2tanθu = 2\tan\theta:

=lnu+u2+4+C=ln(x+2)+x2+4x+8+C= \ln|u + \sqrt{u^2 + 4}| + C = \ln|(x + 2) + \sqrt{x^2 + 4x + 8}| + C

Pattern Recognition

For ax2+bx+cax^2 + bx + c:

  1. Factor out aa if needed
  2. Complete the square: x2+bax=(x+b2a)2b24a2x^2 + \frac{b}{a}x = \left(x + \frac{b}{2a}\right)^2 - \frac{b^2}{4a^2}
  3. Identify which case applies

Definite Integrals with Trigonometric Substitution

For definite integrals, you have two options:

  1. Transform the limits: Convert xx-limits to θ\theta-limits and integrate entirely in terms of θ\theta
  2. Back-substitute first: Find the antiderivative in terms of xx, then apply the original limits

The first method is often cleaner, avoiding the need to convert back to xx.

Example: 03dx(9+x2)3/2\int_0^3 \frac{dx}{(9 + x^2)^{3/2}}

Use x=3tanθx = 3\tan\theta. When x=0x = 0, θ=0\theta = 0. When x=3x = 3, θ=π4\theta = \frac{\pi}{4}.

0π/43sec2θdθ27sec3θ=190π/4cosθdθ=19[sinθ]0π/4\int_0^{\pi/4} \frac{3\sec^2\theta \, d\theta}{27\sec^3\theta} = \frac{1}{9} \int_0^{\pi/4} \cos\theta \, d\theta = \frac{1}{9}[\sin\theta]_0^{\pi/4}
=1922=218= \frac{1}{9} \cdot \frac{\sqrt{2}}{2} = \frac{\sqrt{2}}{18}

Real-World Applications

Trigonometric substitution appears throughout physics and engineering wherever geometry meets calculus.

Physics: Gravitational Potential of a Ring

The gravitational potential at a point on the axis of a ring of mass MM and radius RR at distance zz from the center is:

V=GMR2+z2V = -\frac{GM}{\sqrt{R^2 + z^2}}

The R2+z2\sqrt{R^2 + z^2} arises from the Pythagorean theorem: the distance from any point on the ring to the observation point.

Engineering: Catenary Curves

The shape of a hanging cable (catenary) involves hyperbolic functions, which are related to trigonometric functions through complex numbers:

y=acosh(xa)y = a \cosh\left(\frac{x}{a}\right)

Arc length calculations for catenaries use cosh2(u)sinh2(u)=1\cosh^2(u) - \sinh^2(u) = 1, the hyperbolic analog of the Pythagorean identity.

Geometry: Ellipse Area and Arc Length

For an ellipse x2a2+y2b2=1\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1:

  • Area: A=πabA = \pi ab (derived using trig substitution)
  • Arc length: Leads to elliptic integrals that cannot be expressed in terms of elementary functions

Machine Learning Connection

Trigonometric substitution and its underlying geometric principles appear in several machine learning contexts.

The von Mises Distribution

The von Mises distribution is the circular analog of the normal distribution, used for directional data in ML:

f(θμ,κ)=eκcos(θμ)2πI0(κ)f(\theta | \mu, \kappa) = \frac{e^{\kappa \cos(\theta - \mu)}}{2\pi I_0(\kappa)}

Here I0(κ)I_0(\kappa) is the modified Bessel function, computed via an integral involving cosine.

Applications include:

  • Modeling wind directions in climate models
  • Analyzing periodic time series (daily/yearly patterns)
  • Protein structure prediction (torsion angles)
  • Robotics (orientation estimation)

The Gaussian Integral

The famous Gaussian integral ex2dx=π\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi} is fundamental to probability and ML. Its evaluation uses polar coordinates, which are inherently trigonometric:

I2= ⁣ ⁣e(x2+y2)dxdy=02π ⁣ ⁣0er2rdrdθI^2 = \int\!\!\int e^{-(x^2+y^2)} dx\,dy = \int_0^{2\pi}\!\!\int_0^\infty e^{-r^2} r\,dr\,d\theta

The conversion uses x=rcosθx = r\cos\theta, y=rsinθy = r\sin\theta.

RBF Kernels and Distance Functions

Radial basis function kernels like k(x,y)=exp(xy2/2σ2)k(x, y) = \exp(-\|x-y\|^2/2\sigma^2) depend on Euclidean distances. When analyzing these kernels in feature spaces, integrals involving i(xiyi)2\sqrt{\sum_i (x_i - y_i)^2} arise — higher-dimensional analogs of our three cases.


Python Implementation

Numerical and Symbolic Trigonometric Substitution

Here's how to verify trigonometric substitution numerically and perform it symbolically:

Trigonometric Substitution: Numerical and Symbolic
🐍trig_substitution.py
14Quarter Circle Area

The integral ∫√(4-x²)dx from 0 to 2 represents the area under a quarter circle of radius 2. Using x = 2sin(θ) transforms this into a standard trigonometric integral.

37Symbolic Integration

SymPy automatically applies the appropriate trigonometric substitution for expressions containing √(a² - x²), √(a² + x²), or √(x² - a²).

60Ellipse Arc Length

The arc length integral for an ellipse leads to an elliptic integral. Parametric representation uses x = a·cos(t), y = b·sin(t), naturally involving trigonometric functions.

91Beta Distribution

The Beta(1/2, 1/2) distribution has PDF proportional to 1/√(x(1-x)). Using x = sin²(θ) transforms the normalization integral into ∫2dθ from 0 to π/2.

113Gaussian Integral

While not directly trig substitution, the famous Gaussian integral is solved by converting to polar coordinates r = √(x² + y²), which fundamentally uses trigonometric relationships.

152 lines without explanation
1import numpy as np
2from scipy import integrate
3import sympy as sp
4
5def trig_substitution_numerical():
6    """
7    Verify trigonometric substitution numerically.
8
9    Example: ∫ √(4 - x²) dx from 0 to 2
10    This is the area of a quarter circle of radius 2.
11
12    Substitution: x = 2sin(θ), dx = 2cos(θ)dθ
13    √(4 - x²) = √(4 - 4sin²θ) = 2cos(θ)
14
15    Result: Area = π (quarter of circle with r=2)
16    """
17    # Define the integrand f(x) = √(4 - x²)
18    def f(x):
19        return np.sqrt(4 - x**2)
20
21    # Numerical integration using scipy
22    numerical_result, error = integrate.quad(f, 0, 2)
23
24    # Analytical result: quarter circle area = πr²/4 = π(4)/4 = π
25    analytical_result = np.pi
26
27    print("Trigonometric Substitution: ∫₀² √(4 - x²) dx")
28    print("=" * 50)
29    print(f"Numerical result:  {numerical_result:.10f}")
30    print(f"Analytical result: {analytical_result:.10f} (π)")
31    print(f"Absolute error:    {abs(numerical_result - analytical_result):.2e}")
32
33    return numerical_result, analytical_result
34
35def trig_substitution_symbolic():
36    """
37    Use SymPy to perform trigonometric substitution symbolically.
38    SymPy automatically applies the appropriate substitution.
39    """
40    x = sp.Symbol('x')
41    a = sp.Symbol('a', positive=True)
42
43    # Examples that require trigonometric substitution
44    examples = [
45        ("√(a² - x²)", sp.sqrt(a**2 - x**2)),
46        ("1/√(a² - x²)", 1/sp.sqrt(a**2 - x**2)),
47        ("√(a² + x²)", sp.sqrt(a**2 + x**2)),
48        ("1/√(a² + x²)", 1/sp.sqrt(a**2 + x**2)),
49        ("√(x² - a²)", sp.sqrt(x**2 - a**2)),
50        ("x²/√(a² - x²)", x**2/sp.sqrt(a**2 - x**2)),
51    ]
52
53    print("\nSymbolic Trigonometric Substitution Examples")
54    print("=" * 60)
55
56    for name, expr in examples:
57        try:
58            result = sp.integrate(expr, x)
59            result_simplified = sp.simplify(result)
60            print(f"\n∫ {name} dx = {result_simplified}")
61        except Exception as e:
62            print(f"\n∫ {name} dx = (requires special handling)")
63
64    return examples
65
66def arc_length_ellipse():
67    """
68    Compute the arc length of an ellipse using trigonometric substitution.
69
70    Ellipse: x²/a² + y²/b² = 1
71    Arc length: L = ∫ √(1 + (dy/dx)²) dx
72
73    This leads to an elliptic integral that requires trig substitution.
74    """
75    print("\n" + "=" * 60)
76    print("Arc Length of an Ellipse (Numerical Approximation)")
77    print("=" * 60)
78
79    a, b = 3.0, 2.0  # Semi-axes of the ellipse
80
81    # Parametric form: x = a*cos(t), y = b*sin(t)
82    # Arc length: L = ∫₀^(2π) √((dx/dt)² + (dy/dt)²) dt
83    #           = ∫₀^(2π) √(a²sin²t + b²cos²t) dt
84
85    def arc_length_integrand(t):
86        return np.sqrt(a**2 * np.sin(t)**2 + b**2 * np.cos(t)**2)
87
88    # Full ellipse arc length
89    L, error = integrate.quad(arc_length_integrand, 0, 2*np.pi)
90
91    # Ramanujan's approximation for ellipse perimeter
92    h = ((a - b) / (a + b))**2
93    L_approx = np.pi * (a + b) * (1 + 3*h / (10 + np.sqrt(4 - 3*h)))
94
95    print(f"Ellipse with a = {a}, b = {b}")
96    print(f"Numerical arc length: {L:.6f}")
97    print(f"Ramanujan approximation: {L_approx:.6f}")
98    print(f"Error: {abs(L - L_approx):.6f}")
99
100    return L
101
102def probability_density():
103    """
104    The Beta distribution PDF involves √(x(1-x)) terms.
105    Trigonometric substitution helps in normalization proofs.
106
107    Beta(1/2, 1/2) = 1/(π√(x(1-x))) for x ∈ [0,1]
108    """
109    print("\n" + "=" * 60)
110    print("Beta Distribution and Trigonometric Substitution")
111    print("=" * 60)
112
113    # Verify that ∫₀¹ 1/√(x(1-x)) dx = π
114    def integrand(x):
115        if x <= 0 or x >= 1:
116            return 0
117        return 1 / np.sqrt(x * (1 - x))
118
119    # Use midpoint to avoid singularities
120    result, error = integrate.quad(integrand, 0.0001, 0.9999)
121
122    print("∫₀¹ 1/√(x(1-x)) dx")
123    print(f"Numerical result: {result:.6f}")
124    print(f"Analytical result: π = {np.pi:.6f}")
125    print("\nUsing x = sin²(θ), the integral becomes:")
126    print("∫₀^(π/2) 2dθ = π")
127
128    return result
129
130def gaussian_integral():
131    """
132    The Gaussian integral ∫e^(-x²)dx appears everywhere.
133    While not directly trig substitution, polar coordinates
134    (which use trig functions) are key to its evaluation.
135    """
136    print("\n" + "=" * 60)
137    print("Gaussian Integral and Polar Coordinates")
138    print("=" * 60)
139
140    # ∫_{-∞}^{∞} e^(-x²) dx = √π
141    result, error = integrate.quad(lambda x: np.exp(-x**2), -10, 10)
142
143    print("∫_{-∞}^{∞} e^(-x²) dx")
144    print(f"Numerical result: {result:.6f}")
145    print(f"Analytical result: √π = {np.sqrt(np.pi):.6f}")
146    print("\nSolved by converting to polar coordinates:")
147    print("I² = ∫∫ e^(-(x²+y²)) dx dy = ∫∫ e^(-r²) r dr dθ")
148    print("Using r = √(x² + y²) and converting with trig functions!")
149
150    return result
151
152# Run all demonstrations
153trig_substitution_numerical()
154trig_substitution_symbolic()
155arc_length_ellipse()
156probability_density()
157gaussian_integral()

Applications in Physics and Engineering

See how trigonometric substitution applies to real-world problems:

Real-World Applications
🐍trig_sub_applications.py
10Gravitational Potential

The gravitational potential of a ring involves r = √(R² + z²), which is the distance from any point on the ring to the observation point. This naturally leads to √(a² + x²) type integrals.

44Electric Field

The electric field of a charged disk requires integrating contributions from concentric rings. Each ring element involves √(r² + z²) for the distance to the field point.

80Catenary Curve

The catenary (hanging cable) involves hyperbolic functions cosh and sinh, which satisfy cosh²(u) - sinh²(u) = 1. This is analogous to the Pythagorean identity for trig functions.

115Von Mises Distribution

The von Mises distribution is the circular analog of the normal distribution, used for directional data like angles. Its normalization involves a modified Bessel function computed via trigonometric integrals.

148Sphere Surface Area

Surface area calculations in spherical coordinates naturally involve sin(φ) from the Jacobian. The integral ∫∫r²sin(φ)dφdθ gives the familiar 4πr² formula.

188 lines without explanation
1import numpy as np
2from scipy import integrate
3import sympy as sp
4
5def physics_gravitational_potential():
6    """
7    Gravitational potential energy of a ring of mass M
8    at a point P on the axis at distance z.
9
10    The potential involves ∫ dm/r where r = √(R² + z²)
11    This is a case of √(a² + x²) form.
12    """
13    print("Physics: Gravitational Potential of a Ring")
14    print("=" * 50)
15
16    G = 6.674e-11  # Gravitational constant
17    M = 10.0       # Mass of ring (kg)
18    R = 1.0        # Radius of ring (m)
19
20    # Potential at points along the axis
21    def potential(z):
22        r = np.sqrt(R**2 + z**2)
23        return -G * M / r
24
25    # Calculate potential at various heights
26    z_values = np.linspace(0.1, 5, 10)
27    V_values = [potential(z) for z in z_values]
28
29    print(f"Ring: M = {M} kg, R = {R} m")
30    print("\nPotential V(z) = -GM/√(R² + z²):")
31    for z, V in zip(z_values[:5], V_values[:5]):
32        print(f"  z = {z:.2f} m: V = {V:.2e} J/kg")
33
34    print("\nThis form √(R² + z²) arises from the Pythagorean theorem")
35    print("connecting the ring radius and axial distance.")
36
37    return z_values, V_values
38
39def electric_field_disk():
40    """
41    Electric field on the axis of a uniformly charged disk.
42
43    E = (σ/2ε₀)[1 - z/√(z² + R²)]
44
45    The integration involves √(r² + z²) terms from each
46    ring element, requiring trig substitution.
47    """
48    print("\nPhysics: Electric Field of a Charged Disk")
49    print("=" * 50)
50
51    sigma = 1e-6    # Surface charge density (C/m²)
52    eps0 = 8.854e-12  # Permittivity of free space
53    R = 0.1         # Disk radius (m)
54
55    def E_field(z):
56        if z == 0:
57            return sigma / (2 * eps0)
58        return (sigma / (2 * eps0)) * (1 - z / np.sqrt(z**2 + R**2))
59
60    z_values = np.linspace(0.001, 0.5, 10)
61    E_values = [E_field(z) for z in z_values]
62
63    print(f"Disk: R = {R} m, σ = {sigma:.1e} C/m²")
64    print("\nE(z) = (σ/2ε₀)[1 - z/√(z² + R²)]:")
65    for z, E in zip(z_values[:5], E_values[:5]):
66        print(f"  z = {z:.3f} m: E = {E:.2e} N/C")
67
68    print("\nDerivation requires integrating dE from ring elements,")
69    print("each involving √(r² + z²) for the distance.")
70
71    return z_values, E_values
72
73def engineering_cable_tension():
74    """
75    Cable hanging under its own weight (catenary problem).
76
77    Arc length: s = a·sinh(x/a)
78    Tension: T = T₀·cosh(x/a)
79
80    The hyperbolic functions are connected to trig substitution
81    through the identity cosh²(u) - sinh²(u) = 1.
82    """
83    print("\nEngineering: Catenary Cable Tension")
84    print("=" * 50)
85
86    a = 10.0        # Parameter (related to horizontal tension)
87    x_span = 5.0    # Half-span of cable
88
89    # Cable shape: y = a·cosh(x/a) - a
90    x = np.linspace(-x_span, x_span, 100)
91    y = a * np.cosh(x / a) - a
92
93    # Arc length from center to point x
94    def arc_length(x_val):
95        return a * np.sinh(x_val / a)
96
97    # Tension at point x (T = T₀·cosh(x/a))
98    T0 = 1000  # Horizontal tension (N)
99    def tension(x_val):
100        return T0 * np.cosh(x_val / a)
101
102    s = arc_length(x_span)
103    T = tension(x_span)
104
105    print(f"Cable parameters: a = {a} m, span = 2×{x_span} m")
106    print(f"Horizontal tension: T₀ = {T0} N")
107    print(f"\nAt x = {x_span} m:")
108    print(f"  Arc length s = {s:.3f} m")
109    print(f"  Tension T = {T:.3f} N")
110
111    print("\nThe catenary involves cosh and sinh, which satisfy")
112    print("cosh²(u) - sinh²(u) = 1, analogous to sin²θ + cos²θ = 1")
113
114    return x, y
115
116def ml_von_mises_distribution():
117    """
118    The von Mises distribution is the circular analog of
119    the normal distribution, used for directional data in ML.
120
121    PDF: f(θ|μ,κ) = exp(κ·cos(θ-μ)) / (2π·I₀(κ))
122
123    Here I₀ is the modified Bessel function, computed via
124    an integral involving trigonometric functions.
125    """
126    print("\nML: Von Mises Distribution for Directional Data")
127    print("=" * 50)
128
129    from scipy.special import i0  # Modified Bessel function
130
131    # Von Mises PDF
132    def von_mises_pdf(theta, mu, kappa):
133        return np.exp(kappa * np.cos(theta - mu)) / (2 * np.pi * i0(kappa))
134
135    mu = 0.0      # Mean direction
136    kappa = 2.0   # Concentration parameter
137
138    theta = np.linspace(-np.pi, np.pi, 100)
139    pdf_values = von_mises_pdf(theta, mu, kappa)
140
141    print(f"Parameters: μ = {mu}, κ = {kappa}")
142    print(f"Peak PDF value: {max(pdf_values):.4f}")
143    print(f"PDF at θ = π: {von_mises_pdf(np.pi, mu, kappa):.4f}")
144
145    print("\nThe normalization constant involves the integral:")
146    print("I₀(κ) = (1/π) ∫₀^π exp(κ·cos(θ)) dθ")
147    print("This integral is evaluated using trigonometric methods!")
148
149    return theta, pdf_values
150
151def geometry_surface_area_sphere():
152    """
153    Surface area of a sphere using integration.
154
155    A = ∫₀^(2π) ∫₀^π r² sin(φ) dφ dθ = 4πr²
156
157    The spherical coordinates inherently use trigonometric
158    functions, and the integral involves sin(φ).
159    """
160    print("\nGeometry: Surface Area of a Sphere")
161    print("=" * 50)
162
163    r = 2.0  # Radius
164
165    # Double integral using spherical coordinates
166    def integrand(phi, theta):
167        return r**2 * np.sin(phi)
168
169    # Integrate
170    result, error = integrate.dblquad(
171        integrand,
172        0, 2*np.pi,           # θ limits
173        lambda x: 0, lambda x: np.pi  # φ limits
174    )
175
176    analytical = 4 * np.pi * r**2
177
178    print(f"Sphere radius: r = {r}")
179    print(f"\nSurface area:")
180    print(f"  Numerical: {result:.6f}")
181    print(f"  Analytical (4πr²): {analytical:.6f}")
182
183    print("\nSpherical coordinates naturally involve sin(φ) and cos(φ)")
184    print("in the Jacobian and surface element calculations.")
185
186    return result
187
188# Run demonstrations
189physics_gravitational_potential()
190electric_field_disk()
191engineering_cable_tension()
192ml_von_mises_distribution()
193geometry_surface_area_sphere()

Common Mistakes to Avoid

Mistake 1: Wrong Substitution Choice

Wrong: Using x=asinθx = a\sin\theta for a2+x2\sqrt{a^2 + x^2}

This gives a2+a2sin2θ=a1+sin2θ\sqrt{a^2 + a^2\sin^2\theta} = a\sqrt{1 + \sin^2\theta}, which doesn't simplify nicely.

Correct: Use x=atanθx = a\tan\theta to get asecθa\sec\theta.

Mistake 2: Forgetting dx

When substituting x=asinθx = a\sin\theta, don't forget to also substitute dx=acosθdθdx = a\cos\theta \, d\theta. The dxdx term is crucial!

Mistake 3: Wrong Domain for θ

Each substitution has a specific valid range for θ\theta:

  • x=asinθx = a\sin\theta: π2θπ2-\frac{\pi}{2} \leq \theta \leq \frac{\pi}{2}
  • x=atanθx = a\tan\theta: π2<θ<π2-\frac{\pi}{2} < \theta < \frac{\pi}{2}
  • x=asecθx = a\sec\theta: 0θ<π20 \leq \theta < \frac{\pi}{2} or π2<θπ\frac{\pi}{2} < \theta \leq \pi

Mistake 4: Not Simplifying |cos θ| Correctly

cos2θ=cosθ\sqrt{\cos^2\theta} = |\cos\theta|, not just cosθ\cos\theta. Within the standard domain π2θπ2-\frac{\pi}{2} \leq \theta \leq \frac{\pi}{2}, we have cosθ0\cos\theta \geq 0, so cosθ=cosθ|\cos\theta| = \cos\theta.

Mistake 5: Incomplete Back-Substitution

After integrating, you must convert all trigonometric functions back to expressions in xx. Use the reference triangle to find sinθ\sin\theta, cosθ\cos\theta, etc. in terms of xx.


Test Your Understanding

Question 1 of 8Score: 0

Which substitution should you use for ∫ √(9 - x²) dx?


Summary

Trigonometric substitution is a powerful technique for evaluating integrals containing square roots of sums and differences of squares. It exploits the Pythagorean identity to eliminate radicals.

The Three Substitutions

ExpressionSubstitutionResult
√(a² - x²)x = a·sin(θ)a·cos(θ)
√(a² + x²)x = a·tan(θ)a·sec(θ)
√(x² - a²)x = a·sec(θ)a·tan(θ)

Key Takeaways

  1. Recognize the pattern: Look for a2±x2\sqrt{a^2 \pm x^2} or x2a2\sqrt{x^2 - a^2}
  2. Choose the right substitution: Match the expression to the appropriate Pythagorean identity
  3. Don't forget dx: Transform both the integrand and the differential
  4. Use the reference triangle: Convert back to xx using geometric relationships
  5. Complete the square when needed: Transformax2+bx+cax^2 + bx + c to standard form
  6. Transform limits for definite integrals: Work entirely in θ\theta when possible
The Core Insight:
"The Pythagorean theorem connects algebra to geometry, and trigonometric substitution harnesses this connection to simplify otherwise intractable integrals."
Coming Next: In Partial Fraction Decomposition, we'll learn how to integrate rational functions by breaking them into simpler pieces.
Loading comments...