Skip to main content
Logo image

Introduction to Differential Equations

Section 5.4 Sine and cosine series

Subsection 5.4.1 Odd and even periodic functions

We do one more example of computing the Fourier Series. This time we make use of a couple nice integration tricks involving whether sin and cos are even functions (which means \(f(-x)=f(x)\)) or odd functions (which means \(f(-x)=-f(x)\)).
You may have noticed by now that an odd function has no cosine terms in the Fourier series and an even function has no sine terms in the Fourier series. This observation is not a coincidence. Let us look at even and odd periodic function in more detail.
Recall that a function \(f(t)\) is odd if \(f(-t) = -f(t)\text{.}\) A function \(f(t)\) is even if \(f(-t) = f(t)\text{.}\) For example, \(\cos (n t)\) is even and \(\sin (n t)\) is odd. Similarly the function \(t^k\) is even if \(k\) is even and odd when \(k\) is odd.

Example 5.4.1.

Take two functions \(f(t)\) and \(g(t)\) and define their product \(h(t) = f(t)g(t)\text{.}\)
  1. Suppose both \(f(t)\) and \(g(t)\) are odd. Is \(h(t)\) odd or even?
  2. Suppose one is even and one is odd. Is \(h(t)\) odd or even?
  3. Suppose both are even. Is \(h(t)\) odd or even?
You can check your answers graphically using this Geogebra applet 1 . Even functions are symmetric about the y-axis, while odd functions are flip over both the y-axis and the x-axis.
If \(f(t)\) and \(g(t)\) are both odd, then \(f(t)+g(t)\) is odd. Similarly for even functions. On the other hand, if \(f(t)\) is odd and \(g(t)\) even, then we cannot say anything about the sum \(f(t) + g(t)\text{.}\) In fact, the Fourier series of any function is a sum of an odd (the sine terms) and an even (the cosine terms) function.
In this section we consider odd and even periodic functions. We have previously defined the \(2L\)-periodic extension of a function defined on the interval \([-L,L]\text{.}\) Sometimes we are only interested in the function on the range \([0,L]\) and it would be convenient to have an odd (resp. even) function. If the function is odd (resp. even), all the cosine (resp. sine) terms disappear. What we will do is take the odd (resp. even) extension of the function to \([-L,L]\) and then extend periodically to a \(2L\)-periodic function.
Take a function \(f(t)\) defined on \([0,L]\text{.}\) On \((-L,L]\) define the functions
\begin{equation*} \begin{aligned} F_{\text{odd}}(t) & \overset{\text{def}}{=} \begin{cases} f(t) & \text{if } \; \phantom{-}0 \leq t \leq L , \\ -f(-t) & \text{if } \; {-L} < t < 0 , \end{cases} \\ F_{\text{even}}(t) & \overset{\text{def}}{=} \begin{cases} f(t) & \text{if } \; \phantom{-}0 \leq t \leq L , \\ f(-t) & \text{if } \; {-L} < t < 0 . \end{cases} \end{aligned} \end{equation*}
Extend \(F_{\text{odd}}(t)\) and \(F_{\text{even}}(t)\) to be \(2L\)-periodic. Then \(F_{\text{odd}}(t)\) is called the odd periodic extension of \(f(t)\text{,}\) and \(F_{\text{even}}(t)\) is called the even periodic extension of \(f(t)\text{.}\) For the odd extension we generally assume that \(f(0) = f(L) = 0\text{.}\)
Verify: Check that \(F_{\text{odd}}(t)\) is odd and \(F_{\text{even}}(t)\) is even. For \(F_{\text{odd}}\text{,}\) assume \(f(0) = f(L) = 0\text{.}\)

Example 5.4.2.

Take the function \(f(t) = t\,(1-t)\) defined on \([0,1]\text{.}\) Figure 5.32 shows the plots of the odd and even periodic extensions of \(f(t)\text{.}\)
Figure 5.32. Odd and even 2-periodic extension of \(f(t) = t\,(1-t)\text{,}\) \(0 \leq t \leq 1\text{.}\)

Subsection 5.4.2 Sine and cosine series

