---
title: Trigonometric substitution
heading: The field of a wire, one triangle at a time
eyebrow: A6 · Lesson 3 · Trigonometric substitution
xp: 40
---

::: hook
The electric field near a charged wire, the magnetic field near a current-carrying trace, the potential of a charged disk: each is an integral with $\sqrt{a^2 + x^2}$ or $(a^2 + x^2)^{3/2}$ in it, because distance from a point to a line is the hypotenuse of a right triangle. The way through is to let the triangle do the work: substitute an angle for $x$, and the square root collapses to a single trig function.
:::

::: play
- A wire runs along the $x$ axis from $-L$ to $L$. You're at distance $a$ above its middle. The curve is the strength of each bit's contribution, $\frac{a}{(a^2 + x^2)^{3/2}}$.
- Lengthen the wire. Does the total (the area) keep growing?
- Compare the readout with the formula from trig substitution.
:::
:::

```sim plot
view: graph
x: x = -10..10
y: y = 0..1.1
slider: a = 1..3 step 0.1 = 1
slider: L = 0.5..10 step 0.1 = 2
plot: a/(a^2 + x^2)^1.5 | label: contribution
plot: a/(a^2 + x^2)^1.5 | fill: -L..L | color: ch2
readout: total = 2*L/(a*sqrt(a^2 + L^2)) | digits: 5
readout: infinite wire = 2/a | digits: 5
```

::: predict
## As the wire gets infinitely long, what does the total $\int_{-L}^{L}\frac{a\,dx}{(a^2 + x^2)^{3/2}}$ approach?

- [ ] It grows without limit
- [x] $2/a$
- [ ] $1/a^2$
- [ ] $\pi/a$

::: reveal
$2/a$. The far parts of the wire contribute less and less, fast enough that the total converges. With $x = a\tan\theta$ the integral becomes $\frac{1}{a}\int\cos\theta\,d\theta$, and as $L \to \infty$ the angle runs from $-90°$ to $90°$. That $1/a$ is why the field of a long wire falls off as one over the distance.
:::
:::

::: nameit
## Three substitutions

Each turns a square root into a single term using a Pythagorean identity:

| Expression | Substitute | Identity used | Becomes |
|---|---|---|---|
| $\sqrt{a^2 - x^2}$ | $x = a\sin\theta$ | $1 - \sin^2 = \cos^2$ | $a\cos\theta$ |
| $\sqrt{a^2 + x^2}$ | $x = a\tan\theta$ | $1 + \tan^2 = \sec^2$ | $a\sec\theta$ |
| $\sqrt{x^2 - a^2}$ | $x = a\sec\theta$ | $\sec^2 - 1 = \tan^2$ | $a\tan\theta$ |

Remember $dx$ changes too: with $x = a\tan\theta$, $dx = a\sec^2\theta\,d\theta$. To return to $x$, draw the right triangle with the substitution's ratio on two sides.

## Two results worth knowing

$$\int\frac{dx}{\sqrt{a^2 - x^2}} = \sin^{-1}\frac{x}{a} + C \qquad \int\frac{dx}{a^2 + x^2} = \frac{1}{a}\tan^{-1}\frac{x}{a} + C$$

## The wire integral

With $x = a\tan\theta$: $(a^2 + x^2)^{3/2} = a^3\sec^3\theta$ and $dx = a\sec^2\theta\,d\theta$, so

$$\int\frac{a\,dx}{(a^2 + x^2)^{3/2}} = \int\frac{a \cdot a\sec^2\theta}{a^3\sec^3\theta}d\theta = \frac{1}{a}\int\cos\theta\,d\theta = \frac{\sin\theta}{a} = \frac{x}{a\sqrt{a^2 + x^2}}$$

From $-L$ to $L$: $\frac{2L}{a\sqrt{a^2 + L^2}}$, which tends to $2/a$ for a long wire. B2 and B5 use exactly this for the fields of charged lines and current-carrying wires.
:::

::: example
## Find the area of a circle of radius $r$ by integration.

::: solution
1. **Set up the integral.** The upper half is $y = \sqrt{r^2 - x^2}$, so the area is
   $$A = 2\int_{-r}^{r}\sqrt{r^2 - x^2}\,dx$$
