Skip to main content

Applied Mathematics

Section 6.4 Approximation by Trigonometric Polynomials

Consider a periodic function \(f\) of period \(2\pi\) on the interval \([-\pi,\pi]\text{.}\) The \(N\)th partial sum of the Fourier Series of \(f\) is denoted \(f_N\text{,}\)
\begin{equation*} f_N(x) = a_0 + \sum_{n=1}^N (a_n \cos nx + b_n \sin nx) \end{equation*}
where \(a_0, a_n\) and \(b_n\) are the Fourier Coefficients as before. The function \(f_N\) is also called the Trigonometric Polynomial of degree \(n\).
Let’s ask a question about approximation. Consider a function of the form:
\begin{equation*} F_N(x) =A_0 + \sum_{n=1}^N (A_n \cos nx + B_n \sin nx) \end{equation*}
What is the best approximate for a trigonometric polynomial to another function \(F(x)\text{.}\) That is, what coefficients can be chosen \(A_0, A_n, B_n\text{?}\)
To answer this question, we will need to know what error we are taking about. Typically the error will be some function of the two functions, called \(E(f,g)\) that outputs a number. We would like the error to have the following properties:
\begin{align*} E(f,g) \amp = E(g,f) \\ E(f,g) \amp \geq 0 \\ E(f,f) \amp = 0 \end{align*}
one such function that we know is the function norm or square of it:
\begin{align*} E(F,F_N) \amp = \langle F-F_N,F-F_N \rangle = ||F-F_N||^2 \\ \amp = \int_{-\pi}^{\pi} (F(x)-F_N(x))^2 \, dx \\ \amp = \int_{-\pi}^{\pi}\bigl(F(x) - A_0 - \sum_{n=1}^{N} (A_n \cos nx + B_n \sin nx) \bigr)^2 \end{align*}
To find the minimum of this, we will take the derivatives of \(E\) with respect to \(A_0, A_n\) and \(B_n\) and solve for where the derivative is 0.
\begin{align*} \frac{\partial E}{\partial A_0} \amp = -2 \int_{-\pi}^{\pi} \bigl(F(x) - A_0 - \sum_{n=1}^{N} (A_n \cos nx + B_n \sin nx ) \bigr) \\ 0 \amp = \langle F, 1\rangle - \langle A_0, 1 \rangle - \sum_{n=1}^{N} (\langle A_n \cos n x, 1 \rangle + \langle B_n \sin nx, 1 \rangle ) \\ 0 \amp = \langle F, 1\rangle - A_0\langle 1, 1 \rangle \end{align*}
\begin{equation} A_0 = \frac{\langle F,1\rangle}{\langle 1,1 \rangle} = \frac{1}{2\pi} \int_{-\pi}^{\pi} F(x)\,dx\tag{6.4.1} \end{equation}
Similarly take the derivative with respect to \(A_m\text{:}\)
\begin{align*} \frac{\partial E}{\partial A_m} \amp = -2 \int_{-\pi}^{\pi} \cos mx \bigl(F(x) - A_0 - \sum_{n=1}^{N} (A_n \cos nx + B_n \sin nx ) \bigr)\\ \amp \qquad \text{set the derivative to 0} \\ 0 \amp = \langle F, \cos mx \rangle - \langle A_0, \cos mx \rangle \\ \amp \qquad - \sum_{n=1}^{N} (\langle A_n \cos n x, \cos mx \rangle + \langle B_n \sin nx, \cos mx \rangle ) \end{align*}
Note that \(\langle \cos nx,\cos mx\rangle =0\) unless \(m=n\) and \(\langle 1,\cos mx\rangle=0\)
\begin{align} 0 \amp = \langle F, \cos mx \rangle - A_m \langle \cos mx, \cos mx \rangle \notag\\ \amp \qquad \text{or}\notag\\ A_m \amp = \frac{\langle F, \cos mx\rangle }{\langle \cos mx, \cos mx \rangle } = \frac{1}{\pi} \int_{-\pi}^{\pi} F(x) \cos m x \, dx\tag{6.4.2} \end{align}
And similarly it can be shown that
\begin{equation} B_m = \frac{1}{\pi} \int_{-\pi}^{\pi} F(x) \sin mx \, dx\tag{6.4.3} \end{equation}
Note that the coefficients \(A_0, A_m\) and \(B_m\) in (6.4.1), (6.4.2) and (6.4.3) are the Fourier Coefficients, seen in SectionΒ 6.2

Remark 6.4.1.

Let \(f(x)\) be a piecewise continuous function on \([-\pi,\pi]\text{,}\) \(N \gt 0\) and
\begin{equation*} f_N (x) = a_0 + \sum_{n=1}^N (a_n \cos nx + b_n \sin nx) \end{equation*}
The values of \(a_n\) and \(b_n\) that minimize \(||f-f_N||\) (or \(||f-f_N||^2\)) is
\begin{align*} a_0 \amp = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) \, dx \\ a_n \amp = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos n x \, dx \\ b_n \amp = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin n x \, dx \end{align*}
that is they are the Fourier Coefficients.

Example 6.4.2.