Let \(f(t)\) be an odd \(2L\)-periodic function. We write the Fourier series for \(f(t)\text{.}\) First, we compute the coefficients \(a_n\) (including \(n=0\)) and get
\begin{equation*} a_n = \frac{1}{L} \int_{-L}^L f(t) \cos \left( \frac{n \pi}{L} t \right) \, dt = 0 . \end{equation*}
That is, there are no cosine terms in the Fourier series of an odd function. The integral is zero because \(f(t) \cos \left( {n \pi}{L} t \right)\) is an odd function (product of an odd and an even function is odd) and the integral of an odd function over a symmetric interval is always zero. The integral of an even function over a symmetric interval \([-L,L]\) is twice the integral of the function over the interval \([0,L]\text{.}\) The function \(f(t) \sin \left( \frac{n \pi}{L} t \right)\) is the product of two odd functions and hence is even.
\begin{equation*} b_n = \frac{1}{L} \int_{-L}^L f(t) \sin \left( \frac{n \pi}{L} t \right) \, dt = \frac{2}{L} \int_{0}^L f(t) \sin \left( \frac{n \pi}{L} t \right) \, dt . \end{equation*}
We now write the Fourier series of \(f(t)\) as
\begin{equation*} \sum_{n=1}^\infty b_n \sin \left( \frac{n \pi}{L} t \right) . \end{equation*}
Similarly, if \(f(t)\) is an even \(2L\)-periodic function. For the same exact reasons as above, we find that \(b_n = 0\) and
\begin{equation*} a_n = \frac{2}{L} \int_{0}^L f(t) \cos \left( \frac{n \pi}{L} t \right) \, dt . \end{equation*}
The formula still works for \(n=0\text{,}\) in which case it becomes
\begin{equation*} a_0 = \frac{2}{L} \int_{0}^L f(t) \, dt . \end{equation*}
The Fourier series is then
\begin{equation*} \frac{a_0}{2} + \sum_{n=1}^\infty a_n \cos \left( \frac{n \pi}{L} t \right) . \end{equation*}
An interesting consequence is that the coefficients of the Fourier series of an odd (or even) function can be computed by just integrating over the half interval \([0,L]\text{.}\) Therefore, we can compute the Fourier series of the odd (or even) extension of a function by computing certain integrals over the interval where the original function is defined.
We call the series \(\sum_{n=1}^\infty b_n \sin \left( \frac{n \pi}{L} t\right)\) the sine series of \(f(t)\) and we call the series \(\frac{a_0}{2} + \sum_{n=1}^\infty a_n \cos \left( \frac{n \pi}{L} t \right)\) the cosine series of \(f(t)\text{.}\) We often do not actually care what happens outside of \([0,L]\text{.}\) In this case, we pick whichever series fits our problem better.
It is not necessary to start with the full Fourier series to obtain the sine and cosine series. The sine series is really the eigenfunction expansion of \(f(t)\) using eigenfunctions of the eigenvalue problem \(x''+\lambda x = 0\text{,}\) \(x(0) = 0\text{,}\) \(x(L) = L\text{.}\) The cosine series is the eigenfunction expansion of \(f(t)\) using eigenfunctions of the eigenvalue problem \(x''+\lambda x = 0\text{,}\) \(x'(0) = 0\text{,}\) \(x'(L) = L\text{.}\) We could have, therefore, gotten the same formulas by defining the inner product
\begin{equation*} \langle f(t), g(t) \rangle = \int_0^L f(t) g(t) \, dt , \end{equation*}
and following the procedure of Section 5.2. This point of view is useful, as we commonly use a specific series that arose because our underlying question led to a certain eigenvalue problem. If the eigenvalue problem is not one of the three we covered so far, you can still do an eigenfunction expansion, generalizing the results of this chapter. We will deal with such a generalization in Chapter 6.

Example 5.4.3.

