<?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="m0503">
  
  <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">DFT: Computational Complexity</name>

  <metadata xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
  <md:version xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">2.10</md:version>
  <md:created xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">2000/07/18</md:created>
  <md:revised xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">2003/07/27 15:59:17.563 GMT-5</md:revised>
  <md:authorlist xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="dhj">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Don</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Johnson</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">dhj@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
    <md:maintainer xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="seejaie">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">CJ</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Ganier</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">seejaie@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="dhj">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Don</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Johnson</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">dhj@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="jac3">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">John</md:firstname>
      <md:othername xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Austin</md:othername>
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Cottrell</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">jac3@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
    <md:keyword xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">computational complexity</md:keyword>
    <md:keyword xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">discrete fourier transform</md:keyword>
  </md:keywordlist>

  <md:abstract xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">A brief explanation of calculation complexity and how the complexity of the discrete Fourier transform is order N squared.</md:abstract>
</metadata>

  <content xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
    <para 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="p1">
      We now have a way of computing the spectrum for an arbitrary
      signal: The Discrete Fourier Transform <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" document="m10249" target="eqn1" strength="5">(DFT)</cnxn> computes the spectrum at
      <m:math><m:ci>N</m:ci></m:math> equally spaced frequencies from
      a length- <m:math><m:ci>N</m:ci></m:math> sequence. An issue
      that never arises in analog "computation," like that
      performed by a circuit, is how much work it takes to perform the
      signal processing operation such as filtering. In computation,
      this consideration translates to the number of basic
      computational steps required to perform the needed
      processing. The number of steps, known as the
      <term xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">complexity</term>, becomes equivalent to how long the
      computation takes (how long must we wait for an
      answer). Complexity is not so much tied to specific computers or
      programming languages but to how many steps are required on any
      computer. Thus, a procedure's stated complexity says that
      the time taken will be <term xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">proportional</term> to some
      function of the amount of data used in the computation and the
      amount demanded.
    </para>

    <para 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="p2">
      For example, consider the formula for the discrete Fourier
      transform.  For each frequency we chose, we must multiply each signal
      value by a complex number and add together the results. For a
      real-valued signal, each real-times-complex multiplication requires
      two real multiplications, meaning we have 
      <m:math>
	<m:apply><m:times/><m:cn>2</m:cn><m:ci>N</m:ci></m:apply>
      </m:math> multiplications to perform. To add the results
      together, we must keep the real and imaginary parts
      separate. Adding <m:math><m:ci>N</m:ci></m:math> numbers
      requires <m:math>
      <m:apply><m:minus/><m:ci>N</m:ci><m:cn>1</m:cn></m:apply>
      </m:math>
      additions. Consequently, each frequency requires 

      <m:math>
	<m:apply><m:eq/>
	  <m:apply><m:plus/>
	    <m:apply><m:times/><m:cn>2</m:cn><m:ci>N</m:ci></m:apply>
	    <m:apply><m:times/>
	      <m:cn>2</m:cn>
	      <m:apply><m:minus/><m:ci>N</m:ci><m:cn>1</m:cn></m:apply>
	    </m:apply>
	  </m:apply>
	  <m:apply><m:minus/>
	    <m:apply><m:times/><m:cn>4</m:cn><m:ci>N</m:ci></m:apply>
	    <m:cn>2</m:cn>
	  </m:apply>
	</m:apply>
      </m:math>
      basic computational steps. As we have
      <m:math><m:ci>N</m:ci></m:math> frequencies, the total number of
      computations is
      <m:math>
	<m:apply><m:times/>
	  <m:ci>N</m:ci>
	  <m:apply><m:minus/>
	    <m:apply><m:times/><m:cn>4</m:cn><m:ci>N</m:ci></m:apply>
	    <m:cn>2</m:cn>
	  </m:apply>
	</m:apply>
      </m:math>.  
    </para> 

    <para 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="p3">
      In complexity calculations, we only worry about what happens as
      the data lengths increase, and take the dominant term—here the
      <m:math>
	<m:apply><m:times/>
	  <m:cn>4</m:cn>
	  <m:apply><m:power/><m:ci>N</m:ci><m:cn>2</m:cn></m:apply>
	</m:apply>
      </m:math> term—as reflecting how much work is involved in
      making the computation. As multiplicative constants don't matter
      since we are making a "proportional to" evaluation, we find the
      DFT is an
      <m:math>
	<m:apply>
	  <m:ci>O</m:ci>
	  <m:apply>
	    <m:power/>
	    <m:ci>N</m:ci>
	    <m:cn>2</m:cn>
	  </m:apply>
	</m:apply>
      </m:math> computational procedure. This notation is read "order
      <m:math><m:ci>N</m:ci></m:math>-squared".  Thus, if we double
      the length of the data, we would expect that the computation
      time to approximately quadruple.
    </para>

    <exercise 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="ex1">
      <problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/"> 
	<para 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="exercise">
	  In making the complexity evaluation for the DFT, we assumed
	  the data to be real.  Three questions emerge.  First of all,
	  the spectra of such signals have conjugate symmetry, meaning
	  that negative frequency components (<m:math>
	  <m:apply><m:eq/>
	      <m:ci>k</m:ci>
	      <m:set>
		<m:apply><m:plus/>
		  <m:apply><m:divide/><m:ci>N</m:ci><m:cn>2</m:cn></m:apply>
		  <m:cn>1</m:cn>
		</m:apply>
		<m:ci>…</m:ci>
		<m:apply><m:plus/><m:ci>N</m:ci><m:cn>1</m:cn></m:apply>
	      </m:set>
	    </m:apply>
	  </m:math> in the <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" document="m10249" target="eqn1" strength="5">DFT</cnxn>) can be computed from the
	  corresponding positive frequency components.  Does this
	  symmetry change the DFT's complexity?  Secondly, suppose the
	  data are complex-valued; what is the DFT's complexity now?
	  Finally, a less important but interesting question is
	  suppose we want <m:math><m:ci>K</m:ci></m:math> frequency
	  values instead of <m:math><m:ci>N</m:ci></m:math>; now what
	  is the complexity?
	</para>
      </problem>
      <solution xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
	<para 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="p7">
	  When the signal is real-valued, we may only need half the
	  spectral values, but the complexity remains unchanged. If
	  the data are complex-valued, which demands retaining all
	  frequency values, the complexity is again the same. When
	  only <m:math><m:ci>K</m:ci></m:math> frequencies are needed,
	  the complexity is
	  <m:math>
	    <m:apply>
	      <m:ci>O</m:ci>
	      <m:apply><m:times/>
		<m:ci>K</m:ci> <m:ci>N</m:ci>
	      </m:apply>
	    </m:apply>
	  </m:math>.
	</para>
      </solution>
    </exercise>

  </content>
</document>
