# The Unapologetic Mathematician

## Sine and Cosine

Now I want to consider the differential equation $f''(x)+f(x)=0$. As I mentioned at the end of last time, we can write this as $f''(x)=(-1)f(x)$ and find two solutions — $\exp(ix)$ and $\exp(-ix)$ — by taking the two complex square roots of $-1$. But the equation doesn’t use any complex numbers. Surely we can find real-valued functions that work.

Indeed, we can, and we’ll use the same techniques as we did before. We again find that any solution must be infinitely differentiable, and so we will assume that it’s analytic. Thus we write

$\displaystyle f(x)=\sum\limits_{k=0}^\infty a_kx^k$

and we take the first two derivatives

$\displaystyle f'(x)=\sum\limits_{k=0}^\infty(k+1)a_{k+1}x^k$
$\displaystyle f''(x)=\sum\limits_{k=0}^\infty(k+2)(k+1)a_{k+2}x^k$

The equation then reads

$\displaystyle a_{k+2}=-\frac{a_k}{(k+2)(k+1)}$

for every natural number $k$. The values $a_0=f(0)$ and $a_1=f'(0)$ are not specified, and we can use them to set initial conditions.

We pick two sets of initial conditions to focus on. In the first case, $f(0)=0$ and $f'(0)=1$, while in the second case $f(0)=1$ and $f'(0)=0$. We call these two solutions the “sine” and “cosine” functions, respectively, writing them as $\sin(x)$ and $\cos(x)$.

Let’s work out the series for the cosine function. We start with $a_1=0$, and the recurrence relation tells us that all the odd terms will be zero. So let’s just write out the even terms $a_{2k}$. First off, $a_0=1$. Then to move from $a_{2k}$ to $a_{2k+2)}$ we multiply by $\frac{-1}{(2k+1)(2k+2)}$. So in moving from $a_0$ all the way to $a_{2k}$ we’ve multiplied by $-1$ $k$ times, and we’ve multiplied up every number from ${1}$ to $2k$. That is, we have $a_{2k}=\frac{(-1)^k}{(2k)!}$, and we have the series

$\displaystyle\cos(x)=\sum\limits_{k=0}^\infty\frac{(-1)^kx^{2k}}{(2k)!}$

This isn’t the usual form for a power series, but it’s more compact than including all the odd terms. A similar line of reasoning leads to the following series expansion for the sine function:

$\displaystyle\sin(x)=\sum\limits_{k=0}^\infty\frac{(-1)^kx^{2k+1}}{(2k+1)!}$

Any other solution with $f(0)=a$ and $f'(0)=b$ then can be written as $a\cos(x)+b\sin(x)$.

In particular, consider the first solutions we found above: $f(x)=\exp(ix)$ and $f(x)=\exp(-ix)$. Each of them has $f(0)=1$, and $f'(0)=\pm i$, depending on which solution we pick. That is, we can write $\exp(ix)=\cos(x)+i\sin(x)$, and $\exp(-ix)=\cos(x)-i\sin(x)$.

Of course, the second of these equations is just the complex conjugate of the first, and so it’s unsurprising. The first, however, is called “Euler’s formula”, because it was proved by Roger Cotes. It’s been seen as particularly miraculous, but this is mostly because people’s first exposure to the sine and cosine functions usually comes from a completely different route, and the relationship between exponentials and trigonometry seems utterly mysterious. Seen from the perspective of differential equations (and other viewpoints we’ll see sooner or later) it’s the most natural thing in the world.

Euler’s formula also lets us translate back from trigonometry into exponentials:

$\displaystyle\cos(x)=\frac{\exp(ix)+\exp(-ix)}{2}$
$\displaystyle\sin(x)=\frac{\exp(ix)-\exp(-ix)}{2i}$

And from these formulæ and the differentiation rules for exponentials we can easily work out the differentiation rules for the sine and cosine functions:

$\displaystyle\sin'(x)=\cos(x)$
$\displaystyle\cos'(x)=-\sin(x)$

October 13, 2008