In Example ExampleΒ 6.2.5, the Fourier series of the sawtooth function was found the Fourier Coefficients are:
\begin{align*} a_0 \amp = \frac{\pi}{2} \\ a_n \amp = \frac{2}{\pi n^2} ((-1)^n-1) \qquad \text{$n \geq 1$} \\ b_n \amp = 0 \end{align*}
Graph the sawtooth function and \(f_{9}(x)\text{,}\) the 9th degree trigonometric polynomial.
Solution.
Figure 6.4.3. Plot of the sawtooth wave and it’s 9th degree trigonometric approximation.
and the two plots are indistinguishable on this scale.

Example 6.4.4.

In ExampleΒ 6.2.3, the Fourier series of the square wave function was found and the Fourier Coefficients are:
\begin{align*} a_0 \amp = 0 \\ a_n \amp = 0 \\ b_n \amp = \frac{2}{n\pi} (1- (-1)^n) \end{align*}
Graph the square wave function and \(f_{9}(x)\text{,}\) the \(9\)th degree trigonometric polynomial.
Solution.
Figure 6.4.5. Graph of the square wave function and the \(9\)th degree trigonometric polynomial.
And in contrast to the previous example, the trigonometric polynomial \(f_9(x)\) and the original function \(f\) are quite different. This is mainly due to the discontinuities in the original function.
We will explore this example in a bit more detail after seeing some important theorems.

Subsection 6.4.1 Theorems Related to Fourier Series

There are two important consequences of this theorem:
  • If the integral on the right side is finite, then the series on the left converges. Functions in which the right side is finite are piecewise continuous functions.
  • The error, \(E^{\star}\) in ((6.4.4)) goes to zero. That is Fourier Series converge to \(f\) (using the square error).

Example 6.4.9.

Calculate \(E^{\star}\) for the function:
\begin{equation*} f(x) = \begin{cases} \pi+x \amp x \in [-\pi,0) \\ \pi-x \amp x \in [0,\pi] \end{cases} \end{equation*}
and extended periodically and let \(N=5,10,25,50,100,250,500,1000\text{.}\)
Solution.
The Fourier Series of this function is
\begin{equation*} f(x) = \frac{\pi}{2} + \sum_{n=1}^{\infty} \frac{2}{\pi n^2} (1-(-1)^n) \cos nx \end{equation*}
or \(a_0 = \pi/2\) and \(a_n = (2/\pi n^2)(1-(-1)^n) \)
\begin{align*} E^{\star} \amp = \int_{-\pi}^{\pi} f^2 \, dx - 2A_0\pi - \pi \sum_{n=1}^{N} (A_n^2 + B_n^2) \\ \amp = 2\int_{0}^{\pi} (\pi-x)^2 \, dx - 2\biggl(\frac{\pi}{2}\biggr) - \pi \sum_{n=1}^{N}\biggl(\frac{2}{\pi n^2} (1-(-1)^n) \biggr) \end{align*}
Table 6.4.10.
\(n\) \(E^{\star}\)
5 0.00372
10 0.000832
25 0.0000482
50 \(6.78 \times 10^{-6} \)
100 \(8.49 \times 10^{-8} \)
250 \(5.43 \times 10^{-8} \)
500 \(6.79 \times 10^{-9} \)
1000 \(8.48 \times 10^{-10} \)
A consequence of Parseval’s Theorem is that for piecewise continuous functions, the Fourier Series converges as \(n \rightarrow \infty\text{.}\) So in light of the plot in Example ExampleΒ 6.4.4, that it would appear that the plot of \(f_N\) would approach the square wave as \(N \rightarrow \infty\text{.}\) However the plots of \(f_{25}\) and \(f_{100}\) are shown below (with \(n=25\) on top):
Figure 6.4.11. A square wave?????
Figure 6.4.12. The Trigonmetric Polynomials of degree \(N=25\) of the square wave function from above.
And despite the larger value of \(N\text{,}\) \(f_N\) does not appear to be approaching the square wave function. The difference is pronounced near the discontinuities in the function. This is called \emph{Gibbs Phenomena} and it can be shown in this situation that the local max near \(x=0\) in fact grows without bound as \(N \rightarrow \infty\text{,}\) despite the fact that \(||f_N-f|| \rightarrow 0\text{.}\)

Subsection 6.4.2 Why is finite Fourier Series called a Polynomial?

You may be scratching your head about why the sum of sines and cosines is called a polynomial. You do recall correctly that polynomials are generally of the form
\begin{equation*} p(x) = \sum_{i=0}^n a_n x^n \end{equation*}
that is a linear combination of powers of \(x\text{.}\)
However, you may also recall some trigonmetric identities. For example,
\begin{align*} \sin 2x \amp = 2 \sin x \cos x\\ \cos 2x \amp = 1- 2 \sin^2 x \end{align*}
And a more complicated set of identities lead to
\begin{align*} \sin 3x \amp = 3 \sin x - 4 \sin^3 x \\ \cos 3x \amp = 4 \cos^3 x - 3 \cos x \end{align*}
Note that in these examples, functions of the form \(\sin kx\) and \(\cos kx\) can be written in terms (for \(k=2,3\)) of products and powers of \(\sin x\) and \(\cos x\text{.}\) This continues for larger values of \(k\) as well.
If you continue with similar identities, you can show that the trigonometric polynomial of the form
\begin{equation*} a_0 + \sum_{n=1}^N (a_n \cos nx + b_n \sin nx) \end{equation*}
Can be written as the powers of \(\sin x\) and \(\cos x\text{.}\) This explains why this is called a polynomial.