This section discusses periodic functions, specifically using
the trigonometric functions of sine and cosine as models for periodic
functions.
A periodic function captures the idea of cycles that repeat perfectly
and indefinitely.
Oscillatory waves can be modeled with periodic functions, including
sound, light and radio waves.
The spiking patterns of a neuron can be modeled with periodic functions.
Cyclic patterns in populations can even be modeled with periodic functions.

Periodic functions are characterized by basic features.
One of the most fundamental features is called the period, which is
how much the input of the function needs to increase before the function
exactly repeats its output.
When a wave is observered spatially, the period of the function
corresponds to the wavelength.
When a wave is observed temporally (in time), the period of the function
corresponds to the physical period, or the time between repeating cycles.

Subsection7.3.2A Barebones Review of Sine and Cosine

The appendix has a much more detailed discussion of trigonometric functions.
For our purposes, all that I really want to review is the oscillatory
behavior of the sine and cosine functions as prototypes of periodic
functions. One dynamical perspective of the graphs results from
considering a point that moves around a unit circle at a steady speed.

The point starts at the position \((1,0)\). We consider counter-clockwise
rotation as positive motion and clockwise rotation as negative motion, and
we measure the distance \(x\) the point travels along the circumference.
(This is what the radian measure of an angle measures: the distance traveled
on a unit circle.)
The sine function gives from the vertical position of the point after
traveling some distance along the circumference of the unit circle.
The cosine function gives the horizontal position of the point.
Thus, based on our starting point \((1,0)\), we have
\begin{equation*}\sin(0) = 0 \qquad \cos(0) = 1.\end{equation*}
In addition, because both the horizontal and vertical coordinates of the unit
circle remain between -1 and 1, we know that the sine and cosine oscillate
between a minimum at -1 and a maximum at +1,
\begin{equation*}-1 \le \sin(x) \le 1 \qquad -1 \le \cos(x) \le 1. \end{equation*}

As soon as the point travels a distance of \(2\pi\), it has completed a full
revolution of the circle and it is as though it is revisiting the same points.
This is why the sine and cosine functions are periodic with a period \(2 \pi\).

As a consequence of their unit circle definitions,
the sine and cosine functions are especially symmetric.
For example, the cosine function is an even function,
which means that if you reflect the graph horizontally over the \(y\)-axis,
the graph is unchanged. This graphical view is expressed in an equation as
\begin{equation*} \cos(-x) = \cos(x). \end{equation*}
That is, if the graph \(y=\cos(x)\) includes some point \((x,y)=(a,b)\),
then the opposite point \((x,y)=(-a,b)\)
(changing only the \(x\)-coordinate) is also in the graph.

How do you read or interpret that equation? On the left, we see the expression
\(\cos(-x)\). In the language of transformations, we have an original graph
\(y=\cos(x)\). This expression corresponds to a new relation \(v=\cos(-u)\)
so that our transformed variables are \(v=y\) and \(x=-u\). That is,
\(\cos(-x)\) is the function that corresponds to changing all \(x\)-coordinates
by multiplying by -1 (or switching positive/negative sides on the number line).
So the equation is saying, on the left, if you take the graph of \(\cos(x)\)
and flip all points from left-to-right, then this is exactly equal to the
original graph. Again, note that changing variables to interpret the transformation
is a convenience and not necessary. You should practice to where this extra
step becomes unnecessary.

While the cosine function is even, the sine function is an odd function.
This means that if you do a horizontal reflection, instead of getting the original
function, you instead get what would be equivalent to a vertical reflection. This
is expressed mathematically by the equation
\begin{equation*} \sin(-x) = - \sin(x). \end{equation*}
Do you see how each side of the equation represents a different transformation,
and the equation says that the two different transformations result in the same thing?
Graphically, this is the same as saying the graph has a rotational symmetry
of 180 degrees or that the graph is symmetric across the origin. That is,
if the graph of \(y=\sin(x)\) includes a point \((x,y)=(a,b)\), then the
opposite point \((x,y)=(-a,-b)\) (both change because going across the origin)
is also on the graph.

Because a circle is rotationally symmetric,
the sine and cosine graphs have the same shapes although they are shifted
with respect to one another. If we took the graph of the cosine and
shifted it to the right by the arc length corresponding to a quarter rotation,
\(\frac{1}{4}(2\pi) = \frac{\pi}{2}\),
then we get the sine graph. This is given by either of the following equations.
\begin{gather*}
\cos(x-\frac{\pi}{2}) = \sin(x)\\
\sin(x+\frac{\pi}{2}) = \cos(x)
\end{gather*}

