Problem Set 13 Solutions

ENGR 12, Spring 2026.

Solutions

1 Even and odd functions

Sketch (or plot) the following functions and determine whether they are even, odd, or neither. Use radians instead of degrees, if relevant.

  1. \(\sin x\)
  2. \(\cos x\)
  3. \(\tan x\)
  4. \(\tan^{-1} x\)
  5. \(\cos^{-1} x - \pi/2\) over the domain \((-1, +1)\)
  6. \(\sin^{-1} x\)
  7. \(x^2\)
  8. \(x^3\)
  9. \((x-2)^2\)
  10. \(e^x\)
TipSolution
No. Graph Characteristic
1 Odd
2 Even
3 Odd
4 Odd
5 Odd
6 Odd
7 Even
8 Odd
9 Neither
10 Neither

2 Some Rules about even and odd functions

Complete the following statements and give an example in each case. Use the words even, odd, or neither to fill in each blank.

Statement
An even function times an even function is even
An even function plus an even function is ?
An even function times an odd function is ?
An even function plus an odd function is ?
An odd function multipled by an odd function is ?
An odd function plus an odd function is ?

By using candidate functions like \(\sin x\), \(\cos x\), \(x^2\), and \(x\), illustrate each of the above statements with an example by checking for yourself whether the result is even, odd, or neither even nor odd. Your example should consist of a plot or sketch showing clearly which two functions were multiplied or added to each other.

TipSolution
Statement Illustration
An even function times an even function is even
An even function plus an even function is even
An even function times an odd function is odd
even function plus an odd function is neither
An odd function times an odd function is even
An odd function plus an odd function is odd

3 FFT in MATLAB

Download the following data file, which contains sampled measurements of some signal that was measured every \(0.02\) seconds. We suspect that the data was produced from some noisy signal containing only three discrete frequencies, which we will extract from this noisy data using MATLAB’s fft function.

Get data file

Get MATLAB file

The data looks like this when plotted against time:

Identify a function of the kind \[f_1(n_1 t) + f_2(n_2 t) + f_3(n_3 t) + \mathrm{noise} \tag{1}\] that best represents this data, where \(n_1\), \(n_2\) and \(n_3\) are three integers that MATLAB will help you identify. \(f_1\), \(f_2\) and \(f_3\) are either \(\sin\) or \(\cos\). The ‘noise’ term is not a real mathematical thing, but just a recognition that this data is not purely a sum of sines and cosines. Give your answer as a mathematical expression, and include a copy of the resulting MATLAB figure showing the correct expression in sub-plot 3. The first two sub-plots should not be changed.

Note

Note that there is no multiplicate factor in Equation 1, i.e., each sin or cos function is multiplied by 1. In other words, you do not need to look for ‘magnitudes’ for each Fourier mode.

Tip

If you don’t know where to start, run FFT_question.m and look for peaks that are close to integers. Then, think about what function — made up of up to three sines or cosines — could best represent the given data.

TipSolution

After some trial and error, we see that the function \[\sin(3t) + \cos(2t) + \cos(30t)\]

does a good job of representing the data.

We can see this below, where the approximate function is overlaid on top of the data, showing reasonable agreement.

4 Triangle Wave

Consider the triangle wave shown below. It is periodic with period \(2\pi\) and is even about the vertical axis.

Figure 1: Triangle Wave

The triangle wave shown above can be defined using the following mathematical expression

\[ \begin{aligned} f(t) &= \begin{cases} 2 + \displaystyle \frac{t - \pi}{\pi} & -\pi < t < 0 \\ \displaystyle \frac{\pi - t}{\pi} & 0 < t < +\pi \\ \end{cases},\\ f(t+2\pi) &= f(t) \end{aligned} \]

Show by using piecewise integration of the Euler Formulas that

  1. \(\displaystyle a_n =\frac{4}{n^2 \pi^2}\) for odd values of \(n>0\),
  2. \(a_n = 0\) for even values of \(n\)
  3. \(a_0 = 1/2\).
  4. \(b_n=0\) for all values of \(n\)

and therefore, that the infinite Fourier series for this function is

\[f(t) = \frac{1}{2} + \frac{4}{\pi^2} \left( \cos t + \frac{\cos 3t}{9} + \frac{\cos 5t}{25} + ...\right) \tag{2}\]

TipSolution

To solve this problem, we need to calculate \(a_n\) and \(b_n\).

4.0.1 Expression for \(a_n\)