Find the Fourier series of the even periodic extension of the function \(f(t) = t^2\) for \(0 \leq t \leq \pi\text{.}\)
We want to write
\begin{equation*} f(t) = \frac{a_0}{2} + \sum_{n=1}^\infty a_n \cos (n t) , \end{equation*}
where
\begin{equation*} a_0 = \frac{2}{\pi} \int_0^\pi t^2 \, dt = \frac{2 \pi^2}{3} , \end{equation*}
and
\begin{equation*} \begin{split} a_n & = \frac{2}{\pi} \int_0^\pi t^2 \cos (n t) \, dt = \frac{2}{\pi} \left[ t^2 \frac{1}{n} \sin (nt) \right]_0^\pi - \frac{4}{n\pi} \int_0^\pi t \sin (n t) \, dt \\ & = \frac{4}{n^2\pi} \Bigl[ t \cos (n t) \Bigr]_0^\pi + \frac{4}{n^2\pi} \int_0^\pi \cos (n t) \, dt = \frac{4{(-1)}^n}{n^2} . \end{split} \end{equation*}
Note that we have “detected” the continuity of the extension since the coefficients decay as \(\frac{1}{n^2}\text{.}\) That is, the even periodic extension of \(t^2\) has no jump discontinuities. It does have corners, since the derivative, which is an odd function and a sine series, has jumps; it has a Fourier series whose coefficients decay only as \(\frac{1}{n}\text{.}\)
Explicitly, the first few terms of the series are
\begin{equation*} \frac{\pi^2}{3} - 4 \cos (t) + \cos (2t) - \frac{4}{9} \cos (3t) + \cdots \end{equation*}
Exercise:
  1. Compute the derivative of the even periodic extension of \(f(t)\) above and verify it has jump discontinuities. Use the actual definition of \(f(t)\text{,}\) not its cosine series!
  2. Why is it that the derivative of the even periodic extension of \(f(t)\) is the odd periodic extension of \(f'(t)\text{?}\)

Subsection 5.4.3 Application

Fourier series ties in to the boundary value problems we studied earlier. Let us see this connection in an application.
Consider the boundary value problem for \(0 < t < L\text{,}\)
\begin{equation*} x''(t) + \lambda\, x(t) = f(t) , \end{equation*}
for the Dirichlet boundary conditions \(x(0) = 0\text{,}\) \(x(L) = 0\text{.}\) The Fredholm alternative (Theorem 5.1.2) says that as long as \(\lambda\) is not an eigenvalue of the underlying homogeneous problem, there exists a unique solution. Eigenfunctions of this eigenvalue problem are the functions \(\sin \left( \frac{n \pi}{L} t \right)\text{.}\) Therefore, to find the solution, we first find the Fourier sine series for \(f(t)\text{.}\) We write \(x\) also as a sine series, but with unknown coefficients. We substitute the series for \(x\) into the equation and solve for the unknown coefficients. If we have the Neumann boundary conditions \(x'(0) = 0\text{,}\) \(x'(L) = 0\text{,}\) we do the same procedure using the cosine series.
Let us see how this method works on examples.

Example 5.4.4.

Take the boundary value problem for \(0 < t < 1\text{,}\)
\begin{equation*} x''(t) + 2 x(t) = f(t) , \end{equation*}
where \(f(t) = t\) on \(0 < t < 1\text{,}\) and satisfying the Dirichlet boundary conditions \(x(0) = 0\text{,}\) \(x(1)=0\text{.}\) We write \(f(t)\) as a sine series
\begin{equation*} f(t) = \sum_{n=1}^\infty c_n \sin (n \pi t) . \end{equation*}
Compute
\begin{equation*} c_n = 2 \int_0^1 t \sin (n \pi t) \,dt = \frac{2 \, {(-1)}^{n+1}}{n \pi} . \end{equation*}
We write \(x(t)\) as
\begin{equation*} x(t) = \sum_{n=1}^\infty b_n \sin (n \pi t) . \end{equation*}
We plug in to obtain
\begin{equation*} \begin{split} x''(t) + 2 x(t) & = \underbrace{ \sum_{n=1}^\infty - b_n n^2 \pi^2 \sin (n \pi t) }_{x''} \, + \, 2 \underbrace{ \sum_{n=1}^\infty b_n \sin (n \pi t) }_{x} \\ & = \sum_{n=1}^\infty b_n (2 - n^2 \pi^2 ) \sin (n \pi t) \\ & = f(t) = \sum_{n=1}^\infty \frac{2\, {(-1)}^{n+1}}{n \pi} \sin (n \pi t) . \end{split} \end{equation*}
Therefore,
\begin{equation*} b_n (2 - n^2 \pi^2) = \frac{2\,{(-1)}^{n+1}}{n \pi} \end{equation*}
or
\begin{equation*} b_n = \frac{2\,{(-1)}^{n+1}}{n \pi (2 - n^2 \pi^2)} . \end{equation*}
That \(2-n^2\pi^2\) is not zero for any \(n\text{,}\) and that we can solve for \(b_n\text{,}\) is precisely because \(2\) is not an eigenvalue of the problem. We have thus obtained a Fourier series for the solution
\begin{equation*} x(t) = \sum_{n=1}^\infty \frac{2\,{(-1)}^{n+1}}{n \pi \,(2 - n^2 \pi^2)} \sin (n \pi t) . \end{equation*}
See Figure 5.33 for a graph of the solution. Notice that because the eigenfunctions satisfy the boundary conditions, and \(x\) is written in terms of the boundary conditions, then \(x\) satisfies the boundary conditions.
Figure 5.33. Plot of the solution of \(x''+2x=t\text{,}\) \(x(0)=0\text{,}\) \(x(1)=0\text{.}\)

Example 5.4.5.

Similarly we handle the Neumann conditions. Take the boundary value problem for \(0 < t < 1\text{,}\)
\begin{equation*} x''(t) + 2 x(t) = f(t) , \end{equation*}
where again \(f(t) = t\) on \(0 < t < 1\text{,}\) but now satisfying the Neumann boundary conditions \(x'(0) = 0\text{,}\) \(x'(1)=0\text{.}\) We write \(f(t)\) as a cosine series
\begin{equation*} f(t) = \frac{c_0}{2} + \sum_{n=1}^\infty c_n \cos (n \pi t) , \end{equation*}
where
\begin{equation*} c_0 = 2 \int_0^1 t \,dt = 1 , \end{equation*}
and
\begin{equation*} c_n = 2 \int_0^1 t \cos (n \pi t) \,dt = \frac{2\bigl({(-1)}^n-1\bigr)}{\pi^2 n^2} = \begin{cases} \frac{-4}{\pi^2 n^2} & \text{if } n \text{ odd} , \\ 0 & \text{if } n \text{ even}. \end{cases} \end{equation*}
We write \(x(t)\) as a cosine series
\begin{equation*} x(t) = \frac{a_0}{2} + \sum_{n=1}^\infty a_n \cos (n \pi t) . \end{equation*}
We plug in to obtain
\begin{equation*} \begin{split} x''(t) + 2 x(t) & = \sum_{n=1}^\infty \Bigl[ - a_n n^2 \pi^2 \cos (n \pi t) \Bigr] + a_0 + 2 \sum_{n=1}^\infty \Bigl[ a_n \cos (n \pi t) \Bigr] \\ & = a_0 + \sum_{n=1}^\infty a_n (2 - n^2 \pi^2 ) \cos (n \pi t) \\ & = f(t) = \frac{1}{2} + \sum_{\substack{n=1\\n~\text{odd}}}^\infty \frac{-4}{\pi^2 n^2} \cos (n \pi t) . \end{split} \end{equation*}
Therefore, \(a_0 = \frac{1}{2}\text{,}\) \(a_n = 0\) for \(n\) even (\(n \geq 2\)) and for \(n\) odd we have
\begin{equation*} a_n (2 - n^2 \pi^2) = \frac{-4}{\pi^2 n^2} , \end{equation*}
or
\begin{equation*} a_n = \frac{-4}{n^2 \pi^2 (2 - n^2 \pi^2)} . \end{equation*}
The Fourier series for the solution \(x(t)\) is
\begin{equation*} x(t) = \frac{1}{4} + \sum_{\substack{n=1\\n~\text{odd}}}^\infty \frac{-4}{n^2 \pi^2 (2 - n^2 \pi^2)} \cos (n \pi t) . \end{equation*}

Subsection 5.4.4 Exercises

Exercise 5.4.1.

Let \(f(t) = \nicefrac{t}{3}\) on \(0 \leq t < 3\text{.}\)
  1. Find the Fourier series of the even periodic extension.
  2. Find the Fourier series of the odd periodic extension.
Answer.
a) \(\nicefrac{1}{2} + \sum\limits_{\substack{n=1\\n\text{ odd}}}^\infty \frac{-4}{\pi^2 n^2} \cos\bigl(\frac{n\pi}{3} t \bigr)\)        b) \(\sum\limits_{n=1}^\infty \frac{2{(-1)}^{n+1}}{\pi n} \sin\bigl(\frac{n\pi}{3} t \bigr)\)