Subsection7.3.3Periodic Functions

Definition7.3.1Periodic Function

A function \(f\) is periodic if there is a number \(p\)
so that \(f(x+p)=f(x)\) for all \(x\). The smallest such number \(p\)
is called the period of the function.

Waves are a good physical example of periodic behavior.
(I'm thinking about steady rolling waves or ripples, not breaking waves that do
not pass the vertical line test but are much more fun.)
If we took a snapshot (single moment of time) and looked at the height
of the water along a straight line, we would see peaks and valleys that
repeat their shape over and over again. This would give us a periodic
function with an independent variable of position. The period would correspond
physically to the wavelength, which is the distance at which the shape starts
to repeat (usually imagined as distance from peak-to-peak).

On the other hand, if we had a bobber at a single location and measured its
height as it bobbed up and down, then we again have a periodic function
with an independent variable of time. The period now corresponds to a time
interval over which the pattern of height begins to repeat, which equals the
time between the bobber reaching its highest point.

In reality, physical waves exist in both space and time and should be
considered as functions of both independent variables. In such a case,
the physical period is called the wavelength and the temporal (time) period
is called simply the period. For the purposes of our discussion, we will
only consider a single independent variable and use the idea of period
and wavelength interchangeably.

The 1963 Nobel prize in Physiology or Medicine was awarded to the
scientists Alan Hodgkin and Andrew Huxley for their development in 1952 of
a model of how ion channels in a neuron control the neuron's firing
patterns. One prediction of their model was that if the stimulus
on the neuron was sufficiently high then the neuron would fall into
a steady rhythm of firing or spiking. The resulting graphs illustrate
a periodic function that is more complex than a simple sine or cosine function.
The period can be estimated by measuring the interval (spacing) between
any repeating point on the graph.

Finding the period from such a graph is challenging because we can only estimate
the coordinates of the points. Using the actual data as portrayed in a detailed
table would be better. In the above figure, it looks like over the course of 100 ms
the pattern repeats almost exactly 7 times. So the period should be close to
\(100/7 \approx 14.3\) ms. The data (table, not shown) suggest that
the moment when the voltage first crosses \(V=0\) occurs at \(t=1.81\) ms.
The voltage crosses this again coming down at \(t=10.16\) ms, but the
moment when the pattern begins again is when it crosses going up at
\(t=16.45\) ms. So our best estimate of the period is \(p=16.45-1.81=14.64\) ms.

For symmetric waves like the sine and cosine functions, the amplitude
of the wave describes the height of the wave away from the center, which would
be the value in the absence of a wave. For this reason, the amplitude of a
periodic function is usually defined as half the distance between the maximum
and minimum values. It is harder to justify this definition for examples like
the Hodgkin–Huxley spiking model where the center line should be 0 V (neutral)
so that there is an asymmetry between the distance to maximum and distance to minimum.

Subsection7.3.4Transformations and Periodic Functions

Suppose we are given data representing some periodic behavior and we want
to establish a model for those data using a known periodic function.
It is almost certain that the known periodic function will have the wrong
amplitude, the wrong period, and the wrong starting point.
We use the idea of transformations to create a new function that will
do a better job of representing our data.
We will use the sine and cosine functions as examples of how this is done.

One way to do this is to imagine enclosing exactly one cycle of the
elementary function in a rectangle and then enclose exactly one cycle
of the data as the transformed function. The width of each rectangle
corresponds to the period. The top of the rectangle corresponds to the
maximum value (peak) and the bottom corresponds to the minimum value (valley).
Then use the method of function transformation to find the new function.

Example7.3.3

Find the formula for the sinusoidal function shown in the following graph.

If we know the location of a peak, then the cosine function is a good
choice for our elementary function because its elementary cycle
goes from peak to peak. (The sine function has an elementary cycle the
goes between two consecutive upward crossings of the center line.)
A single cycle of the cosine function
is shown in the figure below, along with a single corresponding cycle
for our transformed data.

If we think of \((x,y)\) based on \(y=\cos(x)\) as the
original elementary function and our transformed relation using \((u,v)\),
then we need transformations that accomplish the following mappings:
\begin{gather*}
x=0 \: \mapsto \: u=1 \\
x=2\pi \: \mapsto \: u=9 \\
y=-1 \: \mapsto \: v=7 \\
y=0 \: \mapsto \: v=10 \\
y=1 \: \mapsto \: v=13
\end{gather*}
Notice that \(\Delta u = 9-1 = 8\) is the period of the data
and that \(\Delta x = 2 \pi - 0 = 2\pi\) is the natural period
of the cosine function. Further, notice that \(\Delta v = 13-7 = 6\)
is double the amplitude of our data while \(\Delta y = 1--1=2\)
is double the natural amplitude of the cosine function.

