# 4.4: Sine and cosine series

- Page ID
- 346

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

## Contributors

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