## Half Angle Substitution

Here’s a neat substitution for integration that I never learned from calculus subjects but found in a book. I also frequently forget the formulae so whenever I want to use it I need to re-derive everything, hopefully writing it here will help me remember.

If $x$ is our integration variable, then we make the substitution $x = \tan(t/2)$. Using the trig identities, we can now get expressions for trigonometric functions in terms of $t$.

$\sin x = 2\sin \frac{x}{2}\cos \frac{x}{2}$
$= 2\tan\frac{x}{2}\cos^2\frac{x}{2}$
$= 2\frac{t}{\sec^2(x/2)}$
$= 2t/(t^2+1)$.

$\cos x = 1 - 2\sin^2\frac{x}{2}$
$= 1 - 2\tan^2\frac{x}{2}\cos^2\frac{x}{2}$
$= (t^2+1-2t^2)/(t^2+1)$
$= (1-t^2)/(1+t^2)$

$\tan x = \sin x /\cos x$
$= 2t/(1-t^2)$

And of course $dt = \frac{1}{2}\sec^2\frac{x}{2}dx$ so $dx = 2dt/(1+t^2)$.
Now we can work out things like $\int \csc x dx$, which is given by
$\int dt/t = \ln\tan\frac{x}{2} + c$

I didn’t create this blog until after Pi day, so unfortunately I’m a bit late. I celebrate Pi day by deriving the same series expression for pi every year. I’m not sure who to attribute this particular method to, but I definitely learned in from some old calculus book once upon a time. It’s as simple as calculating $\int_0^1\frac{1}{x^2+1}dx$ two different ways and equating the results. First up, we can make the substitution $x = \tan\theta$ and simplify yielding $\int_0^{\pi/4}d\theta = \frac{\pi}{4}$. On the other hand, if $|x|<1$ then $\sum_{n=0}^\infty(-1)^nx^{2n}$ converges (uniformly on all intervals $|x|\leq r < 1$) to $\frac{1}{x^2+1}$, and so may proceed with
$\int_0^1\frac{1}{1+x^2}dx = \sum_{n=0}^\infty(-1)^n\int_0^1x^{2n}dx$. Each $\int_0^1x^{2n}dx = \frac{1}{2n+1}$, and so putting it all together we’re left with
$\pi = 4\sum_{n=0}^\infty \frac{(-1)^n}{2n+1} = 4(1-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+...)$