Exercise 5.4.2.

Let \(f(t) = \cos(2t)\) on \(0 \leq t < \pi\text{.}\)
  1. Find the Fourier series of the even periodic extension.
  2. Find the Fourier series of the odd periodic extension.
Answer.
a) \(\cos(2t)\)        b) \(\sum\limits_{\substack{n=1 \\n \text{ odd}}}^\infty \frac{-4n}{\pi n^2 - 4 \pi} \sin(n t)\)

Exercise 5.4.3.

Take \(f(t) = {(t-1)}^2\) defined on \(0 \leq t \leq 1\text{.}\)
  1. Sketch the plot of the even periodic extension of \(f\text{.}\)
  2. Sketch the plot of the odd periodic extension of \(f\text{.}\)
Answer.
a)
Figure 5.34. Even Periodic Extension of \(f(t)=(t-1)^{2}\) on \([0,1]\)
b)
Figure 5.35. Odd Periodic Extension of \(f(t)=(t-1)^{2}\) on \([0,1]\)

Exercise 5.4.4.

Take \(f(t) = \sin t\) defined on \(0 \leq t \leq \pi\text{.}\)
  1. Sketch the plot of the even periodic extension of \(f\text{.}\)
  2. Sketch the plot of the odd periodic extension of \(f\text{.}\)
