Some other waveforms
This post is a sequel to my earlier post Fourier Fun 1: Sums and square waves, which gives a very basic first introduction to Fourier series. If you have not read that post, you may wish to do so before reading this one.
\begin{equation}
S(t)=\frac{4}{\pi}\sum_{n\textrm{ odd}} \frac{1}{n} \sin(nt).
\end{equation}
The square wave is one of the standard examples used when introducing Fourier series, but there are other waveforms we might want to consider. Two other standard examples are the triangle wave and the sawtooth wave (fig. 1). The triangle wave is similar to the square wave in that only odd components of the sum contribute:
\begin{equation}
T(t)=\frac{8}{\pi^2}\sum_{n\textrm{ odd}}\frac{(-1)^{(n-1)/2}}{n^2} \sin(nt).
\end{equation}
Apart from a couple of different terms, the main difference between the Fourier series of $S(t)$ and $T(t)$ is the sign term $(-1)^{(n-1)/2}$, which gives $+1$ for $n=1, 5, 9,\ldots$ and $-1$ for $n=3, 7, 11,\ldots$. This ensures the series gives a function which is strongly peaked rather than flat (fig. 2).
Figure 1: Plots of (a) a triangle wave $T(t)$ and (b) a sawtooth wave $W(t)$.
Note that in this plot (and all others), the $t$-axis is shown in units of $\pi$ such
that the period of both waves is $2\pi$.
The sawtooth wave is a degree removed from both the square wave and the triangle wave in that, unlike the other two, it is not symmetric about its peaks. Part of the reason both the square wave and triangle wave have no odd-numbered components is that even-numbered components have zeroes ($t$-axis crossings) where the square and triangle waves have maxima. Any sine wave that is not displaced from the $t$-axis will have a positive region and a negative region on either side of every zero (fig. 3). If the square and triangle waves had even-numbered components, and those even-numbered components had zeroes aligned with the wave's peaks, reflection symmetry about the peaks would not be possible; one side would necessarily be 'more positive' on one side and 'more negative' on the other. As the sawtooth wave is not symmetric about its peaks, we should therefore expect it to include even-numbered components in its Fourier series, and this is indeed the case:
\begin{equation}
W(t)=\frac{2}{\pi}\sum_{n=1}^{\infty}\frac{(-1)^{n-1}}{n} \sin(nt).
\end{equation}
The Fourier series
Even so, all three of the examples we have examined have some things in common that may seem to raise some suspicions. They all have amplitude $1$ and period $2\pi$, yes, but these things can easily be altered by multiplying the amplitude by some scalar factor and changing the period term $T$ in the series respectively. In other words, these things can be changed by tweaking the numbers in the equations we have already encountered. What about the vertical displacement? If we want to raise or lower our function with respect to the $t$-axis, there is no way to do that using the equations we have found thus far.There is a simple fix for this, as we will see, but before we come to it there is something else considerably more suspicious we have yet to consider. All of the waves we have looked at 'begin'$^1$ in the same place, or rather have the same horizontal displacement, that is to say they have the same phase $\varphi$. What if, rather than having a zero at the origin, we wanted our waves to have a maximum? The solution seems pretty straightforward. If you have an arbitrary function $f(x)$ that you want to shift along the $x$-axis by some distance $\pm x'$, your function then becomes $f(x\mp x')$. For a sine function of period $T$, $\sin(2n\pi t/T)$, we shift it a quarter-period in the negative direction to give $\sin(2n\pi t/T+T/4)$. But this, unsurprisingly, is simply our old friend $\cos(2n\pi x/T)$.
So what do we do? Sure, we can replace all of our sines with cosines and recast our series that way, but all we have achieved then is an ability to 'begin' our waves a quarter-period over. It takes us from having only a single 'start' point, to two, which is an improvement without doubt but not incredibly more useful. What we really want, I should think, is the ability to 'start' our wave with whatever horizontal displacement we like. Given our previous accomplishment, this is only a further extension of the same thinking; rather than a shift of $T/4$ in the negative $t$-direction we choose any arbitrary phase shift $\varphi$ (with the sign of $\varphi$ indicating the direction of the shift) so that our Fourier series is now
\begin{equation*}
f(t)=\sum_{n=1}^{\infty}B_n\sin\left(\frac{2\pi nt}{T}-\varphi\right),
\end{equation*}
where we have called the amplitude $B_n$ to differentiate it from the $b_n$ amplitude that applies to un-shifted sine components.
This is all well and good, but we can do better by making a small but very significant change. What if, rather than applying a single phase shift $\varphi$ to every series component, we apply a different phase shift to each component, such that $\varphi_n$ is the phase shift for the $n^{\mathrm{th}}$ component? The increased flexibility of such a change is immediately obvious. Given this improvement, we can recast our Fourier series yet again into the form
\begin{equation}
\label{eq:fourierprim}
f(t)=\sum_{n=1}^{\infty}B_n\sin\left(\frac{2\pi nt}{T}-\varphi_n\right).
\end{equation}
For the most part, this expression is fine, but let's say for purely aesthetic reasons$^2$ we don't like having that $\varphi_n$ term there messing up our clean sine function notation. This can be resolved using a trigonometric identity:
\begin{align*}
\sin(\theta_1+\theta_2)&=\sin(\theta_2)\cos(\theta_1)+\cos(\theta_2)\sin(\theta_1)\\
\sin\left(\frac{2\pi nt}{T}+\varphi_n\right)&=\sin(\varphi_n)\cos\left(\frac{2\pi nt}{T}\right)+\cos(\varphi_n)\sin\left(\frac{2\pi nt}{T}\right)\\
&=\alpha_n\cos\left(\frac{2\pi nt}{T}\right)+\beta_n\sin\left(\frac{2\pi nt}{T}\right)
\end{align*}
where $\alpha_n=\sin(\varphi_n)$ and $\beta_n=\cos(\varphi_n)$. Inserting this result into equation \ref{eq:fourierprim} gives
\begin{align}
f(t)&=\sum_{n=1}^{\infty}B_n\Bigg(\alpha_n\cos\left(\frac{2\pi nt}{T}\right)+\beta_n\sin\left(\frac{2\pi nt}{T}\right)\Bigg)\nonumber\\
&=\sum_{n=1}^{\infty}\Bigg(a_n\cos\left(\frac{2\pi nt}{T}\right)+b_n\sin\left(\frac{2\pi nt}{T}\right)\Bigg),
\end{align}
where we have defined $a_n=B_n\alpha_n$ and $b_n=B_n\beta_n$, such that this $b_n$ is the same one we encountered previously. It can be shown$^3$ that, similar to $b_n$, the Fourier components $a_n$ are given by
\begin{equation}
a_n=\frac{2}{T}\int_{t_0}^{t_0+T}\! f(t)\cos\left(\frac{2\pi nt}{T}\right)\,\mathrm{d}t.
\end{equation}
Now we can, at last, return to the matter of the vertical displacement. Just as we considered how to translate an arbitrary function to determine the horizontal displacement, we can do the same for vertical displacement. For an arbitrary function $f(x)$, we shift it vertically by an amount $\pm C$ by making the very straightforward transformation $f(x)\mapsto f(x)\pm C$. Following this, we can modify our Fourier series formula to include a vertical displacement term:
\begin{equation}
\label{eq:Fourier}
f(t)=\frac{a_0}{2}+\sum_{n=1}^{\infty}\Bigg(a_n\cos\left(\frac{2\pi nt}{T}\right)+b_n\sin\left(\frac{2\pi nt}{T}\right)\Bigg),
\end{equation}
where our vertical displacement term, given by $C=a_0/2$, is a matter of convention.$^4$ This is the 'full' Fourier series formula, and with it we can find the Fourier series for any periodic function (in one dimension) with the freedom to pick any finite amplitude, period, vertical or horizontal displacement we choose.
This is the second part in a 3-part series on some of the basics of Fourier analysis. Part 3 can be found here.
Notes
$1$. When I say "begin" or "start" in this context, I put the terms in inverted commas because clearly periodic functions have no true beginning or end, they extend indefinitely in however many dimensions they are defined (that is, of course, unless their domain is limited, as is discussed in the "Making approximations" section). I use the terms here to refer to any point we choose to consider as a reference.
$2$. I admit I am being somewhat duplicitous here, as there is another reason to write the Fourier series as a sum of both sines and cosines, which I detail below. It is quite mathematically full-on compared to the rest of this post, so for those of the faint heart, you can rest easy in the knowledge that, like much mathematics, there is still an element of aesthetics involved, it is just somewhat more 'deep' than that provided in the main body.
Consider a complex function $g(z)$ such that we can take the Laurent expansion around zero:
\begin{equation*}
g(z)=\sum_{n=-\infty}^{\infty}c_n z^n,
\end{equation*}
where the Laurent coefficients $c_n$ are given by
\begin{equation*}
c_n=\frac{1}{2\pi i}\oint_{\gamma}\!\frac{g(z)}{z^{n+1}}\,\mathrm{d}z
\end{equation*}
where $\gamma$ denotes a non-self-intersecting contour which goes clockwise about a closed path enclosing $0$ within an annulus over which $g(z)$ is holomorphic (effectively smooth and well-behaved). What a mouthful! Now let's choose the contour given by $|z|=1$, that is, the unit circle in the complex plane. We can now choose the mapping $z=e^{i\theta}$ ($0\leq\theta\leq 2\pi$) which takes that annulus to a strip surrounding the real axis (and the unit circle to the real number line). We can similarly define a function $f(\theta)$ on this strip such that $f(\theta)=g(z)$. Making the substitution into the Laurent series we find
\begin{equation*}
f(\theta)=g(e^{i\theta})=\sum_{n=-\infty}^{\infty}c_n e^{in\theta}.
\end{equation*}
Considering the Laurent coefficients, we can make a change of variables by taking the derivative $\mathrm{d}z/\mathrm{d}\theta=ie^{i\theta}\rightarrow\mathrm{d}z=ie^{i\theta}\mathrm{d}\theta=iz\,\mathrm{d}\theta$:
\begin{align*}
c_n&=\frac{1}{2\pi i}\oint_{|z|=1}\! \frac{g(z)}{z^{n+1}}\,\mathrm{d}z\\
&=\frac{1}{2\pi i}\int_{0}^{2\pi}\! \frac{f(\theta)}{z^{n+1}}iz\,\mathrm{d}\theta\\
&=\frac{1}{2\pi}\int_{0}^{2\pi}\! \frac{f(\theta)}{z^n}\,\mathrm{d}\theta\\
&=\frac{1}{2\pi}\int_{0}^{2\pi}\! f(\theta)e^{-in\theta}\,\mathrm{d}\theta.
\end{align*}
As in the series $n$ runs from $-\infty$ to $\infty$, we can break up $n$ into positive, negative and $0$ cases. Let's apply Euler's formula $e^{ix}=\cos(x)+i\sin(x)$ to these three cases for $c_n$:
\begin{equation*}
c_n=
\begin{cases}
\frac{1}{2\pi}\int_{0}^{2\pi}\! f(\theta)\big(\cos(n\theta)-i\sin(n\theta)\big)\,\mathrm{d}\theta & \text{for } n > 0 \\
\frac{1}{2\pi}\int_{0}^{2\pi}\! f(\theta)\,\mathrm{d}\theta & \text{for } n = 0 \\
\frac{1}{2\pi}\int_{0}^{2\pi}\! f(\theta)\big(\cos(n\theta)+i\sin(n\theta)\big)\,\mathrm{d}\theta & \text{for } n < 0.
\end{cases}
\end{equation*}
If we compare these cases to the Fourier component equations for a function $f(\theta)$ with period $T=2\pi$, it is easy to formulate $c_n$ in terms of $a_n$ and $b_n$:
\begin{equation*}
c_n=
\begin{cases}
\frac{1}{2}(a_n-ib_n) & \text{for } n > 0 \\
\frac{a_0}{2} & \text{for } n = 0 \\
\frac{1}{2}(a_n+ib_n) & \text{for } n < 0.
\end{cases}
\end{equation*}
This is quite an interesting coincidence! Let's apply these definitions of $c_n$ and Euler's formula to the Laurent series for $f(\theta)$:
\begin{align*}
f(\theta)=\sum_{n=-\infty}^{\infty}c_n e^{in\theta}&=\sum_{n=1}^{\infty}c_{+n} e^{+in\theta}+c_0 e^0+\sum_{n=1}^{\infty}c_{-n} e^{-in\theta}\\
&=\frac{a_0}{2}+\sum_{n=1}^{\infty}\left(\frac{1}{2}(a_n-ib_n)\big(\cos(n\theta)+i\sin(n\theta)\big)\right.\\
&\qquad \left.+\frac{1}{2}(a_n+ib_n)\big(\cos(n\theta)-i\sin(n\theta)\big)\right)\\
&=\frac{a_0}{2}+\sum_{n=1}^{\infty}\big(a_n\cos(n\theta)+b_n\sin(n\theta)\big).
\end{align*}
Lo and behold, we have recovered the Fourier series! In doing so we have gone from the Laurent series for a complex function on the unit circle $S^1$ in a very natural way to the Fourier series for a (real) $2\pi$-periodic function, expressed in terms of complex exponentials which, in turn, can be very naturally expressed in terms of sines and cosines thanks to Euler's formula. Now the real meat of why this is significant is beyond the scope of this endnote, but I think for the time being it suffices to say that the link between the Laurent series of complex analysis and periodic functions, expressible through complex exponentials which are then very naturally expressible in terms of sine and cosine functions, is a good argument in favour of representing Fourier series in terms of these sine and cosine functions rather than in terms of sine functions with various phase shifts.
In truth, this is actually a good argument in favour of sines and cosines instead of any other set of periodic functions, rather than instead of only sines specifically. Even so, this is not the only reason why we might prefer to use both sines and cosines. Another mathematical reason is that sines and cosines are maximally orthogonal ($\int_0^{2\pi}\sin(nx)\cos(mx)=0$ as $\sin(nx)\cos(mx)$ is an odd-function). Of course, there are very compelling non-mathematical reasons, both in terms of historical development and practicality. The history of Fourier analysis I won't go into, but some practical elements will be discussed in Part 3 and viewed in that light, the preference for using sines and cosines may become more clear.
$3$. As we have not bothered to define any halfway-rigorous method of determining $B_n$ or $\varphi_n$ for a function $f(t)$, trying to determine the Fourier component $a_n$ from these quantities and $b_n$ is at the very least inadvisable. The best way to find $a_n$ is instead to follow the derivation of $b_n$, which I provided in Note 4 of Part 1 of this series, making suitable substitutions where appropriate. Due to the similarity between the two derivations, I leave this as an exercise for the reader.
$4$. To understand why this convention is chosen, consider the fact that the summation in equation \ref{eq:Fourier} begins at $n=1$ and not $n=0$. What happens if we take our formulae for $a_n$ and $b_n$ and set $n=0$? We quickly find that $b_0=0$ due to the $\sin(0)$ term. However, for $a_0$, we find
\begin{equation*}
a_0=\frac{2}{T}\int_{t_0}^{t_0+T}\!f(t)\,\mathrm{d}t.
\end{equation*}
Let us define $f(t)=g(t)+C$ such that $g(t)$ is the same function as $f(t)$ but shifted vertically so that it is as much above the $t$-axis as below; this will give $C$ as the vertical displacement of $f(t)$.
\begin{align*}
a_0&=\frac{2}{T}\int_{t_0}^{t_0+T}\!g(t)+C\,\mathrm{d}t\\
&=\frac{2}{T}\Big(G(t_0+T)+(t_0+T)C-\big(G(t_0)+t_0 C\big)\Big)\\
&=\frac{2}{T}\big(G(t_0+T)-G(t_0)+TC\big)
\end{align*}
where $G(t):=\int\!g(t)\,\mathrm{d}t$. We can see that $G(t_0+T)-G(t_0)=0$ because the integral effectively gives how much of a function is above or below the axis, and as $g(t)$ is as much above as below the axis over one period (since we defined it that way) the integral over the period $T$ must be $0$. Alternatively, we can exploit the periodicity of $g(t)$ (and hence $G(t)$) to argue that $G(t_0+T)=G(t_0)$ necessarily. Ultimately the effect is the same, that being we find $a_0=2TC/T=2C$ or, equivalently, $C=a_0/2$. Thus we find that the reason for this convention is that it makes the vertical displacement term consistent with the definitions of $a_n$ and $b_n$ that we have already established.
$2$. I admit I am being somewhat duplicitous here, as there is another reason to write the Fourier series as a sum of both sines and cosines, which I detail below. It is quite mathematically full-on compared to the rest of this post, so for those of the faint heart, you can rest easy in the knowledge that, like much mathematics, there is still an element of aesthetics involved, it is just somewhat more 'deep' than that provided in the main body.
Consider a complex function $g(z)$ such that we can take the Laurent expansion around zero:
\begin{equation*}
g(z)=\sum_{n=-\infty}^{\infty}c_n z^n,
\end{equation*}
where the Laurent coefficients $c_n$ are given by
\begin{equation*}
c_n=\frac{1}{2\pi i}\oint_{\gamma}\!\frac{g(z)}{z^{n+1}}\,\mathrm{d}z
\end{equation*}
where $\gamma$ denotes a non-self-intersecting contour which goes clockwise about a closed path enclosing $0$ within an annulus over which $g(z)$ is holomorphic (effectively smooth and well-behaved). What a mouthful! Now let's choose the contour given by $|z|=1$, that is, the unit circle in the complex plane. We can now choose the mapping $z=e^{i\theta}$ ($0\leq\theta\leq 2\pi$) which takes that annulus to a strip surrounding the real axis (and the unit circle to the real number line). We can similarly define a function $f(\theta)$ on this strip such that $f(\theta)=g(z)$. Making the substitution into the Laurent series we find
\begin{equation*}
f(\theta)=g(e^{i\theta})=\sum_{n=-\infty}^{\infty}c_n e^{in\theta}.
\end{equation*}
Considering the Laurent coefficients, we can make a change of variables by taking the derivative $\mathrm{d}z/\mathrm{d}\theta=ie^{i\theta}\rightarrow\mathrm{d}z=ie^{i\theta}\mathrm{d}\theta=iz\,\mathrm{d}\theta$:
\begin{align*}
c_n&=\frac{1}{2\pi i}\oint_{|z|=1}\! \frac{g(z)}{z^{n+1}}\,\mathrm{d}z\\
&=\frac{1}{2\pi i}\int_{0}^{2\pi}\! \frac{f(\theta)}{z^{n+1}}iz\,\mathrm{d}\theta\\
&=\frac{1}{2\pi}\int_{0}^{2\pi}\! \frac{f(\theta)}{z^n}\,\mathrm{d}\theta\\
&=\frac{1}{2\pi}\int_{0}^{2\pi}\! f(\theta)e^{-in\theta}\,\mathrm{d}\theta.
\end{align*}
As in the series $n$ runs from $-\infty$ to $\infty$, we can break up $n$ into positive, negative and $0$ cases. Let's apply Euler's formula $e^{ix}=\cos(x)+i\sin(x)$ to these three cases for $c_n$:
\begin{equation*}
c_n=
\begin{cases}
\frac{1}{2\pi}\int_{0}^{2\pi}\! f(\theta)\big(\cos(n\theta)-i\sin(n\theta)\big)\,\mathrm{d}\theta & \text{for } n > 0 \\
\frac{1}{2\pi}\int_{0}^{2\pi}\! f(\theta)\,\mathrm{d}\theta & \text{for } n = 0 \\
\frac{1}{2\pi}\int_{0}^{2\pi}\! f(\theta)\big(\cos(n\theta)+i\sin(n\theta)\big)\,\mathrm{d}\theta & \text{for } n < 0.
\end{cases}
\end{equation*}
If we compare these cases to the Fourier component equations for a function $f(\theta)$ with period $T=2\pi$, it is easy to formulate $c_n$ in terms of $a_n$ and $b_n$:
\begin{equation*}
c_n=
\begin{cases}
\frac{1}{2}(a_n-ib_n) & \text{for } n > 0 \\
\frac{a_0}{2} & \text{for } n = 0 \\
\frac{1}{2}(a_n+ib_n) & \text{for } n < 0.
\end{cases}
\end{equation*}
This is quite an interesting coincidence! Let's apply these definitions of $c_n$ and Euler's formula to the Laurent series for $f(\theta)$:
\begin{align*}
f(\theta)=\sum_{n=-\infty}^{\infty}c_n e^{in\theta}&=\sum_{n=1}^{\infty}c_{+n} e^{+in\theta}+c_0 e^0+\sum_{n=1}^{\infty}c_{-n} e^{-in\theta}\\
&=\frac{a_0}{2}+\sum_{n=1}^{\infty}\left(\frac{1}{2}(a_n-ib_n)\big(\cos(n\theta)+i\sin(n\theta)\big)\right.\\
&\qquad \left.+\frac{1}{2}(a_n+ib_n)\big(\cos(n\theta)-i\sin(n\theta)\big)\right)\\
&=\frac{a_0}{2}+\sum_{n=1}^{\infty}\big(a_n\cos(n\theta)+b_n\sin(n\theta)\big).
\end{align*}
Lo and behold, we have recovered the Fourier series! In doing so we have gone from the Laurent series for a complex function on the unit circle $S^1$ in a very natural way to the Fourier series for a (real) $2\pi$-periodic function, expressed in terms of complex exponentials which, in turn, can be very naturally expressed in terms of sines and cosines thanks to Euler's formula. Now the real meat of why this is significant is beyond the scope of this endnote, but I think for the time being it suffices to say that the link between the Laurent series of complex analysis and periodic functions, expressible through complex exponentials which are then very naturally expressible in terms of sine and cosine functions, is a good argument in favour of representing Fourier series in terms of these sine and cosine functions rather than in terms of sine functions with various phase shifts.
In truth, this is actually a good argument in favour of sines and cosines instead of any other set of periodic functions, rather than instead of only sines specifically. Even so, this is not the only reason why we might prefer to use both sines and cosines. Another mathematical reason is that sines and cosines are maximally orthogonal ($\int_0^{2\pi}\sin(nx)\cos(mx)=0$ as $\sin(nx)\cos(mx)$ is an odd-function). Of course, there are very compelling non-mathematical reasons, both in terms of historical development and practicality. The history of Fourier analysis I won't go into, but some practical elements will be discussed in Part 3 and viewed in that light, the preference for using sines and cosines may become more clear.
$3$. As we have not bothered to define any halfway-rigorous method of determining $B_n$ or $\varphi_n$ for a function $f(t)$, trying to determine the Fourier component $a_n$ from these quantities and $b_n$ is at the very least inadvisable. The best way to find $a_n$ is instead to follow the derivation of $b_n$, which I provided in Note 4 of Part 1 of this series, making suitable substitutions where appropriate. Due to the similarity between the two derivations, I leave this as an exercise for the reader.
$4$. To understand why this convention is chosen, consider the fact that the summation in equation \ref{eq:Fourier} begins at $n=1$ and not $n=0$. What happens if we take our formulae for $a_n$ and $b_n$ and set $n=0$? We quickly find that $b_0=0$ due to the $\sin(0)$ term. However, for $a_0$, we find
\begin{equation*}
a_0=\frac{2}{T}\int_{t_0}^{t_0+T}\!f(t)\,\mathrm{d}t.
\end{equation*}
Let us define $f(t)=g(t)+C$ such that $g(t)$ is the same function as $f(t)$ but shifted vertically so that it is as much above the $t$-axis as below; this will give $C$ as the vertical displacement of $f(t)$.
\begin{align*}
a_0&=\frac{2}{T}\int_{t_0}^{t_0+T}\!g(t)+C\,\mathrm{d}t\\
&=\frac{2}{T}\Big(G(t_0+T)+(t_0+T)C-\big(G(t_0)+t_0 C\big)\Big)\\
&=\frac{2}{T}\big(G(t_0+T)-G(t_0)+TC\big)
\end{align*}
where $G(t):=\int\!g(t)\,\mathrm{d}t$. We can see that $G(t_0+T)-G(t_0)=0$ because the integral effectively gives how much of a function is above or below the axis, and as $g(t)$ is as much above as below the axis over one period (since we defined it that way) the integral over the period $T$ must be $0$. Alternatively, we can exploit the periodicity of $g(t)$ (and hence $G(t)$) to argue that $G(t_0+T)=G(t_0)$ necessarily. Ultimately the effect is the same, that being we find $a_0=2TC/T=2C$ or, equivalently, $C=a_0/2$. Thus we find that the reason for this convention is that it makes the vertical displacement term consistent with the definitions of $a_n$ and $b_n$ that we have already established.


0 comments :
Post a Comment