Let’s start by computing the integral \[ \begin{aligned} a_n &= \frac{1}{\pi} \int_{-\pi}^{+\pi} f(t) \cos nt \, dt. \\ &= \frac{1}{\pi} \int_{-\pi}^{0} \left( 2 + \displaystyle \frac{t - \pi}{\pi} \right) \cos nt \, dt + \frac{1}{\pi}\int_{0}^{+\pi} \left(\displaystyle \frac{\pi - t}{\pi} \right) \cos nt \, dt \\ a_n &= \frac{1}{\pi} \int_{-\pi}^{0} 2 \cos nt \, dt + \frac{1}{\pi} \int_{-\pi}^{0} \left(\displaystyle \frac{t - \pi}{\pi} \right) \cos nt \, dt + \frac{1}{\pi} \int_{0}^{+\pi} \left(\displaystyle \frac{\pi - t}{\pi} \right) \cos nt \, dt \end{aligned} \tag{3}\] and we shall compute the three terms above separately.

4.0.1.1 First term: \(\int 2 \cos nt \, dt\) from \(-\pi\) to \(0\)

The first term in Equation 3 is \[\frac{1}{\pi} \int_{-\pi}^{0} 2 \cos nt \, dt = \frac{2}{\pi} \left. \frac{\sin nt}{n} \right|_{-\pi}^{0} = \frac{2}{\pi} \left(\frac{\sin 0}{n} - \frac{\sin (-n \pi)}{n} \right) = 0.\]

4.0.1.2 Second term: from \(-\pi\) to \(0\)

The second term in Equation 3 is

\[ \begin{aligned} & \frac{1}{\pi} \int_{-\pi}^{0} \left( \frac{t}{\pi} \cos nt - \frac{\pi}{\pi} \cos nt \right) dt \\ &= \frac{1}{\pi} \left[ \frac{t}{n\pi} \sin nt + \frac{1}{\pi n^2} \cos nt - \frac{1}{n} \sin nt \right]_{-\pi}^{0} \end{aligned} \] where we have used integration by parts to find that \[\int t \cos nt \, dt = \frac{t \sin nt}{n} + \frac{\cos nt}{n^2}. \tag{4}\]

Continuting with the second term in Equation 3, we evaluate each of the three terms at \(0\) and \(-\pi\):

\[ \begin{split} = \frac{1}{\pi} \left[ \frac{t}{\pi n} \sin 0 + \frac{1}{\pi n^2} \cos 0 - \frac{1}{n} \sin 0 \right] - \\ \frac{1}{\pi} \left[ \left( \frac{(-\pi)}{\pi n} \sin (- n \pi) + \frac{1}{\pi n^2} \cos (- \pi n) - \frac{1}{n} \sin (- n \pi) \right) \right] \\ \end{split} \]

\[ \begin{aligned} &= \frac{1}{\pi} \left[ 0 + \frac{1}{\pi n^2} - 0 - 0 - \frac{1}{\pi n^2} \cos (- n \pi) - 0 \right] \\ &= \frac{1}{\pi^2 n^2} - \frac{1}{\pi^2 n^2} \cos n \pi \end{aligned} \]

Now, we recall that for even \(n\), \(\cos n \pi = +1\) and for odd \(n\), \(\cos n \pi = -1\). This gives us that the first term in Equation 3 is:

\[\begin{cases} \displaystyle \frac{2}{n^2 \pi^2} & n \text{ odd} \\ 0 & n \text{ even}. \end{cases}\]

4.0.1.3 Third term: from \(0\) to \(+\pi\)

We now turn our attention to the third term in Equation 3, which is

\[ \begin{aligned} & \frac{1}{\pi} \int_{0}^{+\pi} \left( \frac{\pi }{\pi} \cos nt - \frac{t}{\pi} \cos nt \right) dt \\ &= \frac{1}{\pi} \left[ \frac{1}{n} \sin nt - \left( \frac{t}{n \pi} \sin nt + \frac{1}{n^2 \pi } \cos nt \right) \right]_{0}^{+\pi} \end{aligned} \] where we have once again used integration by parts from Equation 4.

We now evaluate each of the three terms above at \(0\) and at \(+\pi\), finding

