# Calculus/Integration techniques/Tangent Half Angle

 ← Integration techniques/Partial Fraction Decomposition Calculus Integration techniques/Reduction Formula → Integration techniques/Tangent Half Angle

Another useful change of variables is the Weierstrass substitution, named after Karl Weierstrass:

$t=\tan (x/2) \,$

With this transformation, using the double-angle trigonometric identities,

$\sin x =\frac{2t}{1+t^2} \quad \cos x = \frac{1-t^2}{1+t^2} \quad \tan x = \frac{2t}{1-t^2} \quad dx=\frac{2 \, dt}{1+t^2}$

This transforms a trigonometric integral into a algebraic integral, which may be easier to integrate.

For example, if the integrand is 1/(1 + sin x) then

\begin{align} & {}\quad \int_0^{\pi/2} \frac{dx}{1 + \sin x} = \int_0^1 \frac{\left(\frac{2\,dt}{1+t^2}\right)}{1 + \left(\frac{2t}{1+t^2}\right)} \\[8pt] & = \int_0^1 \frac{2\,dt}{(t+1)^2}\\[8pt] \end{align}

This method can be used to further simplify trigonometric integrals produced by the changes of variables described earlier.

For example, if we are considering the integral

$I = \int_{-1}^1 \frac{\sqrt{1-x^2}}{1+x^2} \, dx$

we can first use the substitution x = sin θ, which gives

$I = \int_{-\pi/2}^{\pi/2} \frac{ \cos^2 \theta}{1+ \sin^2 \theta} \, d\theta$

then use the tan-half-angle substition to obtain

$I = \int_{-1}^1 \frac{(1-t^2)^2}{1+6t^2+t^4}\frac{2 \, dt}{1+t^2}$

In effect, we've removed the square root from the original integrand. We could do this with a single change of variables, but doing it in two steps gives us the opportunity of doing the trigonometric integral another way.

Having done this, we can split the new integrand into partial fractions, and integrate.

\begin{align} I & = \int_{-1}^1 \frac{2-\sqrt{2}}{t^2+3-\sqrt{8}} \, dt + \int_{-1}^1 \frac{2+\sqrt{2}}{t^2+3+\sqrt{8}} \, dt - \int_{-1}^1 \frac{2}{1+t^2} \, dt \\[8pt] & = \frac{4-\sqrt{8}}{\sqrt{3-\sqrt{8}}} \tan^{-1} \left(\sqrt{3+\sqrt{8}}\,\right) + \frac{4+\sqrt{8}}{\sqrt{3+\sqrt{8}}} \tan^{-1}\left(\sqrt{3-\sqrt{8}}\,\right) - \pi \end{align}

This result can be further simplified by use of the identities

$3 \pm \sqrt{8}= \left( \sqrt{2} \pm 1 \right)^2 \quad \tan^{-1} \left( \sqrt{2} \pm 1 \right) = \left( \frac{1}{4} \pm \frac{1}{8} \right)\pi$

$I=(\sqrt{2}-1)\pi \,$

In principle, this approach will work with any integrand which is the square root of a quadratic multiplied by the ratio of two polynomials. However, it should not be applied automatically.

E.g., in this last example, once we deduced

$I = \int_{-\pi/2}^{\pi/2} \frac{ \cos^2 \theta}{1+ \sin^2 \theta} \, d\theta$

we could have used the double angle formula, since this contains only even powers of cos and sin. Doing that gives

$I = \int_{-\pi/2}^{\pi/2} \frac{1+\cos 2\theta}{3 - \cos 2\theta} d\theta = \frac{1}{2} \int_{-\pi}^\pi \frac{1+\cos \phi}{3 - \cos \phi} \, d\phi$

Using tan-half-angle on this new, simpler, integrand gives

\begin{align} I & = \int_{-\infty}^\infty \frac{1}{1+2t^2} \frac{dt}{1+t^2} \\ &= \int_{-\infty}^\infty \frac{2 \, dt}{1+2t^2} - \int_{-\infty}^\infty \frac{dt}{1+t^2} \end{align}

This can be integrated on sight to give

$I = \frac{4}{\sqrt{2}}\frac{\pi}{2}-2\frac{\pi}{2} = (\sqrt{2}-1) \pi$

