# 4.4: Sine and cosine series

#### 4.4.1: Odd and even periodic functions

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)\). A function \(f(t)\) is even if \(f(-t) = f(t)\). For example, \(\cos{(nt)}\) is even and \(\sin{(nt)}\) is odd. Similarly the function \(t^k\) is even if \(k\) is even and odd when \(k\) is odd.

Exercise \(\PageIndex{1}\):

Take two functions \(f(t)\) and \(g(t)\) and define their product \(h(t) =f(t)\,g(t)\). a) Suppose both are odd, is \(h(t)\) odd or even? b) Suppose one is even and one is odd, is \(h(t)\) odd or even? c) Suppose both are even, is \(h(t)\) odd or even?

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)\). 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]\). 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 will 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]\). On \((-L,L]\) define the functions

\[ F_{\rm{odd}}(t) \overset{ \rm{def}}{=} \left\{ \begin{array}{ccc} f(t) & \rm{if} & 0 \leq t \leq L, \\ -f(-t) & \rm{if} & -L < t < 0, \end{array} \right. \\ F_{\rm{even}}(t) \overset{ \rm{def}}{=} \left\{ \begin{array}{ccc} f(t) & \rm{if} & 0 \leq t \leq L, \\ f(-t) & \rm{if} & -L < t < 0. \end{array} \right.\]

Extend \(F_{odd}(t)\) and \(F_{even}(t)\) to be \(2L\)-periodic. Then \(F_{odd}(t)\) is called the odd periodic extension of \(f(t)\), and \(F_{even}(t)\) is called the even periodic extension of \(f(t)\).

Exercise \(\PageIndex{2}\):

Check that \(F_{odd}(t)\) is odd and that \(F_{even}(t)\) is even.

Example \(\PageIndex{1}\):

Take the function \(f(t) = t(1-t)\) defined on \([0,1]\). Figure 4.11 shows the plots of the odd and even extensions of \(f(t)\).

**Figure 4.11**: Odd and even 2-periodic extension of \( f(t) = t(1-t),~ 0 \leq t \leq 1.\)

#### 4.4.2 Sine and cosine series

Let \(f(t)\) be an odd \(2L\)-periodic function. We write the Fourier series for \(f(t)\). First, we compute the coefficients \(a_n\) (including \( n=0 \)) and get

\[a_n = \dfrac{1}{L} \int _{-L}^L f(t) \text{cos} \left(\frac{n\pi}{L}t \right) dt = 0. \]

That is, there are no cosine terms in the Fourier series of an odd function. The integral is zero because \( f(t) \cos{(\frac{n\pi}{L}t)}\) 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]\). The function \(f(t) \sin{(\frac{n\pi}{L}t)}\) is the product of two odd functions and hence is even.

\[ b_n = \dfrac{1}{L} \int_{-L}^L f(t) \sin{\left( \dfrac{n\pi}{L}t \right)}\,dt = \dfrac{2}{L} \int_{0}^L f(t) \sin{\left( \dfrac{n\pi}{L}t \right)}\,dt.\]

We now write the Fourier series of \(f(t)\) as

\[ \sum_{n=1}^{\infty} b_n \sin{\left( \dfrac{n\pi}{L}t \right)}.\]

Similarly, if \(f(t)\) is an even \(2L\)-periodic function. For the same exact reasons as above, we find that \(b_n=0\) and

\[a_n = \dfrac{2}{L} \int_0^{L} f(t) \cos{\left( \dfrac{n\pi}{L}t\right)} \, dt.\]

The formula still works for \(n=0\), in which case it becomes

\[a_0= \dfrac{2}{L}\int_0^L f(t)\, dt.\]

The Fourier series is then

\[ \dfrac{a_0}{2} + \sum_{n=1}^{\infty} a_n \cos{\left( \dfrac{n\pi}{L} t \right)}.\]

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]\). 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.

**Theorem 4.4.1.** *Let* \(f(t)\) *be a piecewise smooth function defined on* \([0,L]\). *Then the odd extension of* \(f(t)\) *has the Fourier series*

\[ F_{odd}(t) = \sum_{n=1}^{\infty} b_n \sin{\left(\dfrac{n\pi}{L}t\right)},\]

*where*

\[ b_n = \dfrac{2}{L} \int_0^{L} f(t) \sin{\left( \dfrac{n\pi}{L} t \right)} \,dt. \]

*The even extension of* \(f(t)\) *has the Fourier series*

\[ F_{even}(t) = \dfrac{a_0}{2} + \sum_{n=1}^{\infty} a_n \cos{\left(\dfrac{n\pi}{L}t\right)},\]

*where*

\[ a_n = \dfrac{2}{L} \int_0^{L} f(t) \cos{\left( \dfrac{n\pi}{L} t \right)} \,dt. \]

The series \( \sum_{n=1}^{\infty} b_n \sin{\left(\dfrac{n\pi}{L}t\right)}\) is called the *sine series* of \(f(t)\) and the series \( \dfrac{a_0}{2} + \sum_{n=1}^{\infty} a_n \cos{\left(\dfrac{n\pi}{L}t\right)}\) is called the *cosine series* of \(f(t)\). We often do not actually care what happens outside of \([0,L]\). In this case, we pick whichever series fits our problem better.