\[ \begin{aligned} &= \frac{1}{\pi} \left[ \frac{\sin n\pi}{n} - \frac{\pi}{n \pi} \sin n \pi - \frac{\cos n \pi}{n^2 \pi} - \left( \frac{1}{n} \sin 0 - \left( 0 \sin 0 + \frac{\cos 0}{n^2 \pi}\right) \right) \right] \\ &= \frac{1}{\pi} \left[ 0 - 0 - \frac{\cos n \pi }{n^2 \pi} - 0 + 0 + \frac{1}{n^2 \pi}\right] \\ &= \frac{1}{\pi^2 n^2} - \frac{1}{\pi^2 n^2} \cos n \pi \end{aligned} \]

which is identical to what we found earlier. So this, too is equal to

\[\begin{cases} \displaystyle \frac{2}{n^2 \pi^2} & \text{if } n \text{ is odd, and} \\ 0 & \text{if } n \text{ is even}. \end{cases}\]

4.0.1.4 Overall expression for \(a_n\)

Thus, adding up the different terms, we find that

\[a_n = \begin{cases} \displaystyle \frac{4}{n^2 \pi^2} & \text{if } n \text{ is odd, and} \\ 0 & \text{if } n \text{ is even.} \end{cases}\]

4.0.2 Expression for \(b_n\)

The next task is to calculate \(b_n\). From the Euler formula, we know that

\[ \begin{aligned} b_n &= \frac{1}{\pi} \int_{-\pi}^{+\pi} f(t) \sin nt \, dt. \\ &= \frac{1}{\pi} \int_{-\pi}^{0} \left(2 + \displaystyle \frac{t - \pi}{\pi} \right) \sin nt \, dt + \frac{1}{\pi}\int_{0}^{+\pi} \left(\displaystyle \frac{\pi - t}{\pi} \right) \sin nt \, dt \\ &= \frac{1}{\pi} \int_{-\pi}^{0} 2 \sin nt \, dt + \frac{1}{\pi} \int_{-\pi}^{0} \left(\displaystyle \frac{t - \pi}{\pi} \right) \sin nt \, dt + \frac{1}{\pi} \int_{0}^{+\pi} \left(\displaystyle \frac{\pi - t}{\pi} \right) \sin nt \, dt \end{aligned} \tag{5}\]

4.0.2.1 First term: \(\int 2 \sin nt \, dt\) from \(-\pi\) to \(0\)

The first term above is

\[ \begin{aligned} \frac{1}{\pi} \int_{-\pi}^{0} 2 \sin nt \, dt &= -\frac{2}{\pi} \left. \frac{\cos nt}{n} \right|_{-\pi}^{0} = \frac{-2}{\pi} \left(\frac{\cos 0}{n} - \frac{\cos (-n \pi)}{n} \right) = 0. \\ &= \frac{-2}{n\pi} \left( 1 - \cos n \pi \right) \text{ since } \cos \text{ is even.} \\ &= \begin{cases} 0 & n \text{ even} \\ \displaystyle \frac{-4}{n \pi} & n \text{ odd.}\end{cases} \end{aligned} \]

Where we have deduced the above from the fact that \(\cos n \pi = 1\) for even \(n\) and \(\cos n \pi = -1\) for odd \(n\).

4.0.2.2 Second term: from \(-\pi\) to \(0\)

The second term in Equation 5 will once again require integration by parts. We have

\[ \begin{aligned} & \frac{1}{\pi} \int_{-\pi}^{0} \left(\displaystyle \frac{t - \pi}{\pi} \right) \sin nt \, dt \\ &= \frac{1}{\pi} \left[ \frac{-t \cos nt}{n \pi} + \frac{\sin nt}{n^2 \pi} + \frac{\cos nt}{n} \right]_{-\pi}^{0} \end{aligned} \]

where we have used integration by parts to find that \[\int t \sin nt \, dt = -\frac{t \cos nt}{n} + \frac{\sin nt}{n^2} \tag{6}\]

Continuing with the second term in Equation 5, we evaluate each of the three terms at \(0\) and \(-\pi\):

\[ \begin{split} \frac{1}{\pi} \left[\frac{- 0 \cos 0}{n \pi} + \frac{\sin 0}{n^2 \pi} + \frac{\cos 0}{n} \right] - \\ \frac{1}{\pi} \left[ \frac{-(-\pi) \cos (-n\pi)}{n \pi} + \frac{\sin (-n \pi)}{n^2 \pi} + \frac{\cos (-n \pi)}{n} \right] \end{split} \]