This is the same result as before, but obtained with less algebra, which shows why it is best to look for the most straightforward methods at every stage.

A more direct way of evaluating the integral I is to substitute t = tan θ right from the start, which will directly bring us to the line

$I = \int_{-\infty}^\infty \frac{1}{1+2t^2} \frac{dt}{1+t^2}$

above. More generally, the substitution t = tan x gives us

$\sin x =\frac{t}{\sqrt{1+t^2}} \quad \cos x = \frac{1}{\sqrt{1+t^2}} \quad dx=\frac{dt}{1+t^2}$

so this substitution is the preferable one to use if the integrand is such that all the square roots would disappear after substitution, as is the case in the above integral.

Example

Using the trigonometric substitution $t=a\tan x$, then $dt=a\sec^2 x\, dx$ and $\sqrt{t^2+a^2} = a\sec x$ (when $-\pi/2 < x < \pi/2$). So,

\begin{align} \int \frac{1}{\left(t^2+a^2\right)^\frac{3}{2}}\,dt & = \int \frac{1}{a^3 \sec^3 x}\, a\sec^2 x\,dx \\[8pt] & = \frac{1}{a^2} \int \cos x\,dx \\[8pt] & = \frac{1}{a^2} \sin x + C \\[8pt] & = \frac{1}{a^2} \frac{a\tan x}{a\sec x} + C \\[8pt] & = \frac{t}{a^2 \sqrt{t^2+a^2}} + C \end{align}

### Alternate Method

In general, to evaluate integrals of the form

$\int \frac{A + B \cos x + C \sin x}{a + b \cos x + c \sin x} \, dx,$

it is extremely tedious to use the aforementioned "tan half angle" substitution directly, as one easily ends up with a rational function with a 4th degree denominator. Instead, we may first write the numerator as

$A + B \cos x + C \sin x \equiv p (a + b \cos x + c \sin x) + q \frac{d}{dx} (a + b \cos x + c \sin x) + r.$

Then the integral can be written as

$\int \left(p+\frac{q \frac{d}{dx} (a + b \cos x + c \sin x)}{a + b \cos x + c \sin x} + \frac{r}{a + b \cos x + c \sin x} \right) \, dx$

which can be evaluated much more easily.

#### Example

Evaluate $\int \frac{\cos x + 2}{\cos x + \sin x} \, dx,$

Let

$\cos x + 2 \equiv p (\cos x + \sin x) + q \frac{d}{dx} (\cos x + \sin x) + r.$

Then

$\cos x + 2 \equiv p (\cos x + \sin x) + q (-\sin x + \cos x) + r$
$\cos x + 2 \equiv (p+q) \cos x + (p-q) \sin x + r.$

Comparing coefficients of cos x, sin x and the constants on both sides, we obtain

$\begin{cases} p+q & = 1 \\ p-q & = 0 \\ r & = 2 \end{cases}$

yielding p = q = 1/2, r = 2. Substituting back into the integrand,

$\int \frac{\cos x + 2}{\cos x + \sin x} \, dx = \int \frac{1}{2} \, dx + \frac{1}{2} \int \frac{d(\cos x + \sin x)}{\cos x + \sin x} + \int \frac{2}{\cos x + \sin x} \, dx.$

The last integral can now be evaluated using the "tan half angle" substitution described above, and we obtain

$\int \frac{2}{\cos x + \sin x} \, dx = \sqrt{2} \ln \left| \frac{\tan \frac{x}{2} - 1 + \sqrt{2}}{\tan \frac{x}{2} - 1 - \sqrt{2}} \right| + C.$

The original integral is thus

$\int \frac{\cos x + 2}{\cos x + \sin x} \, dx = \frac{x}{2} + \frac{1}{2} \ln |\cos x + \sin x| + \sqrt{2} \ln \left| \frac{\tan \frac{x}{2} - 1 + \sqrt{2}}{\tan \frac{x}{2} - 1 - \sqrt{2}} \right| + C.$
 ← Integration techniques/Partial Fraction Decomposition Calculus Integration techniques/Reduction Formula → Integration techniques/Tangent Half Angle