Answer.
a)
Figure 5.36. Even Periodic Extension of \(f(t)=\sin t\) on \([0,\pi]\)
b)
Figure 5.37. Odd Periodic Extension of \(f(t)=\sin t\) on \([0,\pi]\)

Exercise 5.4.5.

Find the Fourier series of both the odd and even periodic extension of the function \(f(t) = {(t-1)}^2\) for \(0 \leq t \leq 1\text{.}\) Can you tell which extension is continuous from the Fourier series coefficients?
Answer.
a) \(\sum\limits_{n=1}^{\infty} \frac{-4+4(-1)^{n}+2n^{2}\pi^{2}}{n^{3}\pi^{3}} \sin(n\pi t)\) b) \(\frac{1}{3}+\sum\limits_{n=1}^{\infty}\frac{4}{n^{2}\pi^{2}}\cos(n\pi t)\)

Exercise 5.4.6.

Find the Fourier series of both the odd and even periodic extension of the function \(f(t) = t\) for \(0 \leq t \leq \pi\text{.}\)
Answer.
a) \(\sum\limits_{n=1}^{\infty} \frac{2(-1)^{n+1}}{n} \sin(nt)\) b) \(\frac{\pi}{2}+\sum\limits_{n=1}^{\infty}\frac{-2+2(-1)^{n}}{n^{2}\pi}\cos(nt)\)

Exercise 5.4.7.

Find the Fourier series of the even periodic extension of the function \(f(t) = \sin t\) for \(0 \leq t \leq \pi\text{.}\)
Answer.
a) \(\sin(t)\) b) \(\frac{2}{\pi}+\sum\limits_{n=2}^{\infty}\frac{2+2(-1)^{n}}{\pi(1-n^{2})}\cos(nt)\)

Exercise 5.4.8.

Let \(f(t) = \sum_{n=1}^\infty \frac{1}{n^2} \sin(nt)\text{.}\) Solve \(x''- x = f(t)\) for the Dirichlet conditions \(x(0) = 0\) and \(x(\pi) = 0\text{.}\)
Solution.
Since our function \(f(t)\) is expanded as a Sine series, we choose \(x(t)=\sum\limits_{n=1}^\infty b_{n}\sin(nt)\) [satisfies the given boundary conditions as well]. Using this in the given differential equation, we can find the expression for \(b_{n}\) for all \(n\text{.}\) This leaves us with the final solution \(\sum\limits_{n=1}^\infty \frac{-1}{n^2(1+n^2)} \sin(nt)\)