\[ \begin{aligned} &= \frac{1}{\pi} \left[ 0 + 0 + \frac{1}{n} \right] - \frac{1}{\pi} \left[ \frac{\cos n\pi}{n} + 0 + \frac{\cos n \pi}{n} \right] \\ &= \frac{1}{\pi} \left( \frac{1}{n} - \frac{2 \cos n \pi}{n}\right) \\ &= \begin{cases} \displaystyle \frac{1}{\pi} \left( \frac{1}{n} - \frac{2}{n}\right) = -\frac{1}{n \pi} & n \text{ even} \\ \displaystyle \frac{1}{\pi} \left( \frac{1}{n} - \frac{-2}{n}\right) = \frac{3}{n \pi} & n \text{ odd}\end{cases} \end{aligned} \]

4.0.2.3 Third term: from \(0\) to \(+\pi\)

We now turn our attention to the third term in Equation 5, which is

\[ \begin{aligned} & \frac{1}{\pi} \int_{0}^{+\pi} \left(\displaystyle \frac{\pi- t}{\pi} \right) \sin nt \, dt \\ &= \frac{1}{\pi} \left[ \frac{- \cos nt}{n} + \frac{t \cos nt}{n \pi} - \frac{\sin nt}{n^2 \pi} \right]_{0}^{+\pi} \end{aligned} \]

where we have once again used integration by parts from Equation 6.

We now evaluate each of the three terms above at \(0\) and at \(+\pi\), finding

\[ \begin{aligned} &= \frac{1}{\pi} \left[ \frac{- \cos n\pi}{n} + \frac{\pi \cos n \pi}{n \pi} - \frac{\sin n \pi}{n^2 \pi} - \left( \frac{- \cos 0}{n} + \frac{0 \cos 0}{n \pi} - \frac{\sin 0}{n^2 \pi} \right)\right] \\ &= \frac{1}{\pi} \left[ \frac{- \cos n\pi}{n} + \frac{\cos n \pi}{n} - 0 + \frac{1}{n} + 0 + 0 \right] \\ &= \frac{1}{n \pi} \end{aligned} \]

4.0.2.4 Overall expression for \(b_n\)

We have a lot of terms to collect now. Let’s write out what \(b_n\) is in the even and odd cases.

  • Even \(n\):

\[b_n = 0 - \frac{1}{n \pi} + \frac{1}{n \pi}\]

which amounts to zero.

  • Odd \(n\):

\[b_n = \frac{-4}{n \pi} + \frac{3}{n \pi} + \frac{1}{n \pi}\]

which also amounts to zero.

Thus, we have successfully shown that \(b_n = 0\) for all \(n\), QED.

4.0.3 Expression for \(a_0\)

\[ \begin{aligned} a_0 &= \frac{1}{2\pi} \int_{-\pi}^{+\pi} f(t) dt \\ &= \frac{1}{2\pi} \int_{-\pi}^{0} \left( 2 + \frac{t-\pi}{\pi} \right) dt + \frac{1}{2\pi} \int_{0}^{+\pi} \left(\frac{\pi - t}{\pi} \right) dt \end{aligned} \]

At this point, we note that Figure 1 depicts an odd function and the area under the graph should be the same to the left and to the right. So for simplicity I will just find the area under the graph for the right-hand side, since that integral looks simpler. Then I can multiply by 2.

\[ \begin{aligned} & \frac{1}{2\pi} \int_{0}^{+\pi} \left(\frac{\pi- t}{\pi} \right) dt \\ &= \frac{1}{2\pi^2} \int_{0}^{+\pi} \pi \,dt - \frac{1}{\pi^2} \int_{0}^{+\pi} t \,dt \\ &= \frac{1}{2\pi^2} \left. \frac{t \pi}{1} \right|_{0}^{+\pi} - \frac{1}{2\pi^2} \left. \frac{t^2}{2} \right|_{0}^{+\pi} \\ &= \frac{\pi^2}{2 \pi^2} - \frac{\pi^2}{4 \pi^2} = \frac{1}{4} \end{aligned} \]

and therefore, multiplying the above result by 2 to account for the area under the left-half of the graph of \(f(t)\), we have \[a_0 = 2 \times \frac{1}{4} = \frac{1}{2}.\]

We have therefore successfully shown that the Fourier series for Equation 2 is

\[ \begin{aligned} f(t) &= \frac{1}{2} + \sum_{n=1}^{\infty} \left( a_n \cos n t + b_n \sin n t \right) \\ \text{ where } a_n &= \begin{cases} \displaystyle \frac{4}{n^2 \pi^2} & n \text{ odd} \\ 0 & n \text{ even}. \end{cases} \\ \text{ and } b_n &= 0 \text{ for all } n. \end{aligned} \]