2. **Substitute $x = r\sin\theta$.** Then $dx = r\cos\theta\,d\theta$, and $\theta$ runs from $-\pi/2$ to $\pi/2$:
   $$\begin{aligned} A &= 2\int_{-\pi/2}^{\pi/2}r^2\cos^2\theta\,d\theta \\ &= 2r^2 \cdot \frac{\pi}{2} \\ &= \pi r^2 \end{aligned}$$

**Answer:** the area is $\pi r^2$.
:::
:::

::: example
## Evaluate $\displaystyle\int_0^{2}\frac{dx}{4 + x^2}$.

::: solution
1. **Use the arctangent form with $a = 2$.**
   $$\int\frac{dx}{4 + x^2} = \frac{1}{2}\tan^{-1}\frac{x}{2}$$
2. **Evaluate from 0 to 2.**
   $$\begin{aligned} \frac{1}{2}\tan^{-1}\frac{x}{2}\Big|_0^2 &= \frac{1}{2}\cdot\frac{\pi}{4} \\ &= \frac{\pi}{8} \\ &= 0.393 \end{aligned}$$

**Answer:** the integral is $\frac{\pi}{8} = 0.393$.
:::
:::

::: example
## Evaluate $\displaystyle\int_0^3\frac{dx}{\sqrt{9 + x^2}}$.

::: solution
1. **Substitute $x = 3\tan\theta$.** Then $dx = 3\sec^2\theta\,d\theta$ and $\sqrt{9 + x^2} = 3\sec\theta$:
   $$\begin{aligned} \int\frac{dx}{\sqrt{9 + x^2}} &= \int\sec\theta\,d\theta \\ &= \ln|\sec\theta + \tan\theta| \end{aligned}$$
2. **Evaluate at the limits.** At $x = 3$, $\tan\theta = 1$ and $\sec\theta = \sqrt2$; at 0, both terms give $\ln 1 = 0$:
   $$\begin{aligned} \int_0^3\frac{dx}{\sqrt{9 + x^2}} &= \ln(1 + \sqrt2) \\ &= 0.881 \end{aligned}$$
   which is $\sinh^{-1}1$.

**Answer:** the integral is $\ln(1 + \sqrt2) = 0.881$, which is $\sinh^{-1}1$.
:::
:::

::: check
given: a = 1 | 2 | 3; L = 1 | 4
answer: 2*L/(a*sqrt(a^2 + L^2))
tolerance: 0.5%

## Evaluate $\displaystyle\int_{-\given{L}}^{\given{L}}\frac{\given{a}\,dx}{(\given{a}^2 + x^2)^{3/2}}$.

::: right
Right. $\frac{x}{a\sqrt{a^2 + x^2}}$ from $-L$ to $L$ gives {answer}.
:::

::: misses
- [2/a] That's the infinitely long wire. This one stops at ±{L}.
- [L/(a*sqrt(a^2 + L^2))] That's only half: integrate from $-L$ to $L$.
- [any] Not yet. Substitute $x = a\tan\theta$.
:::
:::

::: check
given: a = 2 | 3 | 5; b = 1 | 4
answer: atan(b/a)/a
tolerance: 0.5%

## Evaluate $\displaystyle\int_0^{\given{b}}\frac{dx}{\given{a}^2 + x^2}$.

::: right
Right. $\frac{1}{a}\tan^{-1}\frac{b}{a}$ = {answer}.
:::

::: misses
- [atan(b/a)] Divide by $a$.
- [atan(b)/a] The argument is $x/a$.
- [any] Not yet. $\int\frac{dx}{a^2 + x^2} = \frac{1}{a}\tan^{-1}\frac{x}{a}$.
:::
:::

::: check
given: r = 1 | 2 | 5
answer: pi*r^2/4
tolerance: 0.5%

## Evaluate $\displaystyle\int_0^{\given{r}}\sqrt{\given{r}^2 - x^2}\,dx$.

::: right
Right. It's a quarter of a circle of radius {r}: $\pi r^2/4$.
:::

::: misses
- [pi*r^2/2] That's a half-circle. From 0 to $r$ under the upper half is a quarter.
- [r^2] Use $x = r\sin\theta$; the integral becomes $r^2\int_0^{\pi/2}\cos^2\theta\,d\theta$.
- [any] Not yet. Substitute $x = r\sin\theta$, or recognize the shape.
:::
:::