Exercise 5.4.9.

(challenging)   Let \(f(t) = t + \sum_{n=1}^\infty \frac{1}{2^n} \sin(nt)\text{.}\) Solve \(x'' + \pi x = f(t)\) for the Dirichlet conditions \(x(0) = 0\) and \(x(\pi) = 1\text{.}\) Hint: Note that \(\frac{t}{\pi}\) satisfies the given Dirichlet conditions.
Answer.
\(\frac{t}{\pi} + \sum\limits_{n=1}^\infty \frac{1}{2^n(\pi-n^2)} \sin(nt)\)

Exercise 5.4.10.

Consider
\begin{equation*} x''(t) + 4 x(t) = f(t) , \end{equation*}
where \(f(t) = 1\) on \(0 < t < 1\text{.}\)
  1. Solve for the Dirichlet conditions \(x(0)=0, x(1) = 0\text{.}\)
  2. Solve for the Neumann conditions \(x'(0)=0, x'(1) = 0\text{.}\)
Solution.
First we use even and odd extensions of the given function \(f(t)\) to write the Cosine and Sine series, respectively. The Cosine series is given by \(1\) and the Sine series is given by \(\sum\limits_{n=1,n\,odd}^{\infty}\frac{4}{n\pi}\sin(n\pi t)\text{.}\) a) Taking \(x(t)=\sum\limits_{n=1,n\,odd}^{\infty}b_{n}\sin(n\pi t)\text{.}\) Using it in the given differential equation, we can find \(b_{n}\) to then show that \(x(t)=\sum\limits_{n=1,n\,odd}^{\infty}\frac{4}{n\pi(4-n^{2}\pi^{2})}\sin(n\pi t)\) b) \(x(t)=1/4\) is the required solution.

Exercise 5.4.11.

Consider
\begin{equation*} x''(t) + 9 x(t) = f(t) , \end{equation*}
for \(f(t) = \sin (2\pi t)\) on \(0 < t < 1\text{.}\)
  1. Solve for the Dirichlet conditions \(x(0)=0, x(1) = 0\text{.}\)
  2. Solve for the Neumann conditions \(x'(0)=0, x'(1) = 0\text{.}\)
Solution.
a) \(x(t)=\frac{1}{9-4\pi^{2}}\sin(2\pi t)\) b) \(x(t)=\sum\limits_{n=1,n\,odd}^{\infty}\frac{-8}{\pi(9-n^{2}\pi^{2})(n^{2}-4)}\cos(n\pi t)\)

Exercise 5.4.12.

Consider
\begin{equation*} x''(t) + 3 x(t) = f(t) , \quad x(0) = 0, \quad x(1) = 0, \end{equation*}
where \(f(t) = \sum_{n=1}^\infty b_n \sin (n \pi t)\text{.}\) Write the solution \(x(t)\) as a Fourier series, where the coefficients are given in terms of \(b_n\text{.}\)
Solution.
\(x(t)=\sum\limits_{n=1}^{\infty}\frac{b_n}{(3-n^{2}\pi^{2})}\sin(n\pi t)\)

Exercise 5.4.13.

Let \(f(t) = t^2(2-t)\) for \(0 \leq t \leq 2\text{.}\) Let \(F(t)\) be the odd periodic extension. Compute \(F(1)\text{,}\) \(F(2)\text{,}\) \(F(3)\text{,}\) \(F(-1)\text{,}\) \(F(\nicefrac{9}{2})\text{,}\) \(F(101)\text{,}\) \(F(103)\text{.}\) Note: Do not compute using the sine series.

Exercise 5.4.14.

Let \(f(t)\) be defined on \(0 \leq t < 1\text{.}\) Now take the average of the two extensions \(g(t) = \frac{F_{\text{odd}}(t)+ F_{\text{even}}(t)}{2}\text{.}\)
  1. What is \(g(t)\) if \(0 \leq t < 1\) (Justify!)
  2. What is \(g(t)\) if \(-1 < t < 0\) (Justify!)
Answer.
a) \(f(t)\)        b) \(0\)
www.geogebra.org/m/hfk7axbg
For a higher quality printout use the PDF version: https://www.jirka.org/diffyqs/diffyqs.pdf