Given these observations, we find the actual transformations.
The horizontal transformation has a slope
\(\frac{\Delta u}{\Delta x} = \frac{8}{2\pi}\),
which is exactly the period of the data divided by the natural period
of the cosine.
This allows us to write
\begin{equation*} u = 1 + \frac{8}{2\pi}(x-0) = 1 + \frac{8}{2\pi} x. \end{equation*}
The vertical transformation has a slope
\(\frac{\Delta v}{\Delta y} = \frac{6}{2} = 3\),
which is exactly the amplitude of the data.
Using the transformation of the centerline \(y=0\) to \(v=10\),
we find that our vertical transformation is given by
\begin{equation*} v = 10+3(y-0) = 10 + 3y. \end{equation*}

To obtain our desired function, we need to rewrite \(y=\cos(x)\)
in terms of \((u,v)\). Solving for \(x\), we find
\begin{equation*} u = 1 + \frac{8}{2\pi} x \quad \Leftrightarrow \quad
x = \frac{2 \pi}{8}(u-1). \end{equation*}
We now start with \(v=10+3y\) to obtain
\begin{equation*} v = 10 + 3 \cos(x) = 10 + 3 \cos\left(\frac{2 \pi}{8}(u-1)\right). \end{equation*}
Since we actually wanted our data represented using variables \((x,y)\),
we end by making that change:
\begin{equation*}
y = 10 + 3 \cos\left(\frac{2 \pi}{8}(x-1)\right)
\end{equation*}

The previous example demonstrated how knowing basic information about a
periodic function allows us to model that function using an elementary
trigonometric function. In the example, we discovered that the fundamental
attributes that we needed were the centerline and amplitude (to determine
the vertical transformation) and the period and a starting point (to
determine the horizontal transformation). Once these features are
known, it is straightforward to develop the model.

Theorem7.3.4

Suppose a sinusoidal function has a centerline at \(y=k\)
an amplitude \(A\), a period \(p\), and a maximum occurs at \(x=h\).
Then one model for the function is given by
\begin{equation*} y = k + A \cos\left( \frac{2 \pi}{p}(x-h) \right).\end{equation*}
If instead of a maximum, an upcrossing of the center line occurs at \(x=h\),
then a model for the function would by given by
\begin{equation*} y = k + A \sin\left( \frac{2 \pi}{p}(x-h) \right).\end{equation*}

The reverse process also works. If we start with a formula of a sinusoidal
function, we can interpret the parameters of the formula to determine
the period, the amplitude, the center line (vertical shift),
and the phase shift (horizontal shift).

Example7.3.5

Interpret the formula \(y=3 \sin(6x+\pi) - 3\) and use this to sketch
the graph.

If we thought of \(y=\sin(x)\) as the starting point, then this equation
corresponds to a transformation \(x=6u+\pi\) and \(v=3y-3\).

To interpret the horizontal transformation, we solve for \(u\):
\begin{equation*} u= \frac{1}{6}(x-\pi) = \frac{1}{6} x - \frac{\pi}{6}. \end{equation*}
In words, this says that we multiply all \(x\)-coordinates by \(\frac{1}{6}\)
and then shift the graph to the left by \(-\frac{\pi}{6}\).
Since the original period of sine is \(2 \pi\), the new period
is \(p=\frac{1}{6}(2 \pi) = \frac{\pi}{3}\).
The phase shift is the value of the shift \(-\frac{\pi}{6}\) and
gives the \(x\)-coordinate of the upcrossing of the sinusoidal graph.

To interpret the vertical transformation,
\begin{equation*} v=3y-3, \end{equation*}
we see that all \(y\)-coordinates are multiplied by 3 and then the
graph is shifted down by 3. So the amplitude is 3 (from multiplication)
and the centerline is \(y=-3\) (shift).

We graph the function by imagining (or physically drawing) the rectangle
that surrounds a single cycle. We will use \((x,y)\) for our variables,
where we used \((u,v)\) only to obtain our interpretation.
The centerline \(y=-3\) and amplitude \(A=3\) gives us that
the graph goes from \(y=-6\) (minimum) through \(y=0\) (maximum).
The phase shift \(-\frac{\pi}{6}\) gives the left edge of the
initial cycle and the period \(p=\frac{\pi}{3}\) gives the width
of the cycle.

Once we have our rectangle, we fill in the sinusoidal graph shape
to fit in the rectangle. Then we repeat the pattern taking care
that our period does not change as we draw.