<?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:m="http://www.w3.org/1998/Math/MathML" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="m10253">
  
  <name>Examples for Systems in the Time Domain</name>

  <metadata>
  <md:version>2.5</md:version>
  <md:created>2001/08/08</md:created>
  <md:revised>2002/07/22</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="seejaie">
      <md:firstname>CJ</md:firstname>
      
      <md:surname>Ganier</md:surname>
      <md:email>seejaie@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="dhj">
      <md:firstname>Don</md:firstname>
      
      <md:surname>Johnson</md:surname>
      <md:email>dhj@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="jac3">
      <md:firstname>John</md:firstname>
      <md:othername>Austin</md:othername>
      <md:surname>Cottrell</md:surname>
      <md:email>jac3@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>&gt;superposition</md:keyword>
    <md:keyword>boxcar filter</md:keyword>
    <md:keyword>difference equation</md:keyword>
    <md:keyword>digital signal processing</md:keyword>
    <md:keyword>discrete-time systems</md:keyword>
    <md:keyword>DSP</md:keyword>
    <md:keyword>example</md:keyword>
    <md:keyword>examples</md:keyword>
    <md:keyword>filter</md:keyword>
    <md:keyword>shift-invariant</md:keyword>
    <md:keyword>time domain</md:keyword>
    <md:keyword>time-domain</md:keyword>
  </md:keywordlist>

  <md:abstract>Examples to accompany module "Systems in the Time-Domain."</md:abstract>
