<?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="m11541">
  <name>Convolution - Complete example</name>
  <metadata>
  <md:version>1.7</md:version>
  <md:created>2003/08/07 03:49:36 GMT-5</md:created>
  <md:revised>2007/06/26 04:58:26.927 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="Anders">
      <md:firstname>Anders</md:firstname>
      
      <md:surname>Gjendemsjø</md:surname>
      <md:email>gjendems@iet.ntnu.no</md:email>
    </md:author>
      <md:author id="richb">
      <md:firstname>Richard</md:firstname>
      <md:othername>G.</md:othername>
      <md:surname>Baraniuk</md:surname>
      <md:email>richb@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="Anders">
      <md:firstname>Anders</md:firstname>
      
      <md:surname>Gjendemsjø</md:surname>
      <md:email>gjendems@iet.ntnu.no</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>Complete</md:keyword>
    <md:keyword>Convolution</md:keyword>
    <md:keyword>example</md:keyword>
  </md:keywordlist>

  <md:abstract>Shows a full example of convolution including math and figures.</md:abstract>
</metadata>

  <content>
    <section id="s1">
      <name>Basic Example</name>
      <para id="s1p1">
	Let us look at a basic continuous-time convolution example to
	help express some of the important ideas.  We will convolve together two square pulses,
	<m:math><m:apply><m:ci>x</m:ci><m:ci>t</m:ci></m:apply></m:math> and
	<m:math><m:apply><m:ci>h</m:ci><m:ci>t</m:ci></m:apply></m:math>,
	as shown in <cnxn target="f1"/>
      </para>

      <figure orient="vertical" id="f1">
	<subfigure>
	  <media type="image/png" src="x_t.png"/>
	</subfigure>
	<subfigure>
	  <media type="image/png" src="h_t.png"/>
	</subfigure>
	<caption>
	  Two basic signals that we will convolve together.
	</caption>
      </figure>

      <section id="s1s1">
      	<name>Reflect and Shift</name>
      	<para id="s1s1p1">
      	  Now we will take one of the functions and reflect it around
      	  the y-axis.  Then we must shift the function, such that the
      	  origin, the point of the function that was originally on the
      	  origin, is labeled as point <m:math><m:ci>t</m:ci></m:math>.  This
	  step is shown in <cnxn target="f2"/>,
	  <m:math>
	    <m:apply>
	      <m:ci>h</m:ci>
	      <m:apply>
		<m:minus/>
		<m:ci>t</m:ci>
		<m:ci>τ</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math>. 
	  <figure orient="horizontal" id="f2">
	<subfigure>
	  <media type="image/png" src="h_-tau.png"/>
	  <caption>Reflected square pulse.</caption>
	</subfigure>
	<subfigure>
	  <media type="image/png" src="h_t-tau.png"/>
	  <caption>Reflected and <emphasis>shifted</emphasis> square pulse.</caption>
	</subfigure>
	<caption>
	    <m:math>
	    <m:apply>
	      <m:ci>h</m:ci>
	      <m:apply>
		<m:minus/>
		<m:ci>τ</m:ci>
		</m:apply>
	    </m:apply>
	  </m:math> and
	    <m:math>
	    <m:apply>
	      <m:ci>h</m:ci>
	      <m:apply>
		<m:minus/>
		<m:ci>t</m:ci>
		<m:ci>τ</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math>.
	  
	</caption>
      </figure>	  


	  Note that in <cnxn target="f2"/>  <m:math><m:ci>τ</m:ci></m:math>
	  is the 1st axis variable while <m:math><m:ci>t</m:ci></m:math> is
	  a constant (in this figure).

	  Since convolution is commutative it will never
	  matter which function is reflected and shifted; however, as
	  the functions become more complicated reflecting and shifting
	  the "right one" will often make the problem much easier.
	</para>
      </section>

      <section id="s1s2">
      	<name>Regions of Integration</name>
	<para id="s1s2p1">
	    We start out with the convolution integral,
	    <m:math display="inline">
	        <m:apply>
		    <m:eq/>
		    <m:apply>
		        <m:ci>y</m:ci>
			<m:ci>t</m:ci>
		    </m:apply>
		    <m:apply>
			<m:int/>
			<m:bvar><m:ci>τ</m:ci></m:bvar>
			<m:lowlimit><m:apply><m:minus/><m:infinity/></m:apply></m:lowlimit>
			<m:uplimit><m:infinity/></m:uplimit>
			<m:apply>
			    <m:times/>
			    <m:apply>
			        <m:ci>x</m:ci>
				<m:ci>τ</m:ci>
			    </m:apply>
			    <m:apply>
				<m:ci>h</m:ci>
				<m:apply>
				    <m:minus/>
				    <m:ci>t</m:ci>
				    <m:ci>τ</m:ci>
				</m:apply>
			    </m:apply>
		        </m:apply>
		    </m:apply>
		</m:apply>
	    </m:math>.
	    The value of the function <m:math><m:ci>y</m:ci></m:math>
	    at time <m:math><m:ci>t</m:ci></m:math> is given by
	    the amount of overlap(to be precise the integral of the
	    overlapping region) between
	    <m:math>
	      <m:apply>
      	          <m:ci>h</m:ci>
		  <m:apply>
		      <m:minus/><m:ci>t</m:ci>
		      <m:ci>τ</m:ci>
		  </m:apply>
	      </m:apply>
	  </m:math> and
	  <m:math>
	      <m:apply>
      	          <m:ci>x</m:ci>
		  <m:ci>τ</m:ci>
	      </m:apply>
	  </m:math>.

	     
	</para>

      	<para id="s1s2p2">
      	  Next, we want to look at the functions and divide the span
      	  of the functions into different limits of integration.
      	  These different regions can be understood by thinking about
      	  how we slide 
	  <m:math>
	      <m:apply>
      	          <m:ci>h</m:ci>
		  <m:apply>
		      <m:minus/><m:ci>t</m:ci>
		      <m:ci>τ</m:ci>
		  </m:apply>
	      </m:apply>
	  </m:math> over
	  <m:math>
	      <m:apply>
      	          <m:ci>x</m:ci>
		  <m:ci>τ</m:ci>
	      </m:apply>
	  </m:math>, see <cnxn target="f3"/>.
	  
	  <figure id="f3" orient="vertical"><subfigure>
	          <media type="image/png" src="convolve1.png"/>
		  <caption>
		     No overlap.
		  </caption>
	      </subfigure>
	      <subfigure>
	          <media type="image/png" src="convolve2.png"/>
		  <caption>
		      <m:math>
	      <m:apply>
      	          <m:ci>h</m:ci>
		  <m:apply>
		      <m:minus/><m:ci>t</m:ci>
		      <m:ci>τ</m:ci>
		  </m:apply>
	      </m:apply>
	  </m:math> on its way "into"
	  <m:math>
	      <m:apply>
      	          <m:ci>x</m:ci>
		  <m:ci>τ</m:ci>
	      </m:apply>
	  </m:math>
	  
		  
		  </caption>
	      </subfigure>
	      <subfigure>
	          <media type="image/png" src="convolve3.png"/>
		  <caption><m:math>
	      <m:apply>
      	          <m:ci>h</m:ci>
		  <m:apply>
		      <m:minus/><m:ci>t</m:ci>
		      <m:ci>τ</m:ci>
		  </m:apply>
	      </m:apply>
	  </m:math> on its way "out of"
	  <m:math>
	      <m:apply>
      	          <m:ci>x</m:ci>
		  <m:ci>τ</m:ci>
	      </m:apply>
	  </m:math>
	  </caption>
	      </subfigure>
	      <subfigure>
	          <media type="image/png" src="convolve4.png"/>
		  <caption>No overlap.</caption>
	      </subfigure>
	      <caption>Figures to help understand the regions of intergration</caption>
	  </figure>

	  In this case we will have the following four
	  regions.  Compare these limits of integration to the
	  four illustrations of <m:math>
	  <m:apply>
	      <m:ci>h</m:ci>
	      <m:apply><m:minus/><m:ci>t</m:ci>
		<m:ci>τ</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math> and <m:math>
	    <m:apply>
	      <m:ci>x</m:ci>
	      <m:ci>τ</m:ci>
	    </m:apply>
	  </m:math> in <cnxn target="f3"/>.

	  <list id="l1" type="enumerated">
	    <name>Four Limits of Integration</name>

	    <item>
	      <m:math>
		<m:apply>
		  <m:lt/>
		  <m:ci>t</m:ci>
		  <m:cn>0</m:cn>
		</m:apply>
	      </m:math>
	    </item>

	    <item>
	      <m:math>
		<m:apply>
		  <m:lt/>
		  <m:apply>
		    <m:leq/>
		    <m:cn>0</m:cn>
		    <m:ci>t</m:ci>
		  </m:apply>
		  <m:cn>1</m:cn>
		</m:apply>
	      </m:math>
	    </item>

	    <item>
	      <m:math>
		<m:apply>
		  <m:lt/>
		  <m:apply>
		    <m:leq/>
		    <m:cn>1</m:cn>
		    <m:ci>t</m:ci>
		  </m:apply>
		  <m:cn>2</m:cn>
		</m:apply>
	      </m:math>
	    </item>

	    <item>
	      <m:math>
		<m:apply>
		  <m:geq/>
		  <m:ci>t</m:ci>
		  <m:cn>2</m:cn>
		</m:apply>
	      </m:math>
	    </item>
	  </list>

	</para>
      </section>

	  <!--End new material-->

      <section id="s1s3">
	<name>Using the Convolution Integral</name>
	<para id="s1s3p1">

	  Finally we are ready for a little math.  Using the convolution
	  integral, let us integrate the product of
	  <m:math>
	    <m:apply>
	      <m:times/>
	      <m:apply>
		<m:ci>x</m:ci>
		<m:ci>τ</m:ci>
	      </m:apply>
	      <m:apply>
		<m:ci>h</m:ci>
		<m:apply>
		  <m:minus/>
		  <m:ci>t</m:ci>
		  <m:ci>τ</m:ci>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>.  For our first and fourth region this will be
	  trivial as it will always be <m:math><m:cn>0</m:cn></m:math>.
	  The second region,
	  <m:math>
	    <m:apply>
	      <m:lt/>
	      <m:apply>
		<m:leq/>
		<m:cn>0</m:cn>
		<m:ci>t</m:ci>
	      </m:apply>
	      <m:cn>1</m:cn>
	    </m:apply>
	  </m:math>, will require the following math:

	  <equation id="eqn1">
	    <m:math>
	      <m:apply>
		<m:eq/>
		<m:apply>
		  <m:ci>y</m:ci>
		  <m:ci>t</m:ci>
		</m:apply>
		<m:apply>
		  <m:int/>
		  <m:bvar>
		    <m:ci>τ</m:ci>
		  </m:bvar>
		  <m:lowlimit>
		    <m:cn>0</m:cn>
		  </m:lowlimit>
		  <m:uplimit>
		    <m:ci>t</m:ci>
		  </m:uplimit>
		  <m:apply>
		    <m:cn>1</m:cn>
		  </m:apply>
		</m:apply>
		<m:ci>t</m:ci>
	      </m:apply>
	    </m:math>
	  </equation>

	  The third region,
	  <m:math>
	    <m:apply>
	      <m:lt/>
	      <m:apply>
		<m:leq/>
		<m:cn>1</m:cn>
		<m:ci>t</m:ci>
	      </m:apply>
	      <m:cn>2</m:cn>
	    </m:apply>
	  </m:math>, is solved in much the same manner.  Take note of
	  the changes in our integration though.  As we move
	  <m:math>
	    <m:apply>
	      <m:ci>h</m:ci>
	      <m:apply><m:minus/><m:ci>t</m:ci>
		<m:ci>τ</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math> across our other function, the left-hand edge of the
	  function,
	  <m:math>
	    <m:apply>
	      <m:minus/><m:ci>t</m:ci>
	      <m:ci>1</m:ci>
	    </m:apply>
	  </m:math>, becomes our lowlimit for the integral.  This is
	  shown through our convolution integral as

	  <equation id="eqn2">
	    <m:math>
	      <m:apply>
		<m:eq/>
		<m:apply>
		  <m:ci>y</m:ci>
		  <m:ci>t</m:ci>
		</m:apply>
		<m:apply>
		  <m:int/>
		  <m:bvar>
		    <m:ci>τ</m:ci>
		  </m:bvar>
		  <m:lowlimit>
		    <m:apply>
		      <m:minus/>
		      <m:ci>t</m:ci>
		      <m:ci>1</m:ci>
		    </m:apply>
		  </m:lowlimit>
		  <m:uplimit>
		    <m:cn>1</m:cn>
		  </m:uplimit>
		  <m:apply>
		    <m:cn>1</m:cn>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:minus/>
		  <m:cn>1</m:cn>
		  <m:apply>
		    <m:minus/>
		    <m:ci>t</m:ci>
		    <m:cn>1</m:cn>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:minus/>
		  <m:cn>2</m:cn>
		  <m:ci>t</m:ci>
		</m:apply>
	      </m:apply>
	    </m:math>
	  </equation>

	  The above formulas show the method for calculating
	  convolution; however, do not let the simplicity of this
	  example confuse you when you work on other problems.  The
	  method will be the same, you will just have to deal with
	  more math in more complicated integrals.
	</para>
	<para id="s1s3p2">
	    Note that the value of <m:math><m:apply><m:ci>y</m:ci><m:ci>t</m:ci></m:apply></m:math>
	    at all time is given by the integral of the overlapping functions. In this
	    example <m:math><m:ci>y</m:ci></m:math> for a given  <m:math><m:ci>t</m:ci></m:math>
	    equals the gray area in the plots in <cnxn target="f3"/>.

	</para>

      </section>

      <section id="s1s4">
	<name>Convolution Results</name>
	<para id="s1s4p1">

	  Thus, we have the following results for our four regions:

	  <equation id="eqn3">
	    <m:math>
	      <m:apply>
		<m:eq/>
		<m:apply>
		  <m:ci>y</m:ci>
		  <m:ci>t</m:ci>
		</m:apply>
		<m:apply>
		  <m:piecewise>
		    <m:piece>
		      <m:cn>0</m:cn>
		      <m:apply>
			<m:lt/>
			<m:ci>t</m:ci>
			<m:cn>0</m:cn>
		      </m:apply>
		    </m:piece>
		    <m:piece>
		      <m:ci>t</m:ci>
		      <m:apply>
			<m:lt/>
			<m:apply>
			  <m:leq/>
			  <m:cn>0</m:cn>
			  <m:ci>t</m:ci>
			</m:apply>
			<m:cn>1</m:cn>
		      </m:apply>
		    </m:piece>
		    <m:piece>
		      <m:apply>
			<m:minus/>
			<m:cn>2</m:cn>
			<m:ci>t</m:ci>
		      </m:apply>
		      <m:apply>
			<m:lt/>
			<m:apply>
			  <m:leq/>
			  <m:cn>1</m:cn>
			  <m:ci>t</m:ci>
			</m:apply>
			<m:cn>2</m:cn>
		      </m:apply>
		    </m:piece>
		    <m:piece>
		      <m:cn>0</m:cn>
		      <m:apply>
			<m:geq/>
			<m:ci>t</m:ci>
			<m:cn>2</m:cn>
		      </m:apply>
		    </m:piece>
		  </m:piecewise>
		</m:apply>
	      </m:apply>
	    </m:math>
	  </equation>

	  Now that we have found the resulting function for each of the
	  four regions, we can combine them together and graph the
	  convolution of
	  <m:math>
	    <m:apply>
	      <m:csymbol definitionURL="http://cnx.rice.edu/cd/cnxmath.ocd#convolve"/>
	      <m:apply>
		<m:ci>x</m:ci>
		<m:ci>t</m:ci>
	      </m:apply>
	      <m:apply>
		<m:ci>h</m:ci>
		<m:ci>t</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math>.
	</para>

	<figure id="f4">
	  <media type="image/png" src="y_t.png"/>
	  <caption>
	    Shows the system's output in response to the input,
	    <m:math><m:apply>
		<m:ci>x</m:ci>
		<m:ci>t</m:ci>
	      </m:apply>
	    </m:math>.
	  </caption>
	</figure>
      </section><!-- end section s1 subsection s4-->
      <section id="s1s5">
	  <name>Common sense approach</name>
          <para id="s1s5p1">
	      By looking at <cnxn target="f3"/> we can obtain
	      the system output,
	      <m:math><m:apply><m:ci>y</m:ci><m:ci>t</m:ci></m:apply></m:math>,
	      by "common" sense. 
	      For <m:math><m:apply><m:lt/><m:ci>t</m:ci><m:cn>0</m:cn></m:apply></m:math>
	      there is no overlap, so <m:math><m:apply><m:ci>y</m:ci><m:ci>t</m:ci></m:apply></m:math> is 0.
	      As <m:math><m:ci>t</m:ci></m:math> goes from 0 to 1 the overlap will <emphasis>linearly</emphasis>
	      increase with a maximum for <m:math><m:apply><m:eq/><m:ci>t</m:ci><m:cn>1</m:cn></m:apply></m:math>,
	      the maximum corresponds to the peak value in the triangular pulse. 
	      As <m:math><m:ci>t</m:ci></m:math> goes from 1 to 2 the overlap will <emphasis>linearly</emphasis>
	      decrease. For <m:math><m:apply><m:gt/><m:ci>t</m:ci><m:cn>2</m:cn></m:apply></m:math>
	      there will be no overlap and hence no output.
	  </para>

	  <para id="s1s5p2">
	      We see readily from the "common" sense approach that the output function
	      <m:math><m:apply><m:ci>y</m:ci><m:ci>t</m:ci></m:apply></m:math> is the
	      same as obtained above with calculations. When convolving to square
	      pulses the result will <emphasis>always</emphasis> be a
	      triangular pulse. Its origin, peak value and strech will, of course, vary.
	  </para>

      </section><!-- end section 1 subsection 5-->


    </section><!--end section s1 -->
   <section id="s2">
        <list id="l2">
          <item><cnxn document="m11542">Introduction</cnxn></item>
          <item><cnxn document="m11539">Convolution - Discrete time</cnxn></item>
	  <item><cnxn document="m11540">Convolution - Analog</cnxn></item>
	  <item><cnxn document="m10088">Properties of convolution</cnxn></item>
      </list>
    </section>
  </content>
  
</document>
