<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="m10687">
  <name>Fourier Series Approximation of Signals</name>
  <metadata>
  <md:version>2.8</md:version>
  <md:created>2002/06/26</md:created>
  <md:revised>2007/05/10 15:45:44.959 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="dhj">
      <md:firstname>Don</md:firstname>
      
      <md:surname>Johnson</md:surname>
      <md:email>dhj@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="dhj">
      <md:firstname>Don</md:firstname>
      
      <md:surname>Johnson</md:surname>
      <md:email>dhj@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  

  <md:abstract>(Blank Abstract)</md:abstract>
</metadata>

  <content>
    <para id="para1">
      It is interesting to consider the sequence of signals that we
      obtain as we incorporate more terms into the <cnxn document="m0039" target="ex1" strength="8">Fourier series
      approximation of the half-wave rectified sine wave</cnxn>.
      Define
      <m:math>
	<m:apply>
	  <m:ci type="fn">
	    <m:msub>
	      <m:mi>s</m:mi>
	      <m:mi>K</m:mi>
	    </m:msub>
	  </m:ci>
	  <m:ci>t</m:ci>
	</m:apply>
      </m:math>
      to be the signal containing 
      <m:math>
	<m:apply><m:plus/><m:ci>K</m:ci><m:cn>1</m:cn></m:apply>
      </m:math> 
      Fourier terms.

      <equation id="eqn1white">
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:ci type="fn">
		<m:msub>
		  <m:mi>s</m:mi>
		  <m:mi>K</m:mi>
		</m:msub>
	      </m:ci>
	      <m:ci>t</m:ci>
	    </m:apply>
	    <m:apply>
	      <m:plus/>
	      <m:ci>
		<m:msub>
		  <m:mi>a</m:mi>
		  <m:mn>0</m:mn>
		</m:msub>
	      </m:ci>
	      <m:apply>
		<m:sum/>
		<m:bvar>
		  <m:ci>k</m:ci>
		</m:bvar>
		<m:lowlimit>
		  <m:cn>1</m:cn>
		</m:lowlimit>
		<m:uplimit>
		  <m:ci>K</m:ci>
		</m:uplimit>
		<m:apply>
		  <m:times/>
		  <m:ci>
		    <m:msub>
		      <m:mi>a</m:mi>
		      <m:mi>k</m:mi>
		    </m:msub>
		  </m:ci>
		  <m:apply>
		    <m:cos/>
		    <m:apply>
		      <m:divide/>
		      <m:apply>
			<m:times/>
			<m:cn>2</m:cn>
			<m:pi/>
			<m:ci>k</m:ci>
			<m:ci>t</m:ci>
		      </m:apply>
		      <m:ci>T</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:sum/>
		<m:bvar>
		  <m:ci>k</m:ci>
		</m:bvar>
		<m:lowlimit>
		  <m:cn>1</m:cn>
		</m:lowlimit>
		<m:uplimit>
		  <m:ci>K</m:ci>
		</m:uplimit>
		<m:apply>
		  <m:times/>
		  <m:ci>
		    <m:msub>
		      <m:mi>b</m:mi>
		      <m:mi>k</m:mi>
		    </m:msub>
		  </m:ci>
		  <m:apply>
		    <m:sin/>
		    <m:apply>
		      <m:divide/>
		      <m:apply>
			<m:times/>
			<m:cn>2</m:cn>
			<m:pi/>
			<m:ci>k</m:ci>
			<m:ci>t</m:ci>
		      </m:apply>
		      <m:ci>T</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:apply>
	</m:math>
      </equation>

      <cnxn target="fouriermeteo" strength="9"/> shows how this
      sequence of signals portrays the signal more accurately
      as more terms are added.
    </para>

    <figure id="fouriermeteo" orient="vertical">
      <name>	
	Fourier Series spectrum of a half-wave rectified sine wave
      </name>      
      <subfigure>
	<media type="image/png" src="spectrum2.png"/>
      </subfigure>
      <subfigure>
	<media type="image/png" src="fourier1.png"/>
      </subfigure>
      <caption>	
	The Fourier series spectrum of a half-wave rectified sinusoid
	is shown in the upper portion. The index indicates the
	multiple of the fundamental frequency at which the signal has
	energy.  The cumulative effect of adding terms to the Fourier
	series for the half-wave rectified sine wave is shown in the
	bottom portion.  The dashed line is the actual signal, with
	the solid line showing the finite series approximation to the
	indicated number of terms,
	<m:math>
	  <m:apply><m:plus/><m:ci>K</m:ci><m:cn>1</m:cn></m:apply>
	</m:math>.
      </caption>
    </figure>


    <para id="para2white">      
      We need to assess quantitatively the accuracy of the  
      Fourier series approximation so that we can judge how rapidly
      the series approaches the signal. When we use a      
      <m:math>
	<m:apply><m:plus/>
	  <m:ci>K</m:ci>
	  <m:cn>1</m:cn>
	</m:apply>
      </m:math>-term series, the error—the difference between
      the signal and the
      <m:math>
	<m:apply><m:plus/>
	  <m:ci>K</m:ci>
	  <m:cn>1</m:cn>
	</m:apply>
      </m:math>-term series—corresponds to the unused terms from
      the series.

      <equation id="eqn2white">
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:ci type="fn">
		<m:msub>
		  <m:mi>ε</m:mi>
		  <m:mi>K</m:mi>
		</m:msub>
	      </m:ci>
	      <m:ci>t</m:ci>
	    </m:apply>
	    <m:apply>
	      <m:plus/>
	      <m:apply>
		<m:sum/>
		<m:bvar>
		  <m:ci>k</m:ci>
		</m:bvar>
		<m:lowlimit>
		  <m:apply>
		    <m:plus/>
		    <m:ci>K</m:ci>
		    <m:cn>1</m:cn>
		  </m:apply>
		</m:lowlimit>
		<m:uplimit>
		  <m:infinity/>
		</m:uplimit>
		<m:apply>
		  <m:times/>
		  <m:apply>
		    <m:ci>
		      <m:msub>
			<m:mi>a</m:mi>
			<m:mi>k</m:mi>
		      </m:msub>
		    </m:ci>
		  </m:apply>
		  <m:apply>
		    <m:cos/>
		    <m:apply>
		      <m:divide/>
		      <m:apply>
			<m:times/>
			<m:cn>2</m:cn>
			<m:pi/>
			<m:ci>k</m:ci>
			<m:ci>t</m:ci>
		      </m:apply>
		      <m:ci>T</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:sum/>
		<m:bvar>
		  <m:ci>k</m:ci>
		</m:bvar>
		<m:lowlimit>
		  <m:apply>
		    <m:plus/>
		    <m:ci>K</m:ci>
		    <m:cn>1</m:cn>
		  </m:apply>
		</m:lowlimit>
		<m:uplimit>
		  <m:infinity/>
		</m:uplimit>
		<m:apply>
		  <m:times/>
		  <m:ci>
		    <m:msub>
		      <m:mi>b</m:mi>
		      <m:mi>k</m:mi>
		    </m:msub>
		  </m:ci>
		  <m:apply>
		    <m:sin/>
		    <m:apply>
		      <m:divide/>
		      <m:apply>
			<m:times/>
			<m:cn>2</m:cn>
			<m:pi/>
			<m:ci>k</m:ci>
			<m:ci>t</m:ci>
		      </m:apply>
		      <m:ci>T</m:ci>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:apply>
	</m:math>
      </equation>

      To find the rms error, we must square this expression and
      integrate it over a period. Again, the integral of most
      cross-terms is zero, leaving
      
      <equation id="eqn3white">
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:ci type="fn">rms</m:ci>
	      <m:ci>
		<m:msub>
		  <m:mi>ε</m:mi>
		  <m:mi>K</m:mi>
		</m:msub>
	      </m:ci>
	    </m:apply>
	    <m:apply>
	      <m:root/>
	      <m:degree>
		<m:cn>2</m:cn>
	      </m:degree>
	      <m:apply>
		<m:times/>
		<m:apply>
		<m:divide/>
		  <m:cn>1</m:cn>
		  <m:cn>2</m:cn>
		</m:apply>
		<m:apply>
		  <m:sum/>
		  <m:bvar>
		    <m:ci>k</m:ci>
		  </m:bvar>
		  <m:lowlimit>
		    <m:apply><m:plus/>
		      <m:ci>K</m:ci>
		      <m:cn>1</m:cn>
		    </m:apply>
		  </m:lowlimit>
		  <m:uplimit>
		    <m:infinity/>
		  </m:uplimit>
		  <m:apply>
		    <m:plus/>
		    <m:apply>
		      <m:power/>
		      <m:ci>
			<m:msub>
			  <m:mi>a</m:mi>
			  <m:mi>k</m:mi>
			</m:msub>
		      </m:ci>
		      <m:cn>2</m:cn>
		    </m:apply>
		    <m:apply>
		      <m:power/>
		      <m:ci>
			<m:msub>
			  <m:mi>b</m:mi>
			  <m:mi>k</m:mi>
			</m:msub>
		      </m:ci>
		      <m:cn>2</m:cn>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:apply>
	</m:math>
      </equation>
      
      <cnxn target="fig2" strength="8"/> shows how the error in the
      Fourier series for the half-wave rectified sinusoid decreases as
      more terms are incorporated. In particular, the use of four
      terms, as shown in the bottom plot of <cnxn target="fouriermeteo" strength="8"/>, has a rms error (relative
      to the rms value of the signal) of about 3%. The Fourier series
      in this case converges quickly to the signal.
    </para>

    <figure id="fig2">
      <name>Approximation error for a half-wave rectified sinusoid</name>
      <media type="image/png" src="fourier2.png"/>
      <caption>
	The rms error calculated according to 
	<cnxn target="eqn3white" strength="8"/> 
	is shown as a function of the number of terms in the
	series for the half-wave rectified sinusoid.
        The error has been normalized by the rms value of the
	signal.
      </caption>
    </figure>

    <para id="fssquare1">
      We can look at <cnxn target="fourpointfive" strength="9"/> to
      see the power spectrum and the rms approximation error for the
      square wave.

      <figure id="fourpointfive">
	<name>Power spectrum and approximation error for a square wave</name> 
	<media type="image/png" src="fourier5.png"/> 
	<caption>
	  The upper plot shows the power spectrum of the square wave,
	  and the lower plot the rms error of the finite-length
	  Fourier series approximation to the square wave. The
	  asterisk denotes the rms error when the number of terms
	  <m:math> 
	    <m:ci>K</m:ci>
	  </m:math>
	  in the Fourier series equals 99.
	</caption>
      </figure>

      Because the Fourier coefficients decay more slowly here than for
      the half-wave rectified sinusoid, the rms error is not
      decreasing quickly.  Said another way, the square-wave's
      spectrum contains more power at higher frequencies than does the
      half-wave-rectified sinusoid.  This difference between the two
      Fourier series results because the half-wave rectified
      sinusoid's Fourier coefficients are proportional to
	<m:math>
	  <m:apply>
	    <m:divide/>
	    <m:cn>1</m:cn>
	    <m:apply>
	      <m:power/>
	      <m:ci>k</m:ci>
	      <m:cn>2</m:cn>
	    </m:apply>
	  </m:apply>
	</m:math>
	while those of the square wave are proportional to
	<m:math>
	  <m:apply>
	    <m:divide/>
	    <m:cn>1</m:cn>
	    <m:ci>k</m:ci>
	  </m:apply>
	</m:math>.  If fact, after 99 terms of the square wave's
      approximation, the error is bigger than 10 terms of the
      approximation for the half-wave rectified sinusoid.
      Mathematicians have shown that no signal has an rms
      approximation error that decays more slowly than it does for the
      square wave.
    </para>

    <exercise id="exer1">
      <problem>
	<para id="problem_1">
	  Calculate the harmonic distortion for the square wave.
	</para>
      </problem>
      <solution>
	<para id="solutiontoproblem_1">
	  Total harmonic distortion in the square wave is
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:minus/>
		<m:cn>1</m:cn>
		<m:apply><m:times/>
                  <m:apply><m:divide/><m:cn>1</m:cn><m:cn>2</m:cn></m:apply>
		  <m:apply><m:power/>
		    <m:apply><m:divide/>
		      <m:cn>4</m:cn>
		      <m:pi/>
		    </m:apply>
		    <m:cn>2</m:cn>
		  </m:apply>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:times/>
		<m:cn>20</m:cn>
		<m:ci>%</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math>.
	</para>
      </solution>
    </exercise>

    <para id="fssquare3">
      More than just decaying slowly, Fourier series approximation
      shown in <cnxn target="fourpointfour" strength="9"/> exhibits
      interesting behavior.
 
      <figure id="fourpointfour">
	<name>Fourier series approximation of a square wave</name>
	<media type="image/png" src="fourier4.png"/>
	<caption>
	  Fourier series approximation to
	  <m:math>
	    <m:apply>
	      <m:ci type="fn">sq</m:ci>
	      <m:ci>t</m:ci>
	    </m:apply>
	  </m:math>.  
	  The number of terms in the Fourier sum is indicated in each
	  plot, and the square wave is shown as a dashed line over two
	  periods.
	</caption>
      </figure>

      Although the square wave's Fourier series requires more terms
      for a given representation accuracy, when comparing plots it is
      not clear that the two are equal.  Does the Fourier series
      really equal the square wave at <emphasis>all</emphasis> values
      of
      <m:math display="inline">
	<m:ci>t</m:ci> </m:math>?  In particular, at each step-change
      in the square wave, the Fourier series exhibits a peak followed
      by rapid oscillations. As more terms are added to the series,
      the oscillations seem to become more rapid and smaller, but the
      peaks are not decreasing.  For the <cnxn target="fouriermeteo" strength="9">Fourier series approximation for the half-wave
      rectified sinusoid</cnxn>, no such behavior occurs.  What is
      happening?
    </para>
    
    <para id="fssquare5">
      Consider this mathematical question intuitively: Can a
      discontinuous function, like the square wave, be expressed as a
      sum, even an infinite one, of continuous signals?  One should at
      least be suspicious, and in fact, it can't be thus
      expressed. This issue brought
      <link src="http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Fourier.html">Fourier</link> 

      much criticism from the French Academy of Science (Laplace,
      Lagrange, Monge and LaCroix comprised the review committee) for
      several years after its presentation on 1807.  It was not
      resolved for also a century, and its resolution is interesting
      and important to understand from a practical viewpoint.
    </para>


    <para id="fssquare6">
      The extraneous peaks in the square wave's Fourier series
      <emphasis>never</emphasis> disappear; they are termed
      <term>Gibb's phenomenon</term> after the American physicist
      Josiah Willard Gibbs. They occur whenever the signal is
      discontinuous, and will always be present whenever the signal
      has jumps.
    </para>
    
    <para id="fssquare7">
      Let's return to the question of equality; how can the
      equal sign in the 
      <cnxn target="sine" document="m0039" strength="6">definition of
	the Fourier series </cnxn> 

      be justified?  The partial answer is that
      <emphasis>pointwise</emphasis>—each and every value of
      <m:math>
	<m:ci>t</m:ci> 
      </m:math>—equality 
      is <emphasis>not</emphasis> guaranteed. However, mathematicians
      later in the nineteenth century showed that the rms error of
      the Fourier series was always zero.

	<m:math display="block">
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:limit/>
	      <m:bvar>
		<m:ci>K</m:ci>
	      </m:bvar>
	      <m:lowlimit>
		<m:infinity/>
	      </m:lowlimit>
	      <m:apply>
		<m:ci type="fn">rms</m:ci>
		<m:ci>
		  <m:msub>
		    <m:mi>ε</m:mi>
		    <m:mi>K</m:mi>
		  </m:msub>
		</m:ci>
	      </m:apply>
	    </m:apply>
	    <m:cn>0</m:cn>
	  </m:apply>
	</m:math>

      What this means is that the error between a signal and its
      Fourier series approximation may not be zero, but that its rms
      value will be zero!  It is through the eyes of the rms value
      that we redefine equality: The usual definition of equality is
      called <term>pointwise equality</term>: Two signals
      <m:math>
	<m:apply>
	  <m:ci type="fn">
	    <m:msub>
	      <m:mi>s</m:mi>
	      <m:mn>1</m:mn>
	    </m:msub>
	  </m:ci>
	  <m:ci>t</m:ci>
	</m:apply>
      </m:math>,

      <m:math>
	<m:apply>
	  <m:ci type="fn">
	    <m:msub>
	      <m:mi>s</m:mi>
	      <m:mn>2</m:mn>
	    </m:msub>
	  </m:ci>
	  <m:ci>t</m:ci>
	</m:apply>
      </m:math>
      are said to be equal pointwise if
      <m:math>
	<m:apply>
	  <m:eq/>
	  <m:apply>
	    <m:ci type="fn">
	      <m:msub>
		<m:mi>s</m:mi>
		<m:mn>1</m:mn>
	      </m:msub>
	    </m:ci>
	    <m:ci>t</m:ci>
	  </m:apply>
	  <m:apply>
	    <m:ci type="fn">
	      <m:msub>
		<m:mi>s</m:mi>
		<m:mn>2</m:mn>
	      </m:msub>
	    </m:ci>
	    <m:ci>t</m:ci>
	  </m:apply>
	</m:apply>
      </m:math>
      for all values of <m:math><m:ci>t</m:ci></m:math>.  A new
      definition of equality is <term>mean-square equality</term>: Two
      signals are said to be equal in the mean square if
      <m:math>
	<m:apply>
	  <m:eq/>
	  <m:apply>
	    <m:ci type="fn">rms</m:ci>
	    <m:apply>
	      <m:minus/>
	      <m:ci>
		<m:msub>
		  <m:mi>s</m:mi>
		  <m:mn>1</m:mn>
		</m:msub>
	      </m:ci>
	      <m:ci>
		<m:msub>
		  <m:mi>s</m:mi>
		  <m:mn>2</m:mn>
		</m:msub>
	      </m:ci>
	    </m:apply>
	  </m:apply>
	  <m:cn>0</m:cn>
	</m:apply>
      </m:math>.  For Fourier series, Gibb's phenomenon peaks have
      finite height and zero width. The error differs from zero only
      at isolated points—whenever the periodic signal contains
      discontinuities—and equals about 9% of the size of the
      discontinuity. The value of a function at a finite set of points
      does not affect its integral. This effect underlies the reason
      why defining the value of a discontinuous function, like we
      refrained from doing in defining the <cnxn document="m0004" target="stepdef" strength="5">step function</cnxn>, at its
      discontinuity is meaningless. Whatever you pick for a value has
      no practical relevance for either the signal's spectrum or for
      how a system responds to the signal.  The Fourier series value
      "at" the discontinuity is the average of the values on either
      side of the jump.
    </para>

  </content>
  
</document>