</metadata>


  <content>
    
    <example id="p0">
      <para id="exp1">
	Let's consider the simple system having 

	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:ci>p</m:ci><m:cn>1</m:cn>
	  </m:apply>
	</m:math> 
	
	and 
	
	<m:math>
	  <m:apply><m:eq/><m:ci>q</m:ci><m:cn>0</m:cn></m:apply>
	</m:math>.

	
	<equation id="eq1"> 
	  <m:math>
	    <m:apply><m:ci type="fn">y</m:ci><m:ci>n</m:ci></m:apply>
	    <m:apply>
	      <m:plus/>
	      <m:apply>
		<m:times/>
		<m:ci>a</m:ci>
		<m:apply>
		  <m:ci type="fn">y</m:ci>
		  <m:apply>
		    <m:minus/><m:ci>n</m:ci><m:cn>1</m:cn>
		  </m:apply>
		</m:apply>
	      </m:apply>
	      <m:apply>
		<m:times/>
		<m:ci>b</m:ci>
		<m:apply>
		  <m:ci type="fn">x</m:ci><m:ci>n</m:ci>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	</equation>
      </para>


      <para id="p1"> 
	To compute the output at some index, this difference equation
	says we need to know what the previous output 

	<m:math>
	  <m:apply>
	    <m:ci type="fn">y</m:ci>
	    <m:apply><m:minus/><m:ci>n</m:ci><m:cn>1</m:cn></m:apply>
	  </m:apply>
	</m:math> 

	and what the input signal is at that moment of time. In more
	detail, let's compute this system's output to a unit-sample input: 

	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:ci type="fn">x</m:ci><m:ci>n</m:ci>
	    </m:apply>
	    <m:apply>
	      <m:ci type="fn">δ</m:ci><m:ci>n</m:ci>
	    </m:apply>
	  </m:apply>
	</m:math>.
	
	Because the input is zero for negative indices, we start by trying to
	compute the output at 

	<m:math>
	  <m:apply><m:eq/><m:ci>n</m:ci><m:cn>0</m:cn></m:apply>
	</m:math>.  

	<equation id="eq2">
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:ci type="fn">y</m:ci><m:cn>0</m:cn>
	      </m:apply>
	      <m:apply>
		<m:plus/>
		<m:apply>
		  <m:times/>
		  <m:ci>a</m:ci>
		  <m:apply>
		    <m:ci type="fn">y</m:ci>
		    <m:cn>-1</m:cn>
		  </m:apply>
		</m:apply>
		<m:ci>b</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math>
	</equation>

	What is the value of 

	<m:math>
	  <m:apply><m:ci type="fn">y</m:ci><m:cn>-1</m:cn></m:apply>
	</m:math>?  
	Because we have used an input that is zero for all
	negative indices, it is reasonable to assume that the output is also
	zero. Certainly, the difference equation would not describe a 
	<cnxn strength="5" document="m0007"> linear system </cnxn>if the
	input that is zero for <emphasis>all</emphasis> time did not
	produce a zero output. With this assumption, 
	
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:apply>
	      <m:ci type="fn">y</m:ci><m:cn>-1</m:cn>
	    </m:apply>
	    <m:cn>0</m:cn>
	  </m:apply>
	</m:math>, 

	leaving 

	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:apply><m:ci type="fn">y</m:ci><m:cn>0</m:cn></m:apply>
	    <m:ci>b</m:ci>
	  </m:apply>
	</m:math>. 

	For 
	<m:math>
	  <m:apply><m:gt/><m:ci>n</m:ci><m:cn>0</m:cn></m:apply>
	</m:math>, 
	the input unit-sample is zero, which leaves us with the
	difference equation 
	<m:math>
	  <m:apply><m:forall/>
	    <m:bvar><m:ci>n</m:ci></m:bvar>
	    <m:condition>
	      <m:apply><m:gt/><m:ci>n</m:ci><m:cn>0</m:cn></m:apply>
	    </m:condition>
	    <m:apply>
	      <m:eq/>
	      <m:apply><m:ci type="fn">y</m:ci><m:ci>n</m:ci></m:apply>
	      <m:apply>
		<m:times/>
		<m:ci>a</m:ci>
		<m:apply>
		  <m:ci type="fn">y</m:ci>
		  <m:apply><m:minus/><m:ci>n</m:ci><m:cn>1</m:cn></m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:apply>
	</m:math>. 

	We can envision how the filter responds to this input by making a table. 

	<equation id="eq3">
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply><m:ci type="fn">y</m:ci><m:ci>n</m:ci></m:apply>
	      <m:apply>
		<m:plus/>
		<m:apply>
		  <m:times/>
		  <m:ci>a</m:ci>
		  <m:apply>
		    <m:ci type="fn">y</m:ci>
		    <m:apply>
		      <m:minus/><m:ci>n</m:ci><m:cn>1</m:cn>
		    </m:apply>
		  </m:apply>
		</m:apply>
		<m:apply>
		  <m:times/>
		  <m:ci>b</m:ci>
		  <m:apply><m:ci type="fn">δ</m:ci><m:ci>n</m:ci></m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math>
	</equation>
      </para>


      <figure orient="vertical" id="fig1000">
	<table frame="all" id="table1">
	  <tgroup cols="3" align="left" colsep="1" rowsep="1">
	    <thead valign="top">
	      <row>
		<entry>
		  n
		</entry>
		<entry>
		  x(n)
		</entry>
		<entry>
		  y(n)
		</entry>
	      </row>
	    </thead>
	    <tbody valign="top">
	      <row>
		<entry>
		  -1
		</entry>
		<entry>
		  0
		</entry>
		<entry>
		  0
		</entry>
	      </row>
	      <row>
		<entry>
		  0
		</entry>
		<entry>
		  b
		</entry>
		<entry>
		  b
		</entry>
	      </row>
	      <row>
		<entry>
		  1
		</entry>
		<entry>
		  0
		</entry>
		<entry>
		  <m:math>
		    <m:apply>
		      <m:times/>
		      <m:ci>b</m:ci>
		      <m:ci>a</m:ci>
		    </m:apply>
		  </m:math>
		</entry>
	      </row>
	      <row>
		<entry>
		  2
		</entry>
		<entry>
		  0
		</entry>
		<entry>
		  <m:math>
		    <m:apply>
		      <m:times/>
		      <m:ci>b</m:ci>
		      <m:apply><m:power/><m:ci>a</m:ci><m:cn>2</m:cn></m:apply>
		    </m:apply>
		  </m:math>
		</entry>
	      </row>
	      <row>
		<entry>
		  :
		</entry>
		<entry>
		  0
		</entry>
		<entry>
		  :
		</entry>
	      </row>
	      <row>
		<entry>
		  n
		</entry>
		<entry>
		  0
		</entry>
		<entry>
		  <m:math> 
		    <m:apply>
		      <m:times/>
		      <m:ci>b</m:ci>
		      <m:apply><m:power/><m:ci>a</m:ci><m:ci>n</m:ci></m:apply>
		    </m:apply>
		  </m:math>
		</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</table>
      </figure>

      
      <para id="p15">
	Coefficient values determine how the output behaves. The
	parameter <m:math><m:ci>b</m:ci></m:math> can be any value,
	and serves as a gain. The effect of the parameter
	<m:math><m:ci>a</m:ci></m:math> is more complicated (<cnxn target="fig1000" strength="5"/>).  If it equals zero, the
	output simply equals the input times the gain
	<m:math><m:ci>b</m:ci></m:math>. For all non-zero values of
	<m:math><m:ci>a</m:ci></m:math>, the output lasts forever;
	such systems are said to be <term>IIR</term> (
	<emphasis>I</emphasis>nfinite <emphasis>I</emphasis>mpulse
	<emphasis>R</emphasis>esponse). The reason for this
	terminology is that the unit sample also known as the impulse
	(especially in analog situations), and the system's response
	to the "impulse" lasts forever. If
	<m:math><m:ci>a</m:ci></m:math> is positive and less than one,
	the output is a decaying exponential. When
	<m:math><m:apply><m:eq/><m:ci>a</m:ci><m:cn>1</m:cn></m:apply></m:math>,
	the output is a unit step. If <m:math><m:ci>a</m:ci></m:math>
	is negative and greater than
	<m:math><m:apply><m:minus/><m:cn>1</m:cn></m:apply></m:math>,
	the output oscillates while decaying exponentially. When

	<m:math>
	  <m:apply><m:eq/><m:ci>a</m:ci><m:cn>1</m:cn></m:apply>
	</m:math>, 
	the output changes sign forever, alternating between 
	<m:math>
	  <m:ci>b</m:ci></m:math> and <m:math>
	  <m:apply><m:minus/><m:ci>b</m:ci></m:apply></m:math>. 
	More dramatic effects when 
	<m:math>
	  <m:apply><m:gt/><m:apply><m:abs/><m:ci>a</m:ci></m:apply><m:cn>1</m:cn></m:apply>
	</m:math>; 
	whether positive or negative, the
	output signal becomes larger and larger, <emphasis>growing</emphasis>
	exponentially.  
      </para>


      <figure id="fig1001">
	<media type="image/png" src="sig21.png"/>
	<caption> The input to the simple example system, a unit sample, is
	  shown at the top, with the outputs for several system parameter values
	  shown below.
	</caption>
      </figure>

      
      <para id="p25">
	Positive values of <m:math><m:ci>a</m:ci></m:math> 
	are used in population models to
	describe how population size increases over time. Here,
	<m:math><m:ci>n</m:ci></m:math> might correspond to 
	generation. The difference equation says that the number in the next
	generation is some multiple of the previous one. If this multiple is
	less than one, the population becomes extinct; if greater than one,
	the population flourishes. The same difference equation also describes
	the effect of compound interest on deposits. Here,
	<m:math><m:ci>n</m:ci></m:math> indexes the times at 
	which compounding occurs (daily, monthly, <foreign>etc.</foreign>), 
	<m:math><m:ci>a</m:ci></m:math> equals the compound interest rate plus
	one, and 
	<m:math> 
	  <m:apply><m:eq/><m:ci>b</m:ci><m:cn>1</m:cn></m:apply>
	</m:math> (the bank provides no gain). In signal processing
	applications, we typically require that the output remain bounded for
	any input. For our example, that means that we restrict 
	<m:math>
	  <m:apply><m:eq/><m:apply><m:abs/><m:ci>a</m:ci></m:apply><m:cn>1</m:cn></m:apply>
	</m:math> and chose values for it and the
	gain according to the application. 
      </para>
    </example>

    
    <exercise id="exer1">
      <problem> <para id="probpara1">Note that the 
	  <cnxn document="m0508" strength="5" target="fig0002">difference equation</cnxn>,
	
	  <equation id="eq0002">
	    <name>the difference equation</name>
	    <m:math>
	      <m:apply>
		<m:eq/>
		<m:apply><m:ci type="fn">y</m:ci><m:ci>n</m:ci></m:apply>
		<m:apply>
		  <m:plus/>
		  <m:apply>
		    <m:times/>
		    <m:ci><m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub></m:ci>
		    <m:apply>
		      <m:ci type="fn">y</m:ci>
		      <m:apply>
			<m:minus/>
			<m:ci>n</m:ci><m:cn>1</m:cn>
		      </m:apply>
		    </m:apply>
		  </m:apply>
		  <m:ci>…</m:ci>
		  <m:apply>
		    <m:times/>
		    <m:ci><m:msub><m:mi>a</m:mi><m:mi>p</m:mi></m:msub></m:ci>
		    <m:apply>
		      <m:ci type="fn">y</m:ci>
		      <m:apply>
			<m:minus/>
			<m:ci>n</m:ci><m:ci>p</m:ci>
		      </m:apply>
		    </m:apply>
		  </m:apply>
		  <m:apply>
		    <m:times/>
		    <m:ci><m:msub><m:mi>b</m:mi><m:mn>0</m:mn></m:msub></m:ci>
		    <m:apply><m:ci type="fn">x</m:ci><m:ci>n</m:ci></m:apply>
		  </m:apply>
		  <m:apply>
		    <m:times/>
		    <m:ci><m:msub><m:mi>b</m:mi><m:mn>1</m:mn></m:msub></m:ci>
		    <m:apply>
		      <m:ci type="fn">x</m:ci>
		      <m:apply>
			<m:minus/>
			<m:ci>n</m:ci><m:cn>1</m:cn>
		      </m:apply>
		    </m:apply>
		  </m:apply>
		  <m:ci>…</m:ci>
		  <m:apply>
		    <m:times/>
		    <m:ci><m:msub><m:mi>b</m:mi><m:mi>q</m:mi></m:msub></m:ci>
		    <m:apply>
		      <m:ci type="fn">x</m:ci>
		      <m:apply>
			<m:minus/>
			<m:ci>n</m:ci><m:ci>q</m:ci>
		      </m:apply>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:math>
	  </equation>

	  
	  does not involve terms like 

	  <m:math>
	    <m:apply>
	      <m:ci type="fn">y</m:ci>
	      <m:apply>
		<m:plus/><m:ci>n</m:ci><m:cn>1</m:cn>
	      </m:apply>
	    </m:apply>
	  </m:math> 

	  or 

	  <m:math>
	    <m:apply>
	      <m:ci type="fn">x</m:ci>
	      <m:apply><m:plus/><m:ci>n</m:ci><m:cn>1</m:cn></m:apply>
	    </m:apply>
	  </m:math> 
	  
	  on the equation's right side. Can such terms also be
	  included? Why or why not?
	</para>
      </problem>
     
      <solution>
	<para id="solp1">
	  Such terms would require the system to know what future
	  input or output values would be before the current value was
	  computed. Thus, such terms can cause difficulties.
	</para>
      </solution>
    </exercise>


    <figure id="fig1002">
      <media type="image/png" src="sig22.png"/> 
      <caption>The plot shows the unit-sample response of a length-5
	boxcar filter.</caption>
    </figure>                                    

    
    <example id="ex2001"> 
      <para id="para1"> 
	A somewhat different system has no "a" coefficients. Consider the
	difference equation

	
	<equation id="eq0003"> 
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:ci type="fn">y</m:ci>
		<m:ci>n</m:ci>
	      </m:apply>
	      <m:apply>
		<m:times/>
		<m:apply>
		  <m:divide/>
		  <m:cn>1</m:cn>
		  <m:ci>q</m:ci>
		</m:apply>
		<m:apply>
		  <m:plus/>
		  <m:apply>
		    <m:ci type="fn">x</m:ci>
		    <m:ci>n</m:ci>
		  </m:apply>
		  <m:ci>…</m:ci>
		  <m:apply>
		    <m:ci type="fn">x</m:ci>
		    <m:apply>
		      <m:plus/>
		      <m:apply>
			<m:minus/>
			<m:ci>n</m:ci>
			<m:ci>q</m:ci>
		      </m:apply>
		      <m:cn>1</m:cn>
		    </m:apply>
		  </m:apply>
		</m:apply>
	      </m:apply>
	    </m:apply>
	  </m:math> 
	</equation>

	Because this system's output depends only on current and previous
	input values, we need not be concerned with initial conditions. When
	the input is a unit-sample, the output equals 
	<m:math>
	  <m:apply>
	    <m:divide/><m:cn>1</m:cn> <m:ci>q</m:ci>
	  </m:apply>
	</m:math> 
	
	for 
	
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:ci>n</m:ci>
	    <m:list>
	      <m:cn>0</m:cn>
	      <m:ci>…</m:ci>
	      <m:apply>
		<m:minus/> <m:ci>q</m:ci> <m:cn>1</m:cn>
	      </m:apply>
	    </m:list>
	  </m:apply>
	</m:math>
	
	, then equals zero thereafter. Such systems are said to be
	<term>FIR</term> (Finite Impulse Response) because their unit
	sample responses have finite duration. Plotting this response
	(<cnxn target="fig1002" strength="9"/>) shows that the
	unit-sample response is a pulse of width
	<m:math><m:ci>q</m:ci></m:math> and height
	
	<m:math>
	  <m:apply>
	    <m:divide/> <m:cn>1</m:cn> <m:ci>q</m:ci>
	  </m:apply>
	</m:math> 
	
	. This waveform is also known as a boxcar, hence the name
	  <term>boxcar filter</term> given to this system. (We'll
	  derive its frequency response and develop its filtering
	  interpretation in the next section.) For now, note that the
	  difference equation says that each output value equals the
	  <emphasis>average</emphasis> of the input's current and
	  previous values. Thus, the output equals the running average
	  of input's previous <m:math><m:ci>q</m:ci></m:math>
	  values. Such a system could be used to produce the average
	  weekly temperature (
	
	<m:math>
	  <m:apply>
	    <m:eq/> <m:ci>q</m:ci> <m:cn>7</m:cn>
	  </m:apply>
	</m:math>
	) that could be updated daily.  
      </para>
    </example>   


  </content>
</document>
