Content from 2015-02

The Derivation of Cosine

posted on 2015-02-08 15:10:00

Trigonometry introduces us to a class of new functions which allow us to, among other things, work with angles and solve triangles. We learn about sine and cosine, starting off by defining them as ratios of side lengths of a triangle, and then seeing their relationship to the unit circle. However, one thing is typically left missing: how does one derive the sine and cosine functions? I don't mean "derive" as in "differentiate", I mean "create".

It turns out that calculus is a huge aid here.

Suppose we draw a point \((x,y)\) on the unit circle. For simplicity's sake, let's assume the first quadrant only. Both drawing the radius to this point, and dropping a perpendicular from this point allows us to visualize each Cartesian coordinate as sides of a right triangle. We see that \[x^2 + y^2 = 1.\] If we choose, we can solve for the \(y\)-coordinate to get a closed-form expression for the circle in this quadrant: \[y = \sqrt{1 - x^2}.\]

Finding what the sine and cosine functions are is equivalent to finding a parameterization of \((x,y)\), parameterized by angle. For a circle, angle is defined as the distance along the circumference divided by the radius. Hence, for a unit circle, this is just a unitless measure equal to the arclength of an arc of the circle.

If the unit circle is parameterized by \(\vec r = (x(\theta), y(\theta))\), then we know the unit tangent vector \(\vec T\) is just the derivative of the components: \[\vec T = \left(\frac{dx}{d\theta},\frac{dy}{d\theta}\right).\] From a geometric point of view, a vector can only have two distinct (unit) perpendicular vectors; the vector \((x,y)\) is perpendicular to both \((-y,x)\) and its negation \(-(-y,x)=(y,-x)\). Let's verify thos holds true around the entire unit circle.

Unit circle

Observe that the slope of the vector \(\vec r\) is just \(y/x\). Given we know that \(y=\sqrt{1-x^2}\), we can differentiate this with respect to \(x\) to get \[\frac{dy}{dx} = -\frac{x}{\sqrt{1-x^2}}.\] But this itself is just \(-x/y\), which is the slope of the tangent vector \((-y,x)\). (We choose this tangent vector because we want it to be pointing in the positive \(y\) direction at \((1,0)\).)

Since \[\vec T = (-y,x) = \left(\frac{dx}{d\theta},\frac{dy}{d\theta}\right),\] we arrive at the set of equations

\begin{align} \frac{dx}{d\theta} &= -y\\ \frac{dy}{d\theta} &= x. \end{align}

Taking the first equation and differentiating both sides gives

\begin{equation} \frac{d^2x}{d\theta^2} = -\frac{dy}{d\theta} \end{equation}

which of course, back-substituting, gives

\begin{equation} \frac{d^2x}{d\theta^2} = -x. \end{equation}

This is the familiar differential equation that we know the sine function satisfies. It also turns out to be the differential equation that will allow us to compute the Taylor series, which gives us a constructive definition of sine.

Suppose that \(x = x(\theta)\) has the Maclaurin expansion

\begin{align} x(\theta) = \sum_{k=0}^{\infty} a_k\theta^k. \end{align}

Differentiating twice gives

\begin{align} x''(\theta) = \sum_{k=2}^{\infty} k(k-1)a_k\theta^{k-2}. \end{align}

Note the change in the lower index, where two constant terms got dropped off. But this series is equal to the negation of the original, so

\begin{align} \sum_{k=2}^{\infty} k(k-1)a_k\theta^{k-2} &= -\sum_{k=0}^{\infty} a_k \theta^k\\ &= -\sum_{k=2}^{\infty} a_{k-2} \theta^{k-2}. \end{align}

Matching coefficients, we have \(k(k-1)a_k = -a_{k-2}\). Rearranging gives \[a_k = -\frac{a_{k-2}}{k(k-1)}.\] This is a recurrence relation which we can solve, once we find some boundary conditions.

The coefficients of a Maclaurin series are determined by the derivatives of the function being approximated. Namely, \[a_k = \frac{x^{(k)}(0)}{k!}.\] We will use this to compute two boundary conditions.

Since \((x(0),y(0)) = (1,0)\), then from our basic vector and tangent relations, we know that \((x'(0),y'(0)) = (0,1)\). Hence, \(x'(0) = 0\), which means \(x'(0) \propto a_1 = 0\). Since our recurrence relation is purely multiplicative, every odd-indexed term must be zero. This just leaves the even terms.

Using \(x(0) = 1\), we can tabulate a few terms, and see a general pattern immediately.

\begin{align} a_0 &= 1\\ a_2 &= -\frac{1}{2(2-1)} = -\frac{1}{2\cdot 1}\\ a_4 &= -\frac{-\frac{1}{2\cdot 1}}{4(4-1)} = \frac{1}{4\cdot 3\cdot 2\cdot 1}\\ a_6 &= -\frac{\frac{1}{4\cdot 3\cdot 2\cdot 1}}{6(6-1)} = -\frac{1}{6!}\\ \vdots &= \vdots\\ a_k &= (-1)^{k/2}\frac{1}{k!}. \end{align}

Substituting this into our original Maclaurin series gives us

\begin{align} x(\theta) &= \sum_{k=0,\ k\text{ even}}^{\infty} (-1)^{k/2}\frac{1}{k!}\theta^k, \end{align}

which can be written with \(k\mapsto 2k\) as

\begin{align} x(\theta) &= \sum_{k=0}^{\infty} (-1)^{k}\frac{1}{(2k)!}\theta^{2k}. \end{align}

As desired, this is the definition of cosine. Tidying up, we have

\begin{align} \cos \theta &= \sum_{k=0}^{\infty} (-1)^{k}\frac{\theta^{2k}}{(2k)!}. \end{align}

This blog covers tutorial, scheme, retro, programming, math, lisp

View content from 2014-06, 2015-01, 2015-02

Unless otherwise credited all material Copyright © 2015-2018 by Robert Smith