\[ \left \langle f(t),g(y)\right \rangle =\int _0^L f(t)g(t)\,dt,\]

and following the procedure of § 4.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 5.

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 the eigenfunctions of the eigenvalue problem \( x'' + \lambda x=0, x(0) =0, x(L)=L\). The cosine series is the eigenfunction expansion of \( f(t)\) using the eigenfunctions of the eigenvalue problem \( x'' + \lambda x=0, x'(0) =0, x'(L)=L\). We could have, therefore, gotten the same formulas by defining the inner product

\[ \left \langle f(t),g(t)\right \rangle =\int _0^L f(t)g(t)\,dt,\]

and following the procedure of ch. 4.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 5.

Example \(\PageIndex{2}\):

Find the Fourier series of the even periodic extension of the function \( f(t)= t^2\) for \( 0 \leq t \leq \pi\).

We want to write

\[ f(t) = \frac{a_0}{2} + \sum_{n=1}^{\infty} a_n \cos(nt),\]

where

\[ a_0= \frac{2}{\pi} \int_0^{\pi}t^2dt= \frac{2 \pi^2}{3},\]

and

\[ a_0= \frac{2}{\pi} \int_0^{\pi}t^2 \cos(nt) dt= \frac{2 }{\pi} \left[ t^2 \frac{1}{n} \sin(nt)\right]_0^{\pi} - \frac{4}{n \pi} \int_0^{\pi} t \sin(nt)dt \\ \frac{4}{n^2 \pi} \left[ t \cos(nt)\right]_0^{\pi} + \frac{4}{n^2 \pi} \int_0^{\pi} \cos(nt)dt = \frac{4(-1)^n}{n^2}.\]

Note that we have “detected” the continuity of the extension since the coefficients decay as \(\frac{1}{n^2}\). That is, the even 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}\).

Explicitly, the first few terms of the series are

\[ \dfrac{\pi^2}{3}-4\cos{(t)}+\cos{(2t)} - \dfrac{4}{9}\cos{(3t)} + \cdots \]

Exercise \(\PageIndex{3}\):

a) Compute the derivative of the even extension of \(f(t)\) above and verify it has jump discontinuities. Use the actual definition of \(f(t)\), not its cosine series! b) Why is it that the derivative of the even extension of \(f(t)\) is the odd extension of \(f'(t)\)?

#### 4.4.3 Application

Fourier series ties in to the boundary value problems we studied earlier. Let us see this connection in more detail.

Suppose we have the boundary value problem for \( 0<t <L\).

\[ x''(t) + \lambda x(t) = f(t),\]

for the *Dirichlet boundary conditions* \(x(0) = 0, x(L)=0\). By using the Fredholm alternative (Theorem 4.1.2) we note that as long as \(\lambda\) is *not *an eigenvalue of the underlying homogeneous problem, there exists a unique solution. Note that the eigenfunctions of this eigenvalue problem are the functions \(\sin{\left(\frac{n\pi}{L}t\right)}\). Therefore, to find the solution, we first find the Fourier sine series for \(f(t)\). 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\) and \(x'(L)=0\), we do the same procedure using the cosine series.

Let us see how this method works on examples.

Example \(\PageIndex{3}\):

Take the boundary value problem for \(0<t<1\),

\[x''(t) + 2x(t) = f(t),\]

where \(f(t)=t\) on \(0<t<1\), and satisfying the **Dirichlet boundary** conditions \(x(0) = 0\) and \(x(1)=0\). We write \(f(t)\) as a sine series

\[ f(t) = \sum_{n=1}^{\infty} c_n \sin{(n\pi t)},\]

where

\[ c_n = 2\int_0^1 t\, \sin{(n\pi t)}\,dt = \dfrac{2(-1)^{n+1}}{n\pi}.\]

We write \(x(t)\) as

\[x(t)=\sum_{n=1}^{\infty} b_n \sin{(n\pi t)}.\]

We plug in to obtain

\[ x''(t)+2x(t)= \sum_{n=1}^{\infty} -b_n n^2 \pi^2 \sin(n \pi t)+2 \sum_{n=1}^{\infty} b_n \sin(n \pi t) \\ = \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).\]

Therefore,

\[ b_n (2-n^2\pi^2) = \dfrac{2(-1)^{n+1}}{n\pi} .\]

or

\[ b_n = \dfrac{2(-1)^{n+1}}{n\pi(2-n^2\pi^2)} .\]

We have thus obtained a Fourier series for the solution

\[ x(t) = \sum_{n=1}^{\infty} \dfrac{2(-1)^{n+1}}{n\pi (2-n^2\pi^2)} \sin{(n\pi t)}.\]

Example \(\PageIndex{4}\):

Similarly we handle the Neumann conditions. Take the boundary value problem for \(0<t<1\),

\[x''(t) + 2x(t) = f(t),\]

