Skip to main content
Mathematics LibreTexts

7.5: An Application to Fourier Approximation

  • Page ID
    134856
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    If \(U\) is an orthogonal basis of a vector space \(V\), the expansion theorem (Theorem [thm:030904]) presents a vector \(v \in V\) as a linear combination of the vectors in \(U\). Of course this requires that the set \(U\) is finite since otherwise the linear combination is an infinite sum and makes no sense in \(V\).

    However, given an infinite orthogonal set \(U = \{ \mathbf{f}_1, \mathbf{f}_2, \dots, \mathbf{f}_n, \dots \}\), we can use the expansion theorem for \(\{ \mathbf{f}_1, \mathbf{f}_2, \dots, \mathbf{f}_n\}\) for each \(n\) to get a series of “approximations” \(\mathbf{v}_n\) for a given vector \(\mathbf{v}\). A natural question is whether these \(\mathbf{v}_n\) are getting closer and closer to \(\mathbf{v}\) as \(n\) increases. This turns out to be a very fruitful idea.

    In this section we shall investigate an important orthogonal set in the space \(\mathbf{C}[-\pi, \pi]\) of continuous functions on the interval \([-\pi, \pi]\), using the inner product.

    \[\langle f, g \rangle = \int_{-\pi}^{\pi} f(x)g(x)dx \nonumber \]

    Of course, calculus will be needed. The orthogonal set in question is

    \[\{1, \sin x, \cos x, \sin(2x), \cos(2x), \sin(3x), \cos(3x), \dots \} \nonumber \]

    Standard techniques of integration give

    \[\begin{aligned} \| 1 \|^2 &= \int_{-\pi}^{\pi} 1^2 dx = 2\pi \\ \| \sin\ kx \| ^2 &= \int_{-\pi}^{\pi} \sin^2(kx) dx = \pi \quad \mbox{ for any } k = 1, 2, 3, \dots \\ \| \cos\ kx \| ^2 &= \int_{-\pi}^{\pi} \cos^2(kx) dx = \pi \quad \mbox{ for any } k = 1, 2, 3, \dots\end{aligned} \nonumber \]

    We leave the verifications to the reader, together with the task of showing that these functions are orthogonal:

    \[\langle \sin(kx), \sin(mx) \rangle = 0 = \langle \cos(kx), \cos(mx) \rangle \quad \mbox{ if } k \neq m \nonumber \]

    and

    \[\langle \sin(kx), \cos(mx) \rangle = 0 \quad \mbox{ for all } k \geq 0 \mbox{ and } m \geq 0 \nonumber \]

    (Note that \(1 = \cos(0x)\), so the constant function \(1\) is included.)

    Now define the following subspace of \(\mathbf{C}[-\pi, \pi]\):

    \[F_n = span \;\{1, \sin x, \cos x, \sin(2x), \cos(2x), \dots, \sin(nx), \cos(nx) \} \nonumber \]

    The aim is to use the approximation theorem (Theorem [thm:031150]); so, given a function \(f\) in \(\mathbf{C}[-\pi, \pi]\), define the Fourier coefficients of \(f\) by

    \[\begin{aligned} a_0 &= \frac{\langle f(x), 1 \rangle}{\| 1 \| ^2} = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x)dx \\ a_k &= \frac{\langle f(x), \cos(kx) \rangle}{\| \cos(kx) \| ^2} = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\cos(kx)dx\quad k = 1, 2, \dots \\ b_k &= \frac{\langle f(x), \sin(kx) \rangle}{\| \sin(kx) \| ^2} = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\sin(kx)dx\quad k = 1, 2, \dots\end{aligned} \nonumber \]

    Then the approximation theorem (Theorem [thm:031150]) gives Theorem [thm:032777].

    032777 Let \(f\) be any continuous real-valued function defined on the interval \([-\pi, \pi]\). If \(a_{0}\), \(a_{1}\), \(\dots\), and \(b_{0}\), \(b_{1}\), \(\dots\) are the Fourier coefficients of \(f\), then given \(n \geq 0\),

    \[f_n(x) = a_0 + a_1 \cos x + b_1 \sin x + a_2 \cos(2x) + b_2 \sin(2x) + \dots + a_n \cos(nx) + b_n \sin(nx) \nonumber \]

    is a function in \(F_{n}\) that is closest to \(f\) in the sense that

    \[\| f - f_n \| \leq \| f - g \| \nonumber \]

    holds for all functions \(g\) in \(F_{n}\).

    The function \(f_{n}\) is called the \(n\)th Fourier approximation to the function \(f\).

    032790 Find the fifth Fourier approximation to the function \(f(x)\) defined on \([-\pi, \pi]\) as follows:

    \[f(x) = \left\{ \begin{array}{ll} \pi + x & \mbox{if } -\pi \leq x < 0 \\ \pi - x & \mbox{if } 0 \leq x \leq \pi \\ \end{array} \right. \nonumber \]

    The graph of \(y = f(x)\) appears in the top diagram. The Fourier coefficients are computed as follows. The details of the integrations (usually by parts) are omitted.

    \[\begin{aligned} a_0 &= \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x)dx = \frac{\pi}{2} \\ %row 2 a_k &= \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\cos(kx)dx = \frac{2}{\pi k^2}[1 - \cos(k\pi)] = \left\{ \begin{array}{ll} 0 & \mbox{if } k \mbox{ is even} \\ \frac{4}{\pi k^2} & \mbox{if } k \mbox{ is odd} \\ \end{array} \right. \\ %row 3 b_k &= \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\sin(kx)dx = 0 \quad \mbox{ for all } k = 1, 2, \dots\end{aligned} \nonumber \]

    Hence the fifth Fourier approximation is

    \[f_5(x) = \frac{\pi}{2} + \frac{4}{\pi}\left\{\cos x + \frac{1}{3^2} \cos(3x) + \frac{1}{5^2} \cos(5x) \right\} \nonumber \]

    This is plotted in the middle diagram and is already a reasonable approximation to \(f(x)\). By comparison, \(f_{13}(x)\) is also plotted in the bottom diagram.

    We say that a function \(f\) is an even function if \(f(x) = f(-x)\) holds for all \(x\); \(f\) is called an odd function if \(f(-x) = -f(x)\) holds for all \(x\). Examples of even functions are constant functions, the even powers \(x^{2}\), \(x^{4}\), \(\dots\), and \(\cos(kx)\); these functions are characterized by the fact that the graph of \(y = f(x)\) is symmetric about the \(y\) axis. Examples of odd functions are the odd powers \(x\), \(x^{3}\), \(\dots\), and \(\sin(kx)\) where \(k > 0\), and the graph of \(y = f(x)\) is symmetric about the origin if \(f\) is odd. The usefulness of these functions stems from the fact that

    \[\begin{array}{ll} \int_{-\pi}^{\pi} f(x)dx = 0 & \mbox{if } f \mbox{ is odd} \\ \int_{-\pi}^{\pi} f(x)dx = 2 \int_{0}^{\pi} f(x)dx & \mbox{if } f \mbox{ is even} \end{array} \nonumber \]

    These facts often simplify the computations of the Fourier coefficients. For example:

    1. The Fourier sine coefficients \(b_{k}\) all vanish if \(f\) is even.
    2. The Fourier cosine coefficients \(a_{k}\) all vanish if \(f\) is odd.

    This is because \(f(x) \sin(kx)\) is odd in the first case and \(f(x) \cos(kx)\) is odd in the second case.

    The functions \(1\), \(\cos(kx)\), and \(\sin(kx)\) that occur in the Fourier approximation for \(f(x)\) are all easy to generate as an electrical voltage (when \(x\) is time). By summing these signals (with the amplitudes given by the Fourier coefficients), it is possible to produce an electrical signal with (the approximation to) \(f(x)\) as the voltage. Hence these Fourier approximations play a fundamental role in electronics.

    Finally, the Fourier approximations \(f_{1}, f_{2}, \dots\) of a function \(f\) get better and better as \(n\) increases. The reason is that the subspaces \(F_{n}\) increase:

    \[F_1 \subseteq F_2 \subseteq F_3 \subseteq \cdots \subseteq F_n \subseteq \cdots \nonumber \]

    So, because \(f_n = \proj{F_n}{f}\), we get (see the discussion following Example [exa:031164])

    \[\| f - f_1 \| \geq \| f - f_2 \| \geq \cdots \geq \| f - f_n \| \geq \cdots \nonumber \]

    These numbers \(\| f - f_{n} \|\) approach zero; in fact, we have the following fundamental theorem.

    032829 Let \(f\) be any continuous function in \(C[-\pi, \pi]\). Then

    \[f_n(x) \mbox{ approaches } f(x) \mbox{ for all } x \mbox{ such that } -\pi < x < \pi. \footnotemark \nonumber \]

    It shows that \(f\) has a representation as an infinite series, called the Fourier series of \(f\):

    \[f(x) = a_0 + a_1 \cos x + b_1 \sin x + a_2 \cos(2x) + b_2 \sin(2x) + \cdots \nonumber \]

    whenever \(-\pi < x < \pi\). A full discussion of Theorem [thm:032829] is beyond the scope of this book. This subject had great historical impact on the development of mathematics, and has become one of the standard tools in science and engineering.

    Thus the Fourier series for the function \(f\) in Example [exa:032790] is

    \[f(x) = \frac{\pi}{2} + \frac{4}{\pi}\left\{\cos x + \frac{1}{3^2} \cos(3x) + \frac{1}{5^2} \cos(5x) + \frac{1}{7^2} \cos(7x) + \cdots \right\} \nonumber \]

    Since \(f(0) = \pi\) and \(\cos(0) = 1\), taking \(x = 0\) leads to the series

    \[\frac{\pi^2}{8} = 1 + \frac{1}{3^2} + \frac{1}{5^2} + \frac{1}{7^2} + \cdots \nonumber \]

    032840 Expand \(f(x) = x\) on the interval \([-\pi, \pi]\) in a Fourier series, and so obtain a series expansion of \(\frac{\pi}{4}\).

    Here \(f\) is an odd function so all the Fourier cosine coefficients \(a_{k}\) are zero. As to the sine coefficients:

    \[b_k = \frac{1}{\pi} \int_{-\pi}^{\pi} x \sin(kx)dx = \frac{2}{k}(-1)^{k + 1} \quad \mbox{ for } k \geq 1 \nonumber \]

    where we omit the details of the integration by parts. Hence the Fourier series for \(x\) is

    \[x = 2[\sin x - \frac{1}{2} \sin(2x) + \frac{1}{3} \sin(3x) - \frac{1}{4} \sin(4x) + \dots] \nonumber \]

    for \(-\pi < x < \pi\). In particular, taking \(x = \frac{\pi}{2}\) gives an infinite series for \(\frac{\pi}{4}\).

    \[\frac{\pi}{4} = 1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - \cdots \nonumber \]

    Many other such formulas can be proved using Theorem [thm:032829].


    1. The name honours the French mathematician J.B.J. Fourier (1768-1830) who used these techniques in 1822 to investigate heat conduction in solids.↩

    This page titled 7.5: An Application to Fourier Approximation is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by W. Keith Nicholson (Lyryx Learning Inc.) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.