::: check
given: a = 2 | 4; b = 1 | 2
answer: asin(b/a)
tolerance: 0.5%

## Evaluate $\displaystyle\int_0^{\given{b}}\frac{dx}{\sqrt{\given{a}^2 - x^2}}$.

::: right
Right. $\sin^{-1}\frac{b}{a}$ = {answer} rad.
:::

::: misses
- [asin(b/a)/a] Unlike the arctangent formula, there's no $1/a$ in front.
- [any] Not yet. $x = a\sin\theta$ turns it into $\int d\theta$.
:::
:::

::: check
kind: parts
given: a = 1 | 3 | 4; b = 1 | 2

## Use trigonometric substitution.

::: part
answer: asinh(b/a)
tolerance: 0.5%

### $\displaystyle\int_0^{\given{b}}\frac{dx}{\sqrt{\given{a}^2 + x^2}}$

::: misses
- [atan(b/a)/a] That's $\int\frac{dx}{a^2 + x^2}$, without the square root.
- [any] $x = a\tan\theta$ gives $\int\sec\theta\,d\theta$.
:::
:::

::: part
answer: b/(a^2*sqrt(a^2 + b^2))
tolerance: 0.5%

### $\displaystyle\int_0^{\given{b}}\frac{dx}{(\given{a}^2 + x^2)^{3/2}}$

::: misses
- [any] $x = a\tan\theta$ gives $\frac{1}{a^2}\int\cos\theta\,d\theta = \frac{\sin\theta}{a^2}$.
:::
:::
:::

::: check
kind: derivation
vars: a = 1..5, x = -3..3, t = -1.2..1.2

## Use $x = a\tan\theta$ on $\displaystyle\int\frac{dx}{(a^2 + x^2)^{3/2}}$.

::: step
answer: a^3/cos(t)^3

### With $\theta$ written as $t$, what is $(a^2 + x^2)^{3/2}$ in terms of $\theta$?
:::

::: step
answer: sin(t)/a^2

### $dx = a\sec^2\theta\,d\theta$. The integral becomes $\frac{1}{a^2}\int\cos\theta\,d\theta$. What is it?
:::

::: step
answer: x/(a^2*sqrt(a^2 + x^2))

### Write it back in terms of $x$.
:::

::: right
Right. That's the integral behind the field of a straight wire of finite length.
:::
:::

::: explain
## Why does the substitution $x = a\tan\theta$ simplify $\sqrt{a^2 + x^2}$?

::: model
With $x = a\tan\theta$, $a^2 + x^2 = a^2(1 + \tan^2\theta) = a^2\sec^2\theta$, using the identity $1 + \tan^2 = \sec^2$. The square root becomes $a\sec\theta$, a single term, so the awkward root disappears. Geometrically, $x$ and $a$ are the two legs of a right triangle and $\sqrt{a^2 + x^2}$ is its hypotenuse; describing the triangle by its angle makes all three sides simple multiples of $a$.
:::
:::

::: practice

::: check
given: a = 1..8 int
answer: 2/a
tolerance: 0.5%

## Evaluate $\displaystyle\int_{-\infty}^{\infty}\frac{\given{a}\,dx}{(\given{a}^2 + x^2)^{3/2}}$.

::: misses
- [any] The long-wire limit, $2/a$.
:::
:::

::: check
given: a = 2..9 int
answer: pi/a
tolerance: 0.5%

## Evaluate $\displaystyle\int_{-\infty}^{\infty}\frac{dx}{\given{a}^2 + x^2}$.

::: misses
- [pi] Divide by $a$.
- [any] $\frac{1}{a}\tan^{-1}\frac{x}{a}$ from $-\pi/2$ to $\pi/2$.
:::
:::

::: check
given: r = 1..8 int
answer: pi*r^2/2
tolerance: 0.5%

## Evaluate $\displaystyle\int_{-\given{r}}^{\given{r}}\sqrt{\given{r}^2 - x^2}\,dx$.

::: misses
- [pi*r^2] That's the whole circle.
- [any] A half-circle.
:::
:::
:::
