Skip to main content
Mathematics LibreTexts

3.4: Sine and Cosine Series

  • Page ID
    90254
  • \( \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}}\)

    In the last two examples \((f(x)=|x|\) and \(f(x)=x\) on \([-\pi, \pi]\) ) we have seen Fourier series representations that contain only sine or cosine terms. As we know, the sine functions are odd functions and thus sum to odd functions. Similarly, cosine functions sum to even functions. Such occurrences happen often in practice. Fourier representations involving just sines are called sine series and those involving just cosines (and the constant term) are called cosine series.

    Another interesting result, based upon these examples, is that the original functions, \(|x|\) and \(x\) agree on the interval \([0, \pi]\). Note from Figures 3.3.4-3.3.6 that their Fourier series representations do as well. Thus, more than one series can be used to represent functions defined on finite intervals. All they need to do is to agree with the function over that particular interval. Sometimes one of these series is more useful because it has additional properties needed in the given application.

    We have made the following observations from the previous examples:

    1. There are several trigonometric series representations for a function defined on a finite interval.
    2. Odd functions on a symmetric interval are represented by sine series and even functions on a symmetric interval are represented by cosine series.

    These two observations are related and are the subject of this section. We begin by defining a function \(f(x)\) on interval \([0, L]\). We have seen that the Fourier series representation of this function appears to converge to a periodic extension of the function.

    In Figure \(\PageIndex{1}\) we show a function defined on \([0,1]\). To the right is its periodic extension to the whole real axis. This representation has a period of \(L=1\). The bottom left plot is obtained by first reflecting \(f\) about the \(y\) axis to make it an even function and then graphing the periodic extension of this new function. Its period will be \(2 L=2\). Finally, in the last plot we flip the function about each axis and graph the periodic extension of the new odd function. It will also have a period of \(2 L=2\).

    clipboard_e7378150fb68977efe020531c9597cd3a.png
    Figure \(\PageIndex{1}\): This is a sketch of a function and its various extensions. The original function \(f(x)\) is defined on \([0, 1]\) and graphed in the upper left corner. To its right is the periodic extension, obtained by adding replicas. The two lower plots are obtained by first making the original function even or odd and then creating the periodic extensions of the new function.

    In general, we obtain three different periodic representations. In order to distinguish these we will refer to them simply as the periodic, even and odd extensions. Now, starting with \(f(x)\) defined on \([0, L]\), we would like to determine the Fourier series representations leading to these extensions. [For easy reference, the results are summarized in Table \(\PageIndex{1}\)]

    We have already seen from Table 3.3.1 that the periodic extension of \(f(x)\), defined on \([0,L]\), is obtained through the Fourier series representation \[f(x)\sim\frac{a_0}{2}+\sum\limits_{n=1}^\infty\left[a_n\cos\frac{2n\pi x}{L}+b_n\sin\frac{2n\pi x}{L}\right],\label{eq:1}\] where \[\begin{align} &a_{n}=\frac{2}{L} \int_{0}^{L} f(x) \cos \frac{2 n \pi x}{L} d x . \quad n=0,1,2, \ldots,\nonumber \\ &b_{n}=\frac{2}{L} \int_{0}^{L} f(x) \sin \frac{2 n \pi x}{L} d x . \quad n=1,2, \ldots\label{eq:2} \end{align}\]

    Given \(f(x)\) defined on \([0, L]\), the even periodic extension is obtained by simply computing the Fourier series representation for the even function \[f_{e}(x) \equiv\left\{\begin{array}{cc} f(x), & 0<x<L, \\ f(-x) & -L<x<0 .\label{eq:3} \end{array}\right.\]

    Since \(f_{e}(x)\) is an even function on a symmetric interval \([-L, L]\), we expect that the resulting Fourier series will not contain sine terms. Therefore, the series expansion will be given by [Use the general case in (3.3.29) with \(a=-L\) and \(b=L .]\) : \[f_{e}(x) \sim \frac{a_{0}}{2}+\sum_{n=1}^{\infty} a_{n} \cos \frac{n \pi x}{L} .\label{eq:4}\] with Fourier coefficients \[a_{n}=\frac{1}{L} \int_{-L}^{L} f_{e}(x) \cos \frac{n \pi x}{L} d x . \quad n=0,1,2, \ldots .\label{eq:5}\]

    However, we can simplify this by noting that the integrand is even and the interval of integration can be replaced by \([0, L]\). On this interval \(f_{e}(x)=\) \(f(x)\). So, we have the Cosine Series Representation of \(f(x)\) for \(x \in[0, L]\) is given as \[f(x) \sim \frac{a_{0}}{2}+\sum_{n=1}^{\infty} a_{n} \cos \frac{n \pi x}{L} .\label{eq:6} \] where \[a_{n}=\frac{2}{L} \int_{0}^{L} f(x) \cos \frac{n \pi x}{L} d x . \quad n=0,1,2, \ldots\label{eq:7} \]

    Table \(\PageIndex{1}\): Fourier Cosine and Sine Series Representations on \([0,L]\)
    Fourier Series on \([0,L]\)
    \[f(x) \sim \frac{a_{0}}{2}+\sum_{n=1}^{\infty}\left[a_{n} \cos \frac{2 n \pi x}{L}+b_{n} \sin \frac{2 n \pi x}{L}\right]\label{eq:8}\]
    \[\begin{align} &a_{n}=\frac{2}{L} \int_{0}^{L} f(x) \cos \frac{2 n \pi x}{L} d x . \quad n=0,1,2, \ldots,\nonumber \\ &b_{n}=\frac{2}{L} \int_{0}^{L} f(x) \sin \frac{2 n \pi x}{L} d x . \quad n=1,2, \ldots\label{eq:9} \end{align}\]
    Fourier Cosine Series on \([0,L]\)
    \[f(x) \sim a_{0} / 2+\sum_{n=1}^{\infty} a_{n} \cos \frac{n \pi x}{L} .\label{eq:10}\]
    where
    \[a_{n}=\frac{2}{L} \int_{0}^{L} f(x) \cos \frac{n \pi x}{L} d x . \quad n=0,1,2, \ldots\label{eq:11}\]
    Fourier Sine Series on \([0,L]\)
    \[f(x) \sim \sum_{n=1}^{\infty} b_{n} \sin \frac{n \pi x}{L}\label{eq:12}\]
    where
    \[b_{n}=\frac{2}{L} \int_{0}^{L} f(x) \sin \frac{n \pi x}{L} d x . \quad n=1,2, \ldots\label{eq:13}\]

    Similarly, given \(f(x)\) defined on \([0, L]\), the odd periodic extension is obtained by simply computing the Fourier series representation for the odd function \[f_{o}(x) \equiv\left\{\begin{array}{cc} f(x), & 0<x<L, \\ -f(-x) & -L<x<0 . \end{array}\right.\label{eq:14}\]

    The resulting series expansion leads to defining the Sine Series Representation of \(f(x)\) for \(x \in[0, L]\) as \[f(x) \sim \sum_{n=1}^{\infty} b_{n} \sin \frac{n \pi x}{L} .\label{eq:15}\] where \[b_{n}=\frac{2}{L} \int_{0}^{L} f(x) \sin \frac{n \pi x}{L} d x . \quad n=1,2, \ldots .\label{eq:16}\]

    Example \(\PageIndex{1}\)

    In Figure \(\PageIndex{1}\) we actually provided plots of the various extensions of the function \(f(x)=x^{2}\) for \(x \in[0,1]\). Let’s determine the representations of the periodic, even and odd extensions of this function.

    For a change, we will use a CAS (Computer Algebra System) package to do the integrals. In this case we can use Maple. A general code for doing this for the periodic extension is shown in Table \(\PageIndex{2}\).

    Example \(\PageIndex{2}\): Periodic Extension - Trigonometric Fourier Series

    Using the code in Table \(\PageIndex{2}\), we have that \(a_{0}=\frac{2}{3}, a_{n}=\frac{1}{n^{2} \pi^{2}}\), and \(b_{n}=-\frac{1}{n \pi}\). Thus, the resulting series is given as \[f(x) \sim \frac{1}{3}+\sum_{n=1}^{\infty}\left[\frac{1}{n^{2} \pi^{2}} \cos 2 n \pi x-\frac{1}{n \pi} \sin 2 n \pi x\right] .\nonumber \]

    In Figure \(\PageIndex{2}\) we see the sum of the first 50 terms of this series. Generally, we see that the series seems to be converging to the periodic extension of \(f\). There appear to be some problems with the convergence around integer values of \(x\). We will later see that this is because of the discontinuities in the periodic extension and the resulting overshoot is referred to as the Gibbs phenomenon which is discussed in the last section of this chapter.

    clipboard_e1c0117d2424cfb15153888e127ac6d7a.png
    Figure \(\PageIndex{2}\): The periodic extension of \(f(x)=x^{2}\) on \([0,1]\).
    Table \(\PageIndex{2}\): Maple code for computing Fourier coefficients and plotting partial sums of the Fourier series.
    > restart:
    > L:=1:
    > f:=x^2:
    > assume(n,integer):
    >a0:=2/L*int(f,x=0..L);
                                  a0 := 2/3
    > an:=2/L*int(f*cos(2*n*Pi*x/L),x=0..L);
                                         1
                                an := --------  
                                       2    2
    > bn:=2/L*int(f*sin(2*n*Pi*x/L),x=0..L);
                                         1  
                                bn := --------  
                                       n- Pi      
    > F:=a0/2+sum((1/(k*Pi)^2)*cos(2*k*Pi*x/L)
         -1/(k*Pi)*sin(2*k*Pi*x/L),k=1..50):
    > plot(F,x=-1..3,title=‘Periodic Extension‘,
          titlefont=[TIMES,ROMAN,14],font=[TIMES,ROMAN,14]);                                                                                                                         
    

    Example \(\PageIndex{3}\): Even Periodic Extension - Cosine Series

    In this case we compute \(a_{0}=\frac{2}{3}\) and \(a_{n}=\frac{4(-1)^{n}}{n^{2} \pi^{2}}\). Therefore, we have \[f(x) \sim \frac{1}{3}+\frac{4}{\pi^{2}} \sum_{n=1}^{\infty} \frac{(-1)^{n}}{n^{2}} \cos n \pi x\nonumber \]

    In Figure \(\PageIndex{3}\) we see the sum of the first 50 terms of this series. In this case the convergence seems to be much better than in the periodic extension case. We also see that it is converging to the even extension.

    clipboard_e63aca95b4b820c0b2b4106c73321a11c.png
    Figure \(\PageIndex{3}\): The even periodic extension of \(f(x)=x^2\) on \([0,1]\)

    Example \(\PageIndex{4}\): Odd Periodic Extension - Sine Series

    Finally, we look at the sine series for this function. We find that \[b_{n}=-\frac{2}{n^{3} \pi^{3}}\left(n^{2} \pi^{2}(-1)^{n}-2(-1)^{n}+2\right) \text {. }\nonumber \]

    Therefore, \[f(x) \sim-\frac{2}{\pi^{3}} \sum_{n=1}^{\infty} \frac{1}{n^{3}}\left(n^{2} \pi^{2}(-1)^{n}-2(-1)^{n}+2\right) \sin n \pi x .\nonumber \]

    Once again we see discontinuities in the extension as seen in Figure \(\PageIndex{4}\). However, we have verified that our sine series appears to be converging to the odd extension as we first sketched in Figure \(\PageIndex{1}\).

    clipboard_e014ffeac1b6ccc6f8c92a7204867b51d.png
    Figure \(\PageIndex{4}\): The odd periodic extension of \(f(x)=x^{2}\) on \([0,1]\)

    This page titled 3.4: Sine and Cosine Series is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Russell Herman via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.