where again \(f(t)=t\) on \(0<t<1\), but now satisfying the Neumann boundary conditions \(x'(0) = 0\) and \(x'(1)=0\). We write \(f(t)\) as a cosine series

\[ f(t) = \dfrac{c_0}{2} + \sum_{n=1}^{\infty} c_n\cos{(n\pi t)},\]

where

\[ c_0=2\int_0^1 t \,dt =1\]

and

\[ c_n= 2 \int_0^1 t \cos(n \pi t)dt= \frac{2((-1)^n-1)}{\pi^2 n^2}= \left\{ \begin{array}{ccc} \frac{-4}{\pi^2 n^2} & \rm{if~} \it{n} \rm{~odd}, \\ 0 & \rm{if~} \it{n} \rm{~even}. \end{array} \right.\]

We also write \(x(t)\) as a cosine series

\[ x(t) = \dfrac{a_0}{2} + \sum_{n=1}^{\infty} a_n\cos{(n\pi t)}.\]

We plug in to obtain

\[ x''(t)+2x(t)= \sum_{n=1}^{\infty} \left[-a_n n^2 \pi^2 \cos(n \pi t) \right]+a_0+2 \sum_{n=1}^{\infty} \left[a_n \cos(n \pi t) \right] \\ =a_0 + \sum_{n=1}^{\infty} a_n (2-n^2 \pi^2) \cos(n \pi t) \\ = f(t)=\frac{1}{2}+ \sum_{\underset{n ~ odd}{n=1}}^{\infty} \frac{-4}{ \pi^2 n^2} \cos(n \pi t).\]

Therefore, \(a = \frac{1}{2}\) and \(a_n=0\) for \(n\) even (\(n \geq 2\)) and for \(n\) odd we have

\[ a_n(2-n^2\pi^2) = \dfrac{-4}{\pi^2n^2},\]

or

\[ a_n=\dfrac{-4}{n^2\,\pi^2(2-n^2\pi^2)}.\]

The Fourier series for the solution \(x(t)\) is

\[ x(t)= \frac{1}{4}+ \sum_{\underset{n ~ odd}{n=1}}^{\infty} \frac{-4}{ n^2 \pi^2(2- n^2 \pi^2)} \cos(n \pi t). \]

#### 4.4 Exercises

**Exercise 4.4.4:** Take \( f(t)=(t-1)^2\) defined on \( 0 \leq t \leq 1\). a) Sketch the plot of the even periodic extension of \(f\). b) Sketch the plot of the odd periodic extension of \(f\).

**Exercise 4.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\). Can you tell which extension is continuous from the Fourier series coefficients?

**Exercise 4.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\).

**Exercise 4.4.7:** Find the Fourier series of the even periodic extension of the function \( f(t) = \sin t\) for \( 0 \leq t \leq \pi\).

**Exercise 4.4.8:** Consider

\[ x''(t)+4x(t)=f(t),\]

where \( f(t)=1\) on \( 0< t<1\). a) Solve for the Dirichlet conditions \( x(0)=0, x(1)=0\). b) Solve for the Neumann conditions .

**Exercise 4.4.9:** Consider

\[ x''(t)+9x(t)=f(t),\]

for \( f(t)= \sin(2 \pi t)\) on \( 0< t<1\). a) Solve for the Dirichlet conditions \( x(0)=0, x(1)=0\). b) Solve for the Neumann conditions \( x'(0)=0, x'(1)=0\).

**Exercise 4.4.10:** Consider

\[ x''(t)+3x(t)=f(t),~~~~ x(0)=0,~~~~ x(1)=0, \]

where \( f(t)= \sum_{n=1}^{\infty} b_n \sin(n \pi t)\). Write the solution \(x(t)\) as a Fourier series, where the coefficients are given in terms of \(b_n\).

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

**Exercise 4.4.101:** Let \(f(t)= \frac{t}{3}\) on \( 0 \leq t <3\). a) Find the Fourier series of the even periodic extension. b) Find the Fourier series of the odd periodic extension.

**Exercise 4.4.102:** Let \( f(t)= \cos(2t)\) on \(0 \leq t < \pi\). a) Find the Fourier series of the even periodic extension. b) Find the Fourier series of the odd periodic extension.

**Exercise 4.4.103:** Let \(f(t)\) be defined on \(0 \leq t < 1\). Now take the average of the two extensions \( g(t)= \frac{F_{odd}(t)+F_{even}(t)}{2}\). a) What is \(g(t)\) if \(0 \leq t < 1\) (Justify!) b) What is \( g(t)\) if \(-1 < t < 0\) (Justify!)

**Exercise 4.4.104:** Let \( f(t)= \sum_{n=1}^{\infty} \frac{1}{n^2} \sin(nt)\). Solve \( x'' -x=f(t)\) for the Dirichlet conditions \( x(0)=0\) and \( x(\pi)=0\).

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

### Contributors

- Jiří Lebl (Oklahoma State University).These pages were supported by NSF grants DMS-0900885 and DMS-1362337.