<?xml version="1.0" encoding="utf-8"?>
<!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:bib="http://bibtexml.sf.net/" xmlns:md="http://cnx.rice.edu/mdml/0.4" id="id2255528">
  <name>Least Squared Error Design of FIR Filters</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2008/06/09 13:14:50.485 GMT-5</md:created>
  <md:revised>2008/06/24 00:03:50.955 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="cburrus">
      <md:firstname>C.</md:firstname>
      <md:othername>Sidney</md:othername>
      <md:surname>Burrus</md:surname>
      <md:email>csb@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="dcwill">
      <md:firstname>Daniel</md:firstname>
      <md:othername>Collins</md:othername>
      <md:surname>Williamson</md:surname>
      <md:email>dwilliamson1285@gmail.com</md:email>
    </md:maintainer>
    <md:maintainer id="cburrus">
      <md:firstname>C.</md:firstname>
      <md:othername>Sidney</md:othername>
      <md:surname>Burrus</md:surname>
      <md:email>csb@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  

  <md:abstract/>
</metadata>
  <content>
    <para id="id2255546">Because the integral of the square of a signal is a measure of its energy,
there is some physical reason for minimizing the integral of the squared error
<cnxn target="bid0"/>, <cnxn target="bid1"/>. Also, because of Parseval's theorem, a least
squares approximation in the frequency domain is a least squares
approximation in the time domain. However, minimizing the <emphasis>worst case</emphasis>
squared error induces a minimum Chebyshev error problem in some formulations
<cnxn target="bid2"/>.</para>
    <section id="uid1">
      <name>Discrete Frequency Samples of Error</name>
      <para id="id2255584">If we approximate the integral squared error by the sum of the squared
error as given by</para>
      <equation id="uid2">
        <m:math mode="display" overflow="scroll">
          <m:mtable displaystyle="true">
            <m:mtr>
              <m:mtd columnalign="right">
                <m:mi>q</m:mi>
              </m:mtd>
              <m:mtd>
                <m:mo>=</m:mo>
              </m:mtd>
              <m:mtd columnalign="left">
                <m:mrow>
                  <m:mfrac>
                    <m:mn>1</m:mn>
                    <m:mi>L</m:mi>
                  </m:mfrac>
                  <m:munderover>
                    <m:mo>∑</m:mo>
                    <m:mrow>
                      <m:mi>k</m:mi>
                      <m:mo>=</m:mo>
                      <m:mn>0</m:mn>
                    </m:mrow>
                    <m:mrow>
                      <m:mi>L</m:mi>
                      <m:mo>-</m:mo>
                      <m:mn>1</m:mn>
                    </m:mrow>
                  </m:munderover>
                  <m:msup>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>A</m:mi>
                      <m:mrow>
                        <m:mo>(</m:mo>
                        <m:msub>
                          <m:mi>ω</m:mi>
                          <m:mi>k</m:mi>
                        </m:msub>
                        <m:mo>)</m:mo>
                      </m:mrow>
                      <m:mo>-</m:mo>
                      <m:msub>
                        <m:mi>A</m:mi>
                        <m:mi>d</m:mi>
                      </m:msub>
                      <m:mrow>
                        <m:mo>(</m:mo>
                        <m:msub>
                          <m:mi>ω</m:mi>
                          <m:mi>k</m:mi>
                        </m:msub>
                        <m:mo>)</m:mo>
                      </m:mrow>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mn>2</m:mn>
                  </m:msup>
                  <m:mo>=</m:mo>
                  <m:mfrac>
                    <m:mn>1</m:mn>
                    <m:mi>L</m:mi>
                  </m:mfrac>
                  <m:munderover>
                    <m:mo>∑</m:mo>
                    <m:mrow>
                      <m:mi>k</m:mi>
                      <m:mo>=</m:mo>
                      <m:mn>0</m:mn>
                    </m:mrow>
                    <m:mrow>
                      <m:mi>L</m:mi>
                      <m:mo>-</m:mo>
                      <m:mn>1</m:mn>
                    </m:mrow>
                  </m:munderover>
                  <m:mi>e</m:mi>
                  <m:msup>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:msub>
                        <m:mi>ω</m:mi>
                        <m:mi>k</m:mi>
                      </m:msub>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mn>2</m:mn>
                  </m:msup>
                </m:mrow>
              </m:mtd>
            </m:mtr>
            <m:mtr>
              <m:mtd/>
              <m:mtd>
                <m:mo>≈</m:mo>
              </m:mtd>
              <m:mtd columnalign="left">
                <m:mrow>
                  <m:msubsup>
                    <m:mo>∫</m:mo>
                    <m:mn>0</m:mn>
                    <m:mi>π</m:mi>
                  </m:msubsup>
                  <m:msup>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>A</m:mi>
                      <m:mrow>
                        <m:mo>(</m:mo>
                        <m:mi>ω</m:mi>
                        <m:mo>)</m:mo>
                      </m:mrow>
                      <m:mo>-</m:mo>
                      <m:msub>
                        <m:mi>A</m:mi>
                        <m:mi>d</m:mi>
                      </m:msub>
                      <m:mrow>
                        <m:mo>(</m:mo>
                        <m:mi>ω</m:mi>
                        <m:mo>)</m:mo>
                      </m:mrow>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mn>2</m:mn>
                  </m:msup>
                  <m:mspace width="0.166667em"/>
                  <m:mi>d</m:mi>
                  <m:mi>ω</m:mi>
                  <m:mo>=</m:mo>
                  <m:msubsup>
                    <m:mo>∫</m:mo>
                    <m:mn>0</m:mn>
                    <m:mi>π</m:mi>
                  </m:msubsup>
                  <m:mi>e</m:mi>
                  <m:msup>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>ω</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mn>2</m:mn>
                  </m:msup>
                  <m:mspace width="0.166667em"/>
                  <m:mi>d</m:mi>
                  <m:mi>ω</m:mi>
                </m:mrow>
              </m:mtd>
            </m:mtr>
          </m:mtable>
        </m:math>
      </equation>
      <para id="id2256090">where the approximation error as a function of frequency is
defined by <m:math overflow="scroll"><m:mrow><m:mi>e</m:mi><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow><m:mo>=</m:mo><m:mi>A</m:mi><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow><m:mo>-</m:mo><m:msub><m:mi>A</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> with <m:math overflow="scroll"><m:mrow><m:mi>A</m:mi><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:math> being the
amplitude response of the filter and <m:math overflow="scroll"><m:mrow><m:msub><m:mi>A</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> being the desired
amplitude response or the ideal response. The matrix statement for the
error vector becomes</para>
      <equation id="uid3">
        <m:math mode="display" overflow="scroll">
          <m:mrow>
            <m:mi>ϵ</m:mi>
            <m:mspace width="0.166667em"/>
            <m:mo>=</m:mo>
            <m:mspace width="0.166667em"/>
            <m:mi mathvariant="bold">A</m:mi>
            <m:mo>-</m:mo>
            <m:msub>
              <m:mi mathvariant="bold">A</m:mi>
              <m:mi mathvariant="bold">d</m:mi>
            </m:msub>
            <m:mspace width="0.166667em"/>
            <m:mo>=</m:mo>
            <m:mspace width="0.166667em"/>
            <m:mi mathvariant="bold">C</m:mi>
            <m:mspace width="0.166667em"/>
            <m:mi mathvariant="bold">a</m:mi>
            <m:mo>-</m:mo>
            <m:msub>
              <m:mi mathvariant="bold">A</m:mi>
              <m:mi mathvariant="bold">d</m:mi>
            </m:msub>
          </m:mrow>
        </m:math>
      </equation>
      <para id="id2256257">where <m:math overflow="scroll"><m:mi mathvariant="bold">C</m:mi></m:math> is the matrix of cosines from (<cnxn target=""/>),
<m:math overflow="scroll"><m:mi mathvariant="bold">a</m:mi></m:math> is the vector of half of the filter coefficients from
(<cnxn target=""/>), and <m:math overflow="scroll"><m:msub><m:mi mathvariant="bold">A</m:mi><m:mi mathvariant="bold">d</m:mi></m:msub></m:math> is the vector of samples of the ideal desired
amplitude response. The number of samples of the amplitude response is <m:math overflow="scroll"><m:mi>L</m:mi></m:math>
which should be five to twenty times the length of the filter to give a
good approximation of the integral in most cases. The error to be
minimized is</para>
      <equation id="uid4">
        <m:math mode="display" overflow="scroll">
          <m:mrow>
            <m:mi>q</m:mi>
            <m:mspace width="0.166667em"/>
            <m:mo>=</m:mo>
            <m:mspace width="0.166667em"/>
            <m:mrow>
              <m:msup>
                <m:mi>ϵ</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:mi>ϵ</m:mi>
            </m:mrow>
          </m:mrow>
        </m:math>
      </equation>
      <para id="id2256355">except for a scale factor of <m:math overflow="scroll"><m:mfrac><m:mn>1</m:mn><m:mi>L</m:mi></m:mfrac></m:math>.</para>
      <para id="id2256374">This could also be posed for the general phase problem by using
<m:math overflow="scroll"><m:mrow><m:mi>H</m:mi><m:mo>(</m:mo><m:msub><m:mi>ω</m:mi><m:mi>k</m:mi></m:msub><m:mo>)</m:mo></m:mrow></m:math> rather than <m:math overflow="scroll"><m:mrow><m:mi>A</m:mi><m:mo>(</m:mo><m:msub><m:mi>ω</m:mi><m:mi>k</m:mi></m:msub><m:mo>)</m:mo></m:mrow></m:math> and <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math>, the actual impulse
response, rather than <m:math overflow="scroll"><m:mrow><m:mi>a</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math>, a nomralized half of the impulse response.</para>
      <section id="uid5">
        <name>Truncated frequency sampling design using the inverse FFT or IDCT</name>
        <para id="id2256464">The design problem is posed by defining an error measure <m:math overflow="scroll"><m:mi>q</m:mi></m:math> as a sum of
the squared differences between the actual and the desired frequency
response over a set of <m:math overflow="scroll"><m:mi>L</m:mi></m:math> frequency samples. This error function is
defined as</para>
        <equation id="uid6">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mfrac>
                <m:mn>1</m:mn>
                <m:mi>L</m:mi>
              </m:mfrac>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>k</m:mi>
                  <m:mo>=</m:mo>
                  <m:mn>0</m:mn>
                </m:mrow>
                <m:mrow>
                  <m:mi>L</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:munderover>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:mi>H</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mi>k</m:mi>
                    </m:msub>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>-</m:mo>
                  <m:msub>
                    <m:mi>H</m:mi>
                    <m:mi>d</m:mi>
                  </m:msub>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mi>k</m:mi>
                    </m:msub>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2256586">where <m:math overflow="scroll"><m:mrow><m:msub><m:mi>H</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:msub><m:mi>ω</m:mi><m:mi>k</m:mi></m:msub><m:mo>)</m:mo></m:mrow></m:mrow></m:math> are the <m:math overflow="scroll"><m:mi>L</m:mi></m:math> samples of the desired response. This
problem is easier to formulate and solve if the frequency samples
are equally spaced as in (<cnxn target=""/>) which gives</para>
        <equation id="uid7">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msub>
                <m:mi>ω</m:mi>
                <m:mi>k</m:mi>
              </m:msub>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mn>2</m:mn>
              <m:mi>π</m:mi>
              <m:mi>k</m:mi>
              <m:mo>/</m:mo>
              <m:mi>L</m:mi>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2256670">and the problem is restricted to linear-phase filters where the
real-valued amplitude <m:math overflow="scroll"><m:mrow><m:mi>A</m:mi><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:math> can be approximated rather than the
complex frequency response <m:math overflow="scroll"><m:mrow><m:mi>H</m:mi><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:math>. For approximations to a complex
response, see <cnxn target="uid90">"Complex L 2  and Minimum Phase Approximation"</cnxn>.</para>
        <para id="id2256716">Linear phase and equally spaced samples cause (<cnxn target="uid6"/>) to become</para>
        <equation id="uid8">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mfrac>
                <m:mn>1</m:mn>
                <m:mi>L</m:mi>
              </m:mfrac>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>k</m:mi>
                  <m:mo>=</m:mo>
                  <m:mn>0</m:mn>
                </m:mrow>
                <m:mrow>
                  <m:mi>L</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:munderover>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:mi>A</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mn>2</m:mn>
                    <m:mi>π</m:mi>
                    <m:mi>k</m:mi>
                    <m:mo>/</m:mo>
                    <m:mi>L</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>-</m:mo>
                  <m:msub>
                    <m:mi>A</m:mi>
                    <m:mi>d</m:mi>
                  </m:msub>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mn>2</m:mn>
                    <m:mi>π</m:mi>
                    <m:mi>k</m:mi>
                    <m:mo>/</m:mo>
                    <m:mi>L</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2256828">or with a simpler notation</para>
        <equation id="uid9">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mfrac>
                <m:mn>1</m:mn>
                <m:mi>L</m:mi>
              </m:mfrac>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>k</m:mi>
                  <m:mo>=</m:mo>
                  <m:mn>0</m:mn>
                </m:mrow>
                <m:mrow>
                  <m:mi>L</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:munderover>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:msub>
                    <m:mi>A</m:mi>
                    <m:mi>k</m:mi>
                  </m:msub>
                  <m:mo>-</m:mo>
                  <m:msub>
                    <m:mi>A</m:mi>
                    <m:mrow>
                      <m:mi>d</m:mi>
                      <m:mi>k</m:mi>
                    </m:mrow>
                  </m:msub>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2256914">A very powerful property of the Fourier transform allows a straightforward
design of least-squared-error FIR filters. Parseval's Theorem,
which is based on the orthogonality of the DFT, states that the error
defined by (<cnxn target="uid9"/>) in the frequency domain can also be calculated in the
time domain by</para>
        <equation id="uid10">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>n</m:mi>
                  <m:mo>=</m:mo>
                  <m:mn>0</m:mn>
                </m:mrow>
                <m:mrow>
                  <m:mi>L</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:munderover>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:mi>h</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>-</m:mo>
                  <m:msub>
                    <m:mi>h</m:mi>
                    <m:mi>d</m:mi>
                  </m:msub>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2257007">where <m:math overflow="scroll"><m:mrow><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> is the length-L symmetric FIR filter that has the <m:math overflow="scroll"><m:mi>L</m:mi></m:math> frequency
response amplitude samples <m:math overflow="scroll"><m:msub><m:mi>A</m:mi><m:mrow><m:mi>d</m:mi><m:mi>k</m:mi></m:mrow></m:msub></m:math>. This may be calculated by the
frequency sampling method of <cnxn target=""/> using the special formulas
such as (<cnxn target=""/>) for length <m:math overflow="scroll"><m:mi>L</m:mi></m:math> or the inverse DFT. The
filter to be designed has a length-N symmetric impulse response <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> with <m:math overflow="scroll"><m:mi>L</m:mi></m:math>
frequency response samples <m:math overflow="scroll"><m:msub><m:mi>A</m:mi><m:mi>k</m:mi></m:msub></m:math>.</para>
        <para id="id2257119">Because the filter <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> is of length-N and symmetric, the error equation (<cnxn target="uid10"/>)
can be split into two sums</para>
        <equation id="uid11">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>n</m:mi>
                  <m:mo>=</m:mo>
                  <m:mo>-</m:mo>
                  <m:mi>M</m:mi>
                </m:mrow>
                <m:mi>M</m:mi>
              </m:munderover>
              <m:mrow>
                <m:mo>|</m:mo>
              </m:mrow>
              <m:mover accent="true">
                <m:mi>h</m:mi>
                <m:mo>^</m:mo>
              </m:mover>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mo>-</m:mo>
              <m:msub>
                <m:mover accent="true">
                  <m:mi>h</m:mi>
                  <m:mo>^</m:mo>
                </m:mover>
                <m:mi>d</m:mi>
              </m:msub>
              <m:msup>
                <m:mrow>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
              <m:mo>+</m:mo>
              <m:mn>2</m:mn>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>n</m:mi>
                  <m:mo>=</m:mo>
                  <m:mi>M</m:mi>
                  <m:mo>+</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>L</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                  <m:mo>)</m:mo>
                  <m:mo>/</m:mo>
                  <m:mn>2</m:mn>
                </m:mrow>
              </m:munderover>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:msub>
                    <m:mover accent="true">
                      <m:mi>h</m:mi>
                      <m:mo>^</m:mo>
                    </m:mover>
                    <m:mi>d</m:mi>
                  </m:msub>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2257305">where <m:math overflow="scroll"><m:mrow><m:mover accent="true"><m:mi>h</m:mi><m:mo>^</m:mo></m:mover><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> and <m:math overflow="scroll"><m:mrow><m:msub><m:mover accent="true"><m:mi>h</m:mi><m:mo>^</m:mo></m:mover><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> are the inverse DTFTs of <m:math overflow="scroll"><m:msub><m:mi>A</m:mi><m:mi>k</m:mi></m:msub></m:math> and <m:math overflow="scroll"><m:msub><m:mi>A</m:mi><m:mrow><m:mi>d</m:mi><m:mi>k</m:mi></m:mrow></m:msub></m:math>
respectively, which means they are the <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> and <m:math overflow="scroll"><m:mrow><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> shifted to be
symmetic about <m:math overflow="scroll"><m:mrow><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math>. This requires the number of frequency samples <m:math overflow="scroll"><m:mi>L</m:mi></m:math> must
be odd.</para>
        <para id="id2257460">Equation <cnxn target="uid11"/> clearly shows that to minimize <m:math overflow="scroll"><m:mi>q</m:mi></m:math>, the <m:math overflow="scroll"><m:mi>N</m:mi></m:math> values of
<m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> are chosen to be equal to the equivalent <m:math overflow="scroll"><m:mi>N</m:mi></m:math> values of <m:math overflow="scroll"><m:mrow><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math>
making the first sum equal zero. In other words, <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> is obtained by
symmetrically truncating <m:math overflow="scroll"><m:mrow><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math>. The residual error is then given by the
second summation above. An examination of the residual error as a function
of <m:math overflow="scroll"><m:mi>N</m:mi></m:math> may aid in the choice of the filter length <m:math overflow="scroll"><m:mi>N</m:mi></m:math>.</para>
        <para id="id2257598">For the Type 1 linear-phase FIR filter (described in <cnxn target=""/>)
which has an odd length <m:math overflow="scroll"><m:mi>N</m:mi></m:math> and an even-symmetric impulse
response, the <m:math overflow="scroll"><m:mi>L</m:mi></m:math> equally spaced samples of the frequency response
from (<cnxn target=""/>) gives</para>
        <equation id="uid12">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msub>
                <m:mi>A</m:mi>
                <m:mi>k</m:mi>
              </m:msub>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>n</m:mi>
                  <m:mo>=</m:mo>
                  <m:mn>0</m:mn>
                </m:mrow>
                <m:mrow>
                  <m:mi>M</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:munderover>
              <m:mn>2</m:mn>
              <m:mi>h</m:mi>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mo form="prefix">cos</m:mo>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mn>2</m:mn>
                <m:mi>π</m:mi>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>M</m:mi>
                  <m:mo>-</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mi>k</m:mi>
                <m:mo>/</m:mo>
                <m:mi>L</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mo>+</m:mo>
              <m:mi>h</m:mi>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>M</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2257734">for <m:math overflow="scroll"><m:mrow><m:mi>k</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>,</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>.</m:mo><m:mo>.</m:mo><m:mo>.</m:mo><m:mo>.</m:mo><m:mo>,</m:mo><m:mi>L</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>, where <m:math overflow="scroll"><m:mrow><m:mi>M</m:mi><m:mo>=</m:mo><m:mo>(</m:mo><m:mi>N</m:mi><m:mo>-</m:mo><m:mn>1</m:mn><m:mo>)</m:mo><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math>. This
formula was derived as a special case of the DFT applied to the Type 1
real, even-symmetric FIR filter coefficients to calculate the sampled
amplitude of the frequency response (perhaps better posed using <m:math overflow="scroll"><m:mrow><m:mi>a</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math>).
It was noted in <cnxn target=""/> that it is also a cosine transform and
it can be shown that this transformation is orthogonal over the
independent values of <m:math overflow="scroll"><m:msub><m:mi>A</m:mi><m:mi>k</m:mi></m:msub></m:math>, just as the DFT is.</para>
        <para id="id2257850">The desired ideal amplitude gives the ideal impulse response <m:math overflow="scroll"><m:mrow><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math>
from (<cnxn target=""/>0 by</para>
        <equation id="uid13">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msub>
                <m:mi>h</m:mi>
                <m:mi>d</m:mi>
              </m:msub>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mfrac>
                <m:mn>1</m:mn>
                <m:mi>N</m:mi>
              </m:mfrac>
              <m:mrow>
                <m:mo>[</m:mo>
                <m:msub>
                  <m:mi>A</m:mi>
                  <m:mrow>
                    <m:mi>d</m:mi>
                    <m:mn>0</m:mn>
                  </m:mrow>
                </m:msub>
                <m:mo>+</m:mo>
                <m:munderover>
                  <m:mo>∑</m:mo>
                  <m:mrow>
                    <m:mi>k</m:mi>
                    <m:mo>=</m:mo>
                    <m:mn>1</m:mn>
                  </m:mrow>
                  <m:mrow>
                    <m:mi>M</m:mi>
                    <m:mo>-</m:mo>
                    <m:mn>1</m:mn>
                  </m:mrow>
                </m:munderover>
                <m:mn>2</m:mn>
                <m:msub>
                  <m:mi>A</m:mi>
                  <m:mrow>
                    <m:mi>d</m:mi>
                    <m:mi>k</m:mi>
                  </m:mrow>
                </m:msub>
                <m:mo form="prefix">cos</m:mo>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mn>2</m:mn>
                  <m:mi>π</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>-</m:mo>
                    <m:mi>M</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mi>k</m:mi>
                  <m:mo>/</m:mo>
                  <m:mi>N</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mo>]</m:mo>
              </m:mrow>
              <m:mo>.</m:mo>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2258009">for <m:math overflow="scroll"><m:mrow><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>,</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mo>⋯</m:mo><m:mo>,</m:mo><m:mi>L</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>. This is used in (<cnxn target="uid11"/>), and is
the ideal impulse response that is truncated and shifted to give
a causal, symmetric <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math>.</para>
        <para id="id2258070">Use of the alternative equally-spaced sampling in (<cnxn target=""/>), which
has no sample at zero frequency, requires <m:math overflow="scroll"><m:mrow><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> be calculated from
(<cnxn target=""/>) and (<cnxn target=""/>). The Type 2 filters with even <m:math overflow="scroll"><m:mi>N</m:mi></m:math> are
developed in a similar
way and use the design formulas (<cnxn target=""/>) and (<cnxn target=""/>). These methods are
summarized by:</para>
        <para id="id2258120">
          <quote type="block">The filter design procedure for an odd-length Type 1
filter is to first design an odd-length-L FIR
filter by the frequency sampling method from
(<cnxn target=""/>) or (<cnxn target=""/>) or the IDFT, then to
symmetrically truncate it to the desired odd-length N
and shift it to make <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> causal.
To design an even-length Type 2 filter , start
with an even-length-L frequency-sampling design
from (<cnxn target=""/>) or (<cnxn target=""/>) or the IDFT and symmetrically
truncate and shift. The resulting length-N FIR filters are
optimal LS-error approximations to the desired
frequency response over the <m:math overflow="scroll"><m:mi>L</m:mi></m:math> frequency samples.</quote>
        </para>
        <para id="id2258174">This approach can also be applied to the general arbitrary phase FIR
filter design problem.</para>
      </section>
      <section id="uid14">
        <name>Weighted, Unevenly Sampled Discrete Least Squared Error
Filter Design by Solving Simultaneous Equations</name>
        <para id="id2258190">It is sometimes desirable to formulate the least squared error design
problem using unequally-spaced frequency samples and/or a weighting
function on the error. This is not possible using the IDFT or derived
formulas above and requires a different approach to the solution.</para>
        <para id="id2258197">Samples of the amplitude response derived for <m:math overflow="scroll"><m:mi>N</m:mi></m:math> odd in (<cnxn target=""/>) are given by</para>
        <equation id="uid15">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>A</m:mi>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:msub>
                  <m:mi>ω</m:mi>
                  <m:mi>k</m:mi>
                </m:msub>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>n</m:mi>
                  <m:mo>=</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
                <m:mi>M</m:mi>
              </m:munderover>
              <m:mn>2</m:mn>
              <m:mi>h</m:mi>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>M</m:mi>
                <m:mo>-</m:mo>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mspace width="0.166667em"/>
              <m:mo form="prefix">cos</m:mo>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:msub>
                  <m:mi>ω</m:mi>
                  <m:mi>k</m:mi>
                </m:msub>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mo>+</m:mo>
              <m:mi>h</m:mi>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>M</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2258317">for <m:math overflow="scroll"><m:mrow><m:mi>k</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>,</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mo>⋯</m:mo><m:mo>,</m:mo><m:mi>L</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>. This relates the <m:math overflow="scroll"><m:mi>L</m:mi></m:math> frequency
samples <m:math overflow="scroll"><m:mrow><m:mi>A</m:mi><m:mo>(</m:mo><m:msub><m:mi>ω</m:mi><m:mi>k</m:mi></m:msub><m:mo>)</m:mo></m:mrow></m:math> to the M+1 independent values of the symmetric
length-N impulse response h(n). In the design problem where the <m:math overflow="scroll"><m:msub><m:mi>A</m:mi><m:mi>k</m:mi></m:msub></m:math>
are given and the values for h(n) are to be found, this represents <m:math overflow="scroll"><m:mi>L</m:mi></m:math>
equations with M+1 unknowns. Because of the symmetries of <m:math overflow="scroll"><m:mrow><m:mi>A</m:mi><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:math>
shown in <cnxn target=""/>, only half of the <m:math overflow="scroll"><m:mi>L</m:mi></m:math> values of <m:math overflow="scroll"><m:msub><m:mi>A</m:mi><m:mi>k</m:mi></m:msub></m:math> are
independent; however, in some cases, to have proper weights on all <m:math overflow="scroll"><m:mi>L</m:mi></m:math>
samples, all must be calculated.</para>
        <para id="id2258467"><cnxn target="uid15"/> sampled at <m:math overflow="scroll"><m:mi>L</m:mi></m:math> arbitrary frequencies can be
written as a matrix equation</para>
        <equation id="uid16">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi mathvariant="bold">C</m:mi>
              <m:mi mathvariant="bold">a</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mi mathvariant="bold">A</m:mi>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2258519">where <m:math overflow="scroll"><m:mi>a</m:mi></m:math> is an <m:math overflow="scroll"><m:mrow><m:mi>M</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:math> length vector with elements which
are the first half of <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math>. <m:math overflow="scroll"><m:mi mathvariant="bold">C</m:mi></m:math> is an <m:math overflow="scroll"><m:mi>L</m:mi></m:math> by <m:math overflow="scroll"><m:mrow><m:mo>(</m:mo><m:mi>M</m:mi><m:mo>+</m:mo><m:mn>1</m:mn><m:mo>)</m:mo></m:mrow></m:math> matrix of the
cosine terms from (<cnxn target="uid15"/>), and <m:math overflow="scroll"><m:mi>A</m:mi></m:math> is a length-L vector of the
frequency samples <m:math overflow="scroll"><m:mrow><m:mi>A</m:mi><m:mo>(</m:mo><m:msub><m:mi>ω</m:mi><m:mi>k</m:mi></m:msub><m:mo>)</m:mo></m:mrow></m:math>.</para>
        <para id="id2258642">If the formula for the calculation of <m:math overflow="scroll"><m:mi>L</m:mi></m:math> values of the frequency
response of a length-N FIR filter in (<cnxn target="uid12"/>) is used to define an
error vector of differences as defined in (<cnxn target="uid4"/>) and the result is
written in the matrix formulation of (<cnxn target=""/>), the error becomes</para>
        <equation id="uid17">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi mathvariant="bold">C</m:mi>
              <m:mi mathvariant="bold">a</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mi mathvariant="bold">A</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:msub>
                <m:mi mathvariant="bold">A</m:mi>
                <m:mi mathvariant="bold">d</m:mi>
              </m:msub>
              <m:mo>+</m:mo>
              <m:mi mathvariant="bold">e</m:mi>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2258731">or</para>
        <equation id="uid18">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi mathvariant="bold">C</m:mi>
              <m:mi mathvariant="bold">a</m:mi>
              <m:mo>-</m:mo>
              <m:msub>
                <m:mi mathvariant="bold">A</m:mi>
                <m:mi mathvariant="bold">d</m:mi>
              </m:msub>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mi mathvariant="bold">e</m:mi>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2258785">where <m:math overflow="scroll"><m:mi mathvariant="bold">e</m:mi></m:math> is a vector of differences between the actual and desired
samples of the frequency response. The error measure defined in
(<cnxn target="uid6"/>) becomes the quadratic form</para>
        <equation id="uid19">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mrow>
                <m:msup>
                  <m:mi mathvariant="bold">e</m:mi>
                  <m:mi mathvariant="bold">T</m:mi>
                </m:msup>
                <m:mi mathvariant="bold">e</m:mi>
              </m:mrow>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2258849">For <m:math overflow="scroll"><m:mrow><m:mi>L</m:mi><m:mo>&gt;</m:mo><m:mi>N</m:mi></m:mrow></m:math>, equation (<cnxn target="uid16"/>) is over determined and cannot, in
general, be solved for <m:math overflow="scroll"><m:mi mathvariant="bold">a</m:mi></m:math>. The filter design error measure is the
norm of <m:math overflow="scroll"><m:mi mathvariant="bold">e</m:mi></m:math>, as given in (<cnxn target="uid19"/>). This error measure is
minimized by making <m:math overflow="scroll"><m:mi mathvariant="bold">e</m:mi></m:math> orthogonal to the columns of <m:math overflow="scroll"><m:mi mathvariant="bold">C</m:mi></m:math> in
(<cnxn target="uid18"/>). Multiplying both sides of (<cnxn target="uid17"/> by the transpose of
<m:math overflow="scroll"><m:mi mathvariant="bold">C</m:mi></m:math> gives</para>
        <equation id="uid20">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msup>
                <m:mi mathvariant="bold">C</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:mi mathvariant="bold">C</m:mi>
              <m:mi mathvariant="bold">a</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:msup>
                <m:mi mathvariant="bold">C</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:msub>
                <m:mi mathvariant="bold">A</m:mi>
                <m:mi mathvariant="bold">d</m:mi>
              </m:msub>
              <m:mo>+</m:mo>
              <m:msup>
                <m:mi mathvariant="bold">C</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:mi mathvariant="bold">e</m:mi>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2259031">In order for <m:math overflow="scroll"><m:mi>q</m:mi></m:math> to be minimum, <m:math overflow="scroll"><m:mi mathvariant="bold">e</m:mi></m:math> must be orthogonal to the
columns of <m:math overflow="scroll"><m:mi mathvariant="bold">C</m:mi></m:math> and, therefore, <m:math overflow="scroll"><m:mrow><m:msup><m:mi mathvariant="bold">C</m:mi><m:mi mathvariant="bold">T</m:mi></m:msup><m:mi mathvariant="bold">e</m:mi></m:mrow></m:math> must be zero. Hence,
the optimal <m:math overflow="scroll"><m:mi mathvariant="bold">a</m:mi></m:math> must satisfy the “normal equations"
<cnxn target="bid3"/>, <cnxn target="bid4"/>, <cnxn target="bid5"/> which are</para>
        <equation id="uid21">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msup>
                <m:mi mathvariant="bold">C</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:mi mathvariant="bold">C</m:mi>
              <m:mi mathvariant="bold">a</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:msup>
                <m:mi mathvariant="bold">C</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:msub>
                <m:mi mathvariant="bold">A</m:mi>
                <m:mi mathvariant="bold">d</m:mi>
              </m:msub>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2259187">and which can be rewritten in terms of the pseudo-inverse
<cnxn target="bid3"/>, <cnxn target="bid5"/> as</para>
        <equation id="uid22">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi mathvariant="bold">a</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:msup>
                <m:mrow>
                  <m:mo>[</m:mo>
                  <m:msup>
                    <m:mi mathvariant="bold">C</m:mi>
                    <m:mi mathvariant="bold">T</m:mi>
                  </m:msup>
                  <m:mi mathvariant="bold">C</m:mi>
                  <m:mo>]</m:mo>
                </m:mrow>
                <m:mrow>
                  <m:mo>-</m:mo>
                  <m:mn mathvariant="bold">1</m:mn>
                </m:mrow>
              </m:msup>
              <m:msup>
                <m:mi mathvariant="bold">C</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:msub>
                <m:mi mathvariant="bold">A</m:mi>
                <m:mi mathvariant="bold">d</m:mi>
              </m:msub>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2259286">If <m:math overflow="scroll"><m:mrow><m:mi>L</m:mi><m:mspace width="0.166667em"/><m:mo>=</m:mo><m:mspace width="0.166667em"/><m:mi>N</m:mi></m:mrow></m:math>, this becomes the regular frequency-sampling problem
and can be solved with zero error. For the case of interest in
this section, where <m:math overflow="scroll"><m:mrow><m:mi>L</m:mi><m:mo>&gt;</m:mo><m:mi>N</m:mi></m:mrow></m:math>, there are still only <m:math overflow="scroll"><m:mrow><m:mi>M</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:math> equations to be
solved. For <m:math overflow="scroll"><m:mrow><m:mi>L</m:mi><m:mo>&gt;</m:mo><m:mo>&gt;</m:mo><m:mi>N</m:mi></m:mrow></m:math>, equation (<cnxn target="uid12"/>) may be ill-conditioned, and
(<cnxn target="uid22"/>) should not be used to solve them. Special methods will be
necessary to avoid serious numerical problems <cnxn target="bid5"/>.</para>
        <para id="id2259376">If a weighted error function is desired, (<cnxn target="uid6"/>) is modified to give</para>
        <equation id="uid23">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mfrac>
                <m:mn>1</m:mn>
                <m:mi>L</m:mi>
              </m:mfrac>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>k</m:mi>
                  <m:mo>=</m:mo>
                  <m:mn>0</m:mn>
                </m:mrow>
                <m:mrow>
                  <m:mi>L</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:munderover>
              <m:msub>
                <m:mi>W</m:mi>
                <m:mi>k</m:mi>
              </m:msub>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:mi>A</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mi>k</m:mi>
                    </m:msub>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>-</m:mo>
                  <m:msub>
                    <m:mi>A</m:mi>
                    <m:mi>d</m:mi>
                  </m:msub>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mi>k</m:mi>
                    </m:msub>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2259492">The normal equations of (<cnxn target="uid21"/>) become</para>
        <equation id="uid24">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msup>
                <m:mi mathvariant="bold">C</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:mi mathvariant="bold">W</m:mi>
              <m:mi mathvariant="bold">C</m:mi>
              <m:mi mathvariant="bold">a</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:msup>
                <m:mi mathvariant="bold">C</m:mi>
                <m:mi mathvariant="bold">T</m:mi>
              </m:msup>
              <m:mi mathvariant="bold">W</m:mi>
              <m:msub>
                <m:mi mathvariant="bold">A</m:mi>
                <m:mi mathvariant="bold">d</m:mi>
              </m:msub>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2259576">where <m:math overflow="scroll"><m:mi>W</m:mi></m:math> is a positive-definite matrix of the weights. If zero weights
are desired, the effect is be achieved by removing those frequencies from
the set of <m:math overflow="scroll"><m:mi>L</m:mi></m:math> frequencies, not by using a zero value weight which would
violate the vector-space conditions of a well-posed minimization problem.</para>
        <para id="id2259604">Although developed here for the linear-phase filter, (<cnxn target="uid24"/>) is a
very general design approach for the FIR filter that allows arbitrary
phase, as well as uneven frequency sampling and a weighting function in
the error definition. For the arbitrary phase case, a complex <m:math overflow="scroll"><m:mi mathvariant="bold">F</m:mi></m:math> is
obtained from sampling (<cnxn target=""/>) and the full <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> is used. For the
special case of the equally-spaced frequency samples and linear- phase
filter with unity weighting, the solution of (<cnxn target="uid21"/>) or (<cnxn target="uid24"/>)
is the same as given by the frequency sampling design formulas.</para>
        <para id="id2259659">One of the important uses of the unequally spaced frequency samples is to
create a transition band between the pass and stopbands where there are no
samples. This “don't care" band does not contribute to the error measure q
and allows better approximation to occur over the pass and stopbands.</para>
        <para id="id2259673">Of the many ways to solve (<cnxn target="uid21"/>) or (<cnxn target="uid24"/>), one of the easiest and most
reliable is the use of Matlab
,
which has a special command to solve this least-mean-squared error
problem. Equation (<cnxn target="uid22"/>) should not be solved directly. For large <m:math overflow="scroll"><m:mi>L</m:mi></m:math>, it is
ill-conditioned and a direct solution will probably have large errors.
Matlab
 uses special algorithms to minimize these numerical errors.</para>
        <para id="id2259716">This approach was applied to the same problems that were solved by
frequency sampling in the previous section. For <m:math overflow="scroll"><m:mrow><m:mi>N</m:mi><m:mo>=</m:mo><m:mi>L</m:mi></m:mrow></m:math>, the same results are
obtained, thus verifying the theoretical prediction. As <m:math overflow="scroll"><m:mi>L</m:mi></m:math> becomes larger
compared to <m:math overflow="scroll"><m:mi>N</m:mi></m:math>, more control is exerted over the behavior between the
original sample points. As <m:math overflow="scroll"><m:mi>L</m:mi></m:math> becomes large compared to <m:math overflow="scroll"><m:mi>N</m:mi></m:math>, the solution
approaches the same results as obtained where the
error is defined as a continuous function of frequency and the integral of
the squared error is minimized.
Although the solution of the normal equations is a powerful and flexible
technique, it can be slow, have numerical problems, and require large
amounts of computer memory.</para>
      </section>
      <section id="uid25">
        <name>Examples of Discrete Least Squared Error Filter Design</name>
        <para id="id2259789">Here we will give examples of several least squared error designs of FIR filters.</para>
        <figure id="uid26" orient="horizontal">
          <media type="application/postscript" src="figDLSE.eps">
            <media type="image/png" src="figDLSE.png"><!-- NOTE: width parameter changes size of image online (pixels). original width is 419. --><param name="width" value="419"/></media>
          </media>
          <caption>Frequency Response of Length-15 FIR Filter Designed by Least Squared Error</caption>
        </figure>
        <para id="id2259809">As for the frequency sampling design, we see a good lowpass filter
frequency response with the actual amplitude interpolating the desired
values at different points from the frequency sampling example in
<cnxn target="uid26"/> even though the length and band edge are the same.
Notice there is less over shoot but more ripple near <m:math overflow="scroll"><m:mrow><m:mi>f</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math>. The Gibbs
phenomenon is the same as for the Fourier series.</para>
        <para id="id2259840">If a transition band is introduces in the ideal amplitude response between <m:math overflow="scroll"><m:mrow><m:mi>f</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>4</m:mn></m:mrow></m:math> and <m:math overflow="scroll"><m:mrow><m:mi>f</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>6</m:mn></m:mrow></m:math>
with a straight line, the overshoot is reduced significantly but with a slightly slower transition from
the pass to stop band. This is illustrated in <cnxn target="uid27"/>.</para>
        <figure id="uid27" orient="horizontal">
          <media type="application/postscript" src="figDLSEtb.eps">
            <media type="image/png" src="figDLSEtb.png"><!-- NOTE: width parameter changes size of image online (pixels). original width is 419. --><param name="width" value="419"/></media>
          </media>
          <caption>Frequency Response of Length-15 FIR Filter with a Transition Band Designed by Least Squared Error</caption>
        </figure>
      </section>
    </section>
    <section id="uid28">
      <name>Continuous Frequency Definition of Error</name>
      <para id="id2259915">Because the energy of a signal is the integral of the sum of the squares
of the Fourier transform magnitude and because specifications are usually
given in the frequency domain, a very reasonable error measure to
minimize is the integral squared error given by</para>
      <equation id="uid29">
        <m:math mode="display" overflow="scroll">
          <m:mrow>
            <m:mi>q</m:mi>
            <m:mspace width="0.166667em"/>
            <m:mo>=</m:mo>
            <m:mspace width="0.166667em"/>
            <m:mfrac>
              <m:mn>1</m:mn>
              <m:mi>π</m:mi>
            </m:mfrac>
            <m:msubsup>
              <m:mo>∫</m:mo>
              <m:mn>0</m:mn>
              <m:mi>π</m:mi>
            </m:msubsup>
            <m:msup>
              <m:mrow>
                <m:mo>|</m:mo>
                <m:msub>
                  <m:mi>A</m:mi>
                  <m:mi>d</m:mi>
                </m:msub>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mo>-</m:mo>
                <m:mi>A</m:mi>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mo>|</m:mo>
              </m:mrow>
              <m:mn>2</m:mn>
            </m:msup>
            <m:mspace width="0.166667em"/>
            <m:mi>d</m:mi>
            <m:mi>ω</m:mi>
          </m:mrow>
        </m:math>
      </equation>
      <para id="id2260009">where <m:math overflow="scroll"><m:mrow><m:msub><m:mi>A</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> is the desired ideal amplitude response,
<m:math overflow="scroll"><m:mrow><m:mi>A</m:mi><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow><m:mo>=</m:mo><m:msub><m:mo>∑</m:mo><m:mi>n</m:mi></m:msub><m:mi>a</m:mi><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow><m:mspace width="0.166667em"/><m:mo form="prefix">cos</m:mo><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mrow><m:mo>(</m:mo><m:mi>M</m:mi><m:mo>-</m:mo><m:mi>N</m:mi><m:mo>)</m:mo></m:mrow><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> is the achieved amplitude
response with the length <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> related to <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> by (<cnxn target=""/>). This
integral squared error is approximated by the discrete squared error
defined in (<cnxn target="uid29"/>) for <m:math overflow="scroll"><m:mrow><m:mi>L</m:mi><m:mo>&gt;</m:mo><m:mo>&gt;</m:mo><m:mi>N</m:mi></m:mrow></m:math> which in some cases is much easier to
minimize. However for some very useful cases, formulas can be found
for <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> that minimize (<cnxn target="uid29"/>) and that is what we will be
considering in this section.</para>
      <section id="uid30">
        <name>The Unweighted Least Integral Squared Error Approximation</name>
        <para id="id2260197">If the error measure is the unweighted integral squared error defined
in (<cnxn target="uid29"/>), Parseval's theorem gives the equivalent time-domain
formulation for the error to be</para>
        <equation id="uid31">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>n</m:mi>
                  <m:mo>=</m:mo>
                  <m:mo>-</m:mo>
                  <m:mi>∞</m:mi>
                </m:mrow>
                <m:mi>∞</m:mi>
              </m:munderover>
              <m:mrow>
                <m:mo>|</m:mo>
              </m:mrow>
              <m:msub>
                <m:mi>h</m:mi>
                <m:mi>d</m:mi>
              </m:msub>
              <m:msup>
                <m:mrow>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>-</m:mo>
                  <m:mi>h</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mfrac>
                <m:mn>1</m:mn>
                <m:mi>π</m:mi>
              </m:mfrac>
              <m:msubsup>
                <m:mo>∫</m:mo>
                <m:mn>0</m:mn>
                <m:mi>π</m:mi>
              </m:msubsup>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:msub>
                    <m:mi>A</m:mi>
                    <m:mi>d</m:mi>
                  </m:msub>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>ω</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>-</m:mo>
                  <m:mi>A</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>ω</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
              <m:mspace width="0.166667em"/>
              <m:mi>d</m:mi>
              <m:mi>ω</m:mi>
              <m:mo>.</m:mo>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2260359">In general, this ideal response is
infinite in duration and, therefore, cannot be realized exactly by
an actual FIR filter.</para>
        <para id="id2260367">As was done in the case of the discrete error measure, we break the
infinite sum in (<cnxn target="uid31"/>) into two parts, one of which depends on
<m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:math> and the other does not.</para>
        <equation id="uid32">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>n</m:mi>
                  <m:mo>=</m:mo>
                  <m:mo>-</m:mo>
                  <m:mi>M</m:mi>
                </m:mrow>
                <m:mi>M</m:mi>
              </m:munderover>
              <m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo>|</m:mo>
              </m:mrow>
              <m:msub>
                <m:mi>h</m:mi>
                <m:mi>d</m:mi>
              </m:msub>
              <m:msup>
                <m:mrow>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>-</m:mo>
                  <m:mi>h</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
              <m:mspace width="0.166667em"/>
              <m:mo>+</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mspace width="0.166667em"/>
              <m:mn>2</m:mn>
              <m:munderover>
                <m:mo>∑</m:mo>
                <m:mrow>
                  <m:mi>n</m:mi>
                  <m:mo>=</m:mo>
                  <m:mi>M</m:mi>
                  <m:mo>+</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
                <m:mi>∞</m:mi>
              </m:munderover>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:msub>
                    <m:mi>h</m:mi>
                    <m:mi>d</m:mi>
                  </m:msub>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2260538">Again, we see that the minimum <m:math overflow="scroll"><m:mi>q</m:mi></m:math> is achieved by using <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow><m:mo>=</m:mo><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math>
for <m:math overflow="scroll"><m:mrow><m:mo>-</m:mo><m:mi>M</m:mi><m:mo>≤</m:mo><m:mi>n</m:mi><m:mo>≤</m:mo><m:mi>M</m:mi></m:mrow></m:math>. In other words, the infinitely long <m:math overflow="scroll"><m:mrow><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> is
symmetrically truncated to give the optimal least integral squared error
approximation. The problem then becomes one of finding the <m:math overflow="scroll"><m:mrow><m:msub><m:mi>h</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> to
truncate.</para>
        <para id="id2260658">Here the integral definition of approximation error is used. This is
usually what we really want, but in some cases the integrals can not be
carried out and the sampled method above must be used.</para>
        <section id="uid33">
          <name>Ideal Constant Gain Passband Lowpass Filter</name>
          <para id="id2260676">Here we assume the simplest ideal lowpass single band FIR filter to have
unity passband gain for <m:math overflow="scroll"><m:mrow><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>ω</m:mi><m:mn>0</m:mn></m:msub></m:mrow></m:math> and zero stopband gain for
<m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>0</m:mn></m:msub><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:mi>π</m:mi></m:mrow></m:math> similar to those in <cnxn target=""/>a and <cnxn target="uid26"/>.
This gives
</para>
          <equation id="element-610"><m:math>
<m:msub>
<m:mi>A</m:mi>
<m:mi>d</m:mi>
</m:msub>
<m:mo>(</m:mo>
<m:mi>ω</m:mi>
<m:mo>)</m:mo>
<m:mo>=</m:mo>
<m:msubsup>
<m:mo>{</m:mo>
<m:mrow>
<m:mn>0</m:mn>
<m:mspace width="10pt"/>
<m:reln><m:lt/>
<m:reln><m:lt/>
<m:mrow>
<m:msub>
<m:mi>ω</m:mi>
<m:mn>0</m:mn>
</m:msub>
</m:mrow>
<m:mrow>
<m:mi>ω</m:mi>
</m:mrow>
</m:reln>
<m:mrow>
<m:mi>π</m:mi>
</m:mrow>
</m:reln>
</m:mrow>
<m:mrow>
<m:mn>1</m:mn>
<m:mspace width="10pt"/>
<m:reln><m:lt/>
<m:reln><m:lt/>
<m:mrow>
<m:mn>0</m:mn>
</m:mrow>
<m:mrow>
<m:mi>ω</m:mi>
</m:mrow>
</m:reln>
<m:mrow>
<m:msub>
<m:mi>ω</m:mi>
<m:mn>0</m:mn>
</m:msub>
</m:mrow>
</m:reln>
</m:mrow>
</m:msubsup>
</m:math>
</equation><para id="element-219">as the ideal desired amplitude response. The ideal shifted filter
coefficients are the inverse DTFT from (<cnxn target=""/>) of this amplitude which
for <m:math overflow="scroll"><m:mi>N</m:mi></m:math> odd are given by</para><equation id="uid35">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:msub>
                  <m:mover accent="true">
                    <m:mi>h</m:mi>
                    <m:mo>^</m:mo>
                  </m:mover>
                  <m:mi>d</m:mi>
                </m:msub>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mn>1</m:mn>
                  <m:mi>π</m:mi>
                </m:mfrac>
                <m:msubsup>
                  <m:mo>∫</m:mo>
                  <m:mn>0</m:mn>
                  <m:mi>π</m:mi>
                </m:msubsup>
                <m:msub>
                  <m:mi>A</m:mi>
                  <m:mi>d</m:mi>
                </m:msub>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo form="prefix">cos</m:mo>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mi>d</m:mi>
                <m:mi>ω</m:mi>
              </m:mrow>
            </m:math>
          </equation>
          <equation id="uid36">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:mo>=</m:mo>
                <m:mfrac>
                  <m:mn>1</m:mn>
                  <m:mi>π</m:mi>
                </m:mfrac>
                <m:msubsup>
                  <m:mo>∫</m:mo>
                  <m:mn>0</m:mn>
                  <m:msub>
                    <m:mi>ω</m:mi>
                    <m:mn>0</m:mn>
                  </m:msub>
                </m:msubsup>
                <m:mo form="prefix">cos</m:mo>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mi>d</m:mi>
                <m:mi>ω</m:mi>
                <m:mo>=</m:mo>
                <m:mfenced separators="" open="(" close=")">
                  <m:mfrac>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mi>π</m:mi>
                  </m:mfrac>
                </m:mfenced>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mrow>
                    <m:mo form="prefix">sin</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mrow>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mi>n</m:mi>
                  </m:mrow>
                </m:mfrac>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2260973">which is sometimes called a “sinc" function. Note <m:math overflow="scroll"><m:mrow><m:msub><m:mover accent="true"><m:mi>h</m:mi><m:mo>^</m:mo></m:mover><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> is
generally infinite in length. This is now symmetrically
truncated and shifted by <m:math overflow="scroll"><m:mrow><m:mi>M</m:mi><m:mo>=</m:mo><m:mo>(</m:mo><m:mi>N</m:mi><m:mo>-</m:mo><m:mn>1</m:mn><m:mo>)</m:mo><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> to give the optimal, causal length-<m:math overflow="scroll"><m:mi>N</m:mi></m:math> FIR
filter coefficients as</para>
          <equation id="uid37">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:mi>h</m:mi>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfenced separators="" open="(" close=")">
                  <m:mfrac>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mi>π</m:mi>
                  </m:mfrac>
                </m:mfenced>
                <m:mfrac>
                  <m:mrow>
                    <m:mo form="prefix">sin</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>-</m:mo>
                      <m:mi>M</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mrow>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>-</m:mo>
                      <m:mi>M</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                </m:mfrac>
                <m:mspace width="4.pt"/>
                <m:mspace width="4.pt"/>
                <m:mspace width="4.pt"/>
                <m:mtext>for</m:mtext>
                <m:mspace width="4.pt"/>
                <m:mrow>
                  <m:mn>0</m:mn>
                  <m:mo>≤</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>≤</m:mo>
                  <m:mi>N</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2261183">and <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math> otherwise.
The corresponding derivation for an even length starts with the inverse
DTFT in (<cnxn target=""/>) for a shifted even length filter is</para>
          <equation id="uid38">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:msub>
                  <m:mover accent="true">
                    <m:mi>h</m:mi>
                    <m:mo>^</m:mo>
                  </m:mover>
                  <m:mi>d</m:mi>
                </m:msub>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mn>1</m:mn>
                  <m:mi>π</m:mi>
                </m:mfrac>
                <m:msubsup>
                  <m:mo>∫</m:mo>
                  <m:mn>0</m:mn>
                  <m:mi>π</m:mi>
                </m:msubsup>
                <m:msub>
                  <m:mi>A</m:mi>
                  <m:mi>d</m:mi>
                </m:msub>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo form="prefix">cos</m:mo>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>+</m:mo>
                    <m:mn>1</m:mn>
                    <m:mo>/</m:mo>
                    <m:mn>2</m:mn>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mi>d</m:mi>
                <m:mi>ω</m:mi>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfenced separators="" open="(" close=")">
                  <m:mfrac>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mi>π</m:mi>
                  </m:mfrac>
                </m:mfenced>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mrow>
                    <m:mo form="prefix">sin</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>+</m:mo>
                      <m:mn>1</m:mn>
                      <m:mo>/</m:mo>
                      <m:mn>2</m:mn>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mrow>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>+</m:mo>
                      <m:mn>1</m:mn>
                      <m:mo>/</m:mo>
                      <m:mn>2</m:mn>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                </m:mfrac>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2261413">which when truncated and shifted by <m:math overflow="scroll"><m:mrow><m:mi>N</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> gives the same formula as for the
odd length design in (<cnxn target="uid37"/>) but one should note that <m:math overflow="scroll"><m:mrow><m:mi>M</m:mi><m:mo>=</m:mo><m:mo>(</m:mo><m:mi>N</m:mi><m:mo>-</m:mo><m:mn>1</m:mn><m:mo>)</m:mo><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> is not
an integer for an even <m:math overflow="scroll"><m:mi>N</m:mi></m:math>.</para>
        </section>
        <section id="uid39">
          <name>Ideal Linearly Increasing Gain Passband Lowpass Filter</name>
          <para id="id2261487">We now derive the design formula for a filter with an ideal amplitude
response that is a linearly increasing function in the passband rather
than a constant as was assumed above. This ideal amplitude response is
given by
and illustrated in <cnxn target="uid42"/>
For <m:math overflow="scroll"><m:mi>N</m:mi></m:math> odd, the ideal infinitely long shifted filter coefficients are the
inverse DTFT of this amplitude given by</para>
          <equation id="element-558"><m:math>
<m:msub>
<m:mi>A</m:mi>
<m:mi>d</m:mi>
</m:msub>
<m:mo>(</m:mo>
<m:mi>ω</m:mi>
<m:mo>)</m:mo>
<m:mo>=</m:mo>
<m:msubsup>
<m:mo>{</m:mo>
<m:mrow>
<m:mn>0</m:mn>
<m:mspace width="10pt"/>
<m:reln><m:lt/>
<m:reln><m:lt/>
<m:mrow>
<m:msub>
<m:mi>ω</m:mi>
<m:mn>0</m:mn>
</m:msub>
</m:mrow>
<m:mrow>
<m:mi>ω</m:mi>
</m:mrow>
</m:reln>
<m:mrow>
<m:mi>π</m:mi>
</m:mrow>
</m:reln>
</m:mrow>
<m:mrow>
<m:mfrac>
<m:mn>1</m:mn>
<m:mo>π</m:mo>
</m:mfrac>
<m:mi>ω</m:mi>
<m:mspace width="10pt"/>
<m:reln><m:lt/>
<m:reln><m:lt/>
<m:mrow>
<m:mn>0</m:mn>
</m:mrow>
<m:mrow>
<m:mi>ω</m:mi>
</m:mrow>
</m:reln>
<m:mrow>
<m:msub>
<m:mi>ω</m:mi>
<m:mn>0</m:mn>
</m:msub>
</m:mrow>
</m:reln>
</m:mrow>
</m:msubsup>
</m:math>
</equation><equation id="uid40">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:msub>
                  <m:mover accent="true">
                    <m:mi>h</m:mi>
                    <m:mo>^</m:mo>
                  </m:mover>
                  <m:mi>d</m:mi>
                </m:msub>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mn>1</m:mn>
                  <m:mi>π</m:mi>
                </m:mfrac>
                <m:msubsup>
                  <m:mo>∫</m:mo>
                  <m:mn>0</m:mn>
                  <m:msub>
                    <m:mi>ω</m:mi>
                    <m:mn>0</m:mn>
                  </m:msub>
                </m:msubsup>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mfrac>
                    <m:mi>ω</m:mi>
                    <m:mi>π</m:mi>
                  </m:mfrac>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo form="prefix">cos</m:mo>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mi>d</m:mi>
                <m:mi>ω</m:mi>
                <m:mo>=</m:mo>
                <m:mfrac>
                  <m:mrow>
                    <m:mo form="prefix">cos</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                    <m:mo>-</m:mo>
                    <m:mn>1</m:mn>
                  </m:mrow>
                  <m:mrow>
                    <m:msup>
                      <m:mi>π</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                    <m:msup>
                      <m:mi>n</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                  </m:mrow>
                </m:mfrac>
                <m:mo>+</m:mo>
                <m:mfrac>
                  <m:mrow>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mo form="prefix">sin</m:mo>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:msub>
                        <m:mi>ω</m:mi>
                        <m:mn>0</m:mn>
                      </m:msub>
                      <m:mi>n</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                  <m:mrow>
                    <m:msup>
                      <m:mi>π</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                    <m:mi>n</m:mi>
                  </m:mrow>
                </m:mfrac>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2261706">with the indeterminate <m:math overflow="scroll"><m:mrow><m:msub><m:mover accent="true"><m:mi>h</m:mi><m:mo>^</m:mo></m:mover><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mn>0</m:mn><m:mo>)</m:mo></m:mrow><m:mo>=</m:mo><m:mfrac><m:msubsup><m:mi>ω</m:mi><m:mn>0</m:mn><m:mn>2</m:mn></m:msubsup><m:mrow><m:mn>2</m:mn><m:msup><m:mi>π</m:mi><m:mn>2</m:mn></m:msup></m:mrow></m:mfrac></m:mrow></m:math>. This is now
truncated and shifted by <m:math overflow="scroll"><m:mrow><m:mi>M</m:mi><m:mo>=</m:mo><m:mo>(</m:mo><m:mi>N</m:mi><m:mo>-</m:mo><m:mn>1</m:mn><m:mo>)</m:mo><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> to give the optimal, causal length-<m:math overflow="scroll"><m:mi>N</m:mi></m:math> FIR
filter coefficients as</para>
          <equation id="uid41">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:mi>h</m:mi>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mrow>
                    <m:mo form="prefix">cos</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>-</m:mo>
                      <m:mi>M</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mo>)</m:mo>
                    <m:mo>-</m:mo>
                    <m:mn>1</m:mn>
                  </m:mrow>
                  <m:mrow>
                    <m:msup>
                      <m:mi>π</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                    <m:msup>
                      <m:mrow>
                        <m:mo>(</m:mo>
                        <m:mi>n</m:mi>
                        <m:mo>-</m:mo>
                        <m:mi>M</m:mi>
                        <m:mo>)</m:mo>
                      </m:mrow>
                      <m:mn>2</m:mn>
                    </m:msup>
                  </m:mrow>
                </m:mfrac>
                <m:mo>+</m:mo>
                <m:mfrac>
                  <m:mrow>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mo form="prefix">sin</m:mo>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:msub>
                        <m:mi>ω</m:mi>
                        <m:mn>0</m:mn>
                      </m:msub>
                      <m:mrow>
                        <m:mo>(</m:mo>
                        <m:mi>n</m:mi>
                        <m:mo>-</m:mo>
                        <m:mi>M</m:mi>
                        <m:mo>)</m:mo>
                      </m:mrow>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                  <m:mrow>
                    <m:msup>
                      <m:mi>π</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>-</m:mo>
                      <m:mi>M</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                </m:mfrac>
                <m:mspace width="4.pt"/>
                <m:mspace width="4.pt"/>
                <m:mspace width="4.pt"/>
                <m:mtext>for</m:mtext>
                <m:mspace width="4.pt"/>
                <m:mrow>
                  <m:mn>0</m:mn>
                  <m:mo>≤</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>≤</m:mo>
                  <m:mi>N</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2261992">and <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math> otherwise.
The corresponding derivation for an even length starts with the inverse
DTFT for a shifted even length filter in (<cnxn target=""/>) and after shifting by
<m:math overflow="scroll"><m:mrow><m:mi>N</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> gives the same result as (<cnxn target="uid41"/>).</para>
          <figure id="uid42" orient="horizontal">
            <media type="application/postscript" src="figLin.eps">
              <media type="image/png" src="figLin.png"><!-- NOTE: width parameter changes size of image online (pixels). original width is 419. --><param name="width" value="419"/></media>
            </media>
            <caption>Ideal Frequency Response of an FIR Filter with Increasing Gain in
the Passband and Lowpass Cutoff</caption>
          </figure>
        </section>
        <section id="uid43">
          <name>Ideal Differentiator plus Lowpass
Filter</name>
          <para id="id2262070">Fortunately the inverse DTFT for an ideal differentiator combined with a
lowpass filter can also be analytically evaluated. The ideal amplitude
response is the same as (<cnxn target="element-558"/>) and <cnxn target="uid42"/> but, since this case has an odd
symmetric impulse response, the inverse DTFT uses sine functions which for
odd <m:math overflow="scroll"><m:mi>N</m:mi></m:math> gives</para>
          <equation id="uid45">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:msub>
                  <m:mover accent="true">
                    <m:mi>h</m:mi>
                    <m:mo>^</m:mo>
                  </m:mover>
                  <m:mi>d</m:mi>
                </m:msub>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mn>1</m:mn>
                  <m:mi>π</m:mi>
                </m:mfrac>
                <m:msubsup>
                  <m:mo>∫</m:mo>
                  <m:mn>0</m:mn>
                  <m:msub>
                    <m:mi>ω</m:mi>
                    <m:mn>0</m:mn>
                  </m:msub>
                </m:msubsup>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mfrac>
                    <m:mn>1</m:mn>
                    <m:mi>π</m:mi>
                  </m:mfrac>
                  <m:mi>ω</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo form="prefix">sin</m:mo>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mi>d</m:mi>
                <m:mi>ω</m:mi>
                <m:mo>=</m:mo>
                <m:mfrac>
                  <m:mrow>
                    <m:mo form="prefix">sin</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mrow>
                    <m:msup>
                      <m:mi>π</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                    <m:msup>
                      <m:mi>n</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                  </m:mrow>
                </m:mfrac>
                <m:mo>-</m:mo>
                <m:mfrac>
                  <m:mrow>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mo form="prefix">cos</m:mo>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:msub>
                        <m:mi>ω</m:mi>
                        <m:mn>0</m:mn>
                      </m:msub>
                      <m:mi>n</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                  <m:mrow>
                    <m:msup>
                      <m:mi>π</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                    <m:mi>n</m:mi>
                  </m:mrow>
                </m:mfrac>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2262284">with the indeterminate <m:math overflow="scroll"><m:mrow><m:msub><m:mover accent="true"><m:mi>h</m:mi><m:mo>^</m:mo></m:mover><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mn>0</m:mn><m:mo>)</m:mo></m:mrow><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math>. This is now
truncated and shifted by <m:math overflow="scroll"><m:mrow><m:mi>M</m:mi><m:mo>=</m:mo><m:mo>(</m:mo><m:mi>N</m:mi><m:mo>-</m:mo><m:mn>1</m:mn><m:mo>)</m:mo><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> to give the optimal, causal length-<m:math overflow="scroll"><m:mi>N</m:mi></m:math> FIR
filter coefficients as</para>
          <equation id="uid46">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:mi>h</m:mi>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mo>=</m:mo>
                <m:mfrac>
                  <m:mrow>
                    <m:mo form="prefix">sin</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>-</m:mo>
                      <m:mi>M</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mrow>
                    <m:msup>
                      <m:mi>π</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                    <m:msup>
                      <m:mrow>
                        <m:mo>(</m:mo>
                        <m:mi>n</m:mi>
                        <m:mo>-</m:mo>
                        <m:mi>M</m:mi>
                        <m:mo>)</m:mo>
                      </m:mrow>
                      <m:mn>2</m:mn>
                    </m:msup>
                  </m:mrow>
                </m:mfrac>
                <m:mo>-</m:mo>
                <m:mfrac>
                  <m:mrow>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mo form="prefix">cos</m:mo>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:msub>
                        <m:mi>ω</m:mi>
                        <m:mn>0</m:mn>
                      </m:msub>
                      <m:mrow>
                        <m:mo>(</m:mo>
                        <m:mi>n</m:mi>
                        <m:mo>-</m:mo>
                        <m:mi>M</m:mi>
                        <m:mo>)</m:mo>
                      </m:mrow>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                  <m:mrow>
                    <m:msup>
                      <m:mi>π</m:mi>
                      <m:mn>2</m:mn>
                    </m:msup>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>-</m:mo>
                      <m:mi>M</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                  </m:mrow>
                </m:mfrac>
                <m:mspace width="4.pt"/>
                <m:mspace width="4.pt"/>
                <m:mspace width="4.pt"/>
                <m:mtext>for</m:mtext>
                <m:mspace width="4.pt"/>
                <m:mrow>
                  <m:mn>0</m:mn>
                  <m:mo>≤</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>≤</m:mo>
                  <m:mi>N</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2262539">and <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math> otherwise.
Again the corresponding derivation for an even length gives the same
result as in (<cnxn target="uid46"/>). Note this very general single formula includes
as special cases the odd and even length full band (<m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>0</m:mn></m:msub><m:mo>=</m:mo><m:mi>π</m:mi></m:mrow></m:math>)
differentiator given in <cnxn target="bid6"/>. Also note that for a full band
differentiator, an even length is much preferred because of the zero at
<m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mi>π</m:mi></m:mrow></m:math> for an odd length. However, for the differentiator with a
lowpass filter, the zero aids in the lowpass filtering and, therefore,
might be an advantage.</para>
        </section>
        <section id="uid47">
          <name>Hilbert Transformer</name>
          <para id="id2262631">The inverse DTFT for an ideal Hilbert transform <cnxn target="bid7"/> combined with a
lowpass filter can also be analytically evaluated. The ideal amplitude
response is the same as (<cnxn target="element-610"/>) but with a constant phase shift of
<m:math overflow="scroll"><m:mrow><m:mi>ϕ</m:mi><m:mo>=</m:mo><m:mi>π</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math>. Since this case has an odd symmetric impulse response,
the inverse DTFT uses sine functions which for odd <m:math overflow="scroll"><m:mi>N</m:mi></m:math> which gives</para>
          <equation id="uid49">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:msub>
                  <m:mover accent="true">
                    <m:mi>h</m:mi>
                    <m:mo>^</m:mo>
                  </m:mover>
                  <m:mi>d</m:mi>
                </m:msub>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mn>1</m:mn>
                  <m:mi>π</m:mi>
                </m:mfrac>
                <m:msubsup>
                  <m:mo>∫</m:mo>
                  <m:mn>0</m:mn>
                  <m:msub>
                    <m:mi>ω</m:mi>
                    <m:mn>0</m:mn>
                  </m:msub>
                </m:msubsup>
                <m:mo form="prefix">sin</m:mo>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mi>d</m:mi>
                <m:mi>ω</m:mi>
                <m:mo>=</m:mo>
                <m:mfrac>
                  <m:mrow>
                    <m:mn>1</m:mn>
                    <m:mo>-</m:mo>
                    <m:mo form="prefix">cos</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mi>n</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mrow>
                    <m:mi>π</m:mi>
                    <m:mi>n</m:mi>
                  </m:mrow>
                </m:mfrac>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2262798">with the indeterminate <m:math overflow="scroll"><m:mrow><m:msub><m:mover accent="true"><m:mi>h</m:mi><m:mo>^</m:mo></m:mover><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mn>0</m:mn><m:mo>)</m:mo></m:mrow><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math>. This is now truncated and shifted
by <m:math overflow="scroll"><m:mrow><m:mi>M</m:mi><m:mo>=</m:mo><m:mo>(</m:mo><m:mi>N</m:mi><m:mo>-</m:mo><m:mn>1</m:mn><m:mo>)</m:mo><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> to give the optimal, causal length-<m:math overflow="scroll"><m:mi>N</m:mi></m:math> FIR filter coefficients as</para>
          <equation id="uid50">
            <m:math mode="display" overflow="scroll">
              <m:mrow>
                <m:mi>h</m:mi>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mspace width="0.166667em"/>
                <m:mo>=</m:mo>
                <m:mspace width="0.166667em"/>
                <m:mfrac>
                  <m:mrow>
                    <m:mn>1</m:mn>
                    <m:mo>-</m:mo>
                    <m:mo form="prefix">cos</m:mo>
                    <m:mo>(</m:mo>
                    <m:msub>
                      <m:mi>ω</m:mi>
                      <m:mn>0</m:mn>
                    </m:msub>
                    <m:mrow>
                      <m:mo>(</m:mo>
                      <m:mi>n</m:mi>
                      <m:mo>-</m:mo>
                      <m:mi>M</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mrow>
                    <m:mi>π</m:mi>
                    <m:mo>(</m:mo>
                    <m:mi>n</m:mi>
                    <m:mo>-</m:mo>
                    <m:mi>M</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                </m:mfrac>
                <m:mspace width="4.pt"/>
                <m:mspace width="4.pt"/>
                <m:mspace width="4.pt"/>
                <m:mrow>
                  <m:mn>0</m:mn>
                  <m:mo>≤</m:mo>
                  <m:mi>n</m:mi>
                  <m:mo>≤</m:mo>
                  <m:mi>N</m:mi>
                  <m:mo>-</m:mo>
                  <m:mn>1</m:mn>
                </m:mrow>
              </m:mrow>
            </m:math>
          </equation>
          <para id="id2262983">and <m:math overflow="scroll"><m:mrow><m:mi>h</m:mi><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math> otherwise. Again the corresponding derivation for an even
length gives the same result as in (<cnxn target="uid50"/>). The ideal amplitude response
is shown in <cnxn target="uid51"/>.</para>
          <figure id="uid51" orient="horizontal">
            <media type="application/postscript" src="hilbert.eps">
              <media type="image/png" src="hilbert.png"><!-- NOTE: width parameter changes size of image online (pixels). original width is 419. --><param name="width" value="419"/></media>
            </media>
            <caption>Ideal Frequency Response of an FIR Hilbert Transorm in the
Passband and Lowpass Cutoff</caption>
          </figure>
        </section>
      </section>
      <section id="uid52">
        <name>Spline Transition Band Design</name>
        <para id="id2263050">All of the four lowpass filters described above exhibit the Gibbs
phenomenon when truncated to a finite length. To remove this effect and
to give a more explicit specification of the pass and stopband edges, a
transition band is inserted between the pass and stopband. A transition
function can be placed in this band to make the total desired amplitude
response a continuous function.</para>
        <para id="id2263060">If we use a <m:math overflow="scroll"><m:msup><m:mi>p</m:mi><m:mrow><m:mi>t</m:mi><m:mi>h</m:mi></m:mrow></m:msup></m:math> order spline as the transition function, the effect
of adding this transition band to the basic lowpass filter ideal amplitude
given in (<cnxn target="element-610"/>) is to multiply the ideal impulse response in
(<cnxn target="uid36"/>) by a the <m:math overflow="scroll"><m:msup><m:mi>P</m:mi><m:mrow><m:mi>t</m:mi><m:mi>h</m:mi></m:mrow></m:msup></m:math> power of a sinc function to give</para>
        <equation id="uid54">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msub>
                <m:mover accent="true">
                  <m:mi>h</m:mi>
                  <m:mo>^</m:mo>
                </m:mover>
                <m:mi>d</m:mi>
              </m:msub>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:mfrac>
                <m:mrow>
                  <m:mo form="prefix">sin</m:mo>
                  <m:mo>(</m:mo>
                  <m:msub>
                    <m:mi>ω</m:mi>
                    <m:mn>0</m:mn>
                  </m:msub>
                  <m:mi>n</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mrow>
                  <m:mi>π</m:mi>
                  <m:mi>n</m:mi>
                </m:mrow>
              </m:mfrac>
              <m:msup>
                <m:mfenced separators="" open="(" close=")">
                  <m:mfrac>
                    <m:mrow>
                      <m:mo form="prefix">sin</m:mo>
                      <m:mo>(</m:mo>
                      <m:mi>Δ</m:mi>
                      <m:mi>n</m:mi>
                      <m:mo>/</m:mo>
                      <m:mi>p</m:mi>
                      <m:mo>)</m:mo>
                    </m:mrow>
                    <m:mrow>
                      <m:mi>Δ</m:mi>
                      <m:mi>n</m:mi>
                      <m:mo>/</m:mo>
                      <m:mi>p</m:mi>
                    </m:mrow>
                  </m:mfrac>
                </m:mfenced>
                <m:mi>p</m:mi>
              </m:msup>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2263223">where <m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>0</m:mn></m:msub><m:mo>=</m:mo><m:mrow><m:mo>(</m:mo><m:msub><m:mi>ω</m:mi><m:mi>s</m:mi></m:msub><m:mo>+</m:mo><m:msub><m:mi>ω</m:mi><m:mi>p</m:mi></m:msub><m:mo>)</m:mo></m:mrow><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> is the average
band edge and <m:math overflow="scroll"><m:mrow><m:mi>Δ</m:mi><m:mo>=</m:mo><m:mo>(</m:mo><m:msub><m:mi>ω</m:mi><m:mi>s</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>ω</m:mi><m:mi>p</m:mi></m:msub><m:mo>)</m:mo><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:math> is half the transition
band width in radians per second normalized for one sample per
second sampling rate <cnxn target="bid8"/>, <cnxn target="bid6"/>, <cnxn target="bid9"/>. The spline produces a
transition function which consists of <m:math overflow="scroll"><m:mi>p</m:mi></m:math> segments of <m:math overflow="scroll"><m:msup><m:mi>p</m:mi><m:mrow><m:mi>t</m:mi><m:mi>h</m:mi></m:mrow></m:msup></m:math> order
polynomials connected together so that <m:math overflow="scroll"><m:mrow><m:mi>p</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math> derivatives are
continuous at the junctions.</para>
        <figure id="uid55" orient="horizontal">
          <media type="application/postscript" src="figSp.eps">
            <media type="image/png" src="figSp.png"><!-- NOTE: width parameter changes size of image online (pixels). original width is 427. --><param name="width" value="427"/></media>
          </media>
          <caption>Ideal Lowpass Filter Amplitude with Order-p Spline Transition
Function</caption>
        </figure>
        <para id="id2263390">The optimal value of the exponent <m:math overflow="scroll"><m:mi>p</m:mi></m:math> is chosen as
<m:math overflow="scroll"><m:mrow><m:mi>p</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>624</m:mn><m:mo>(</m:mo><m:msub><m:mi>f</m:mi><m:mi>s</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>f</m:mi><m:mi>p</m:mi></m:msub><m:mo>)</m:mo><m:mi>N</m:mi></m:mrow></m:math> (for a unity sampling rate) which minimizes the
approximation error <cnxn target="bid9"/>. Each of the four ideal lowpass
filters derived in the previous can have a transition band added
simply by multiplying their impulse response by the sinc weighting
function as illustrated in (<cnxn target="uid54"/>). <cnxn target="uid55"/> shows an
ideal unity gain filter amplitude response with examples of first,
second, and tenth order spline transition functions.
<cnxn target="uid56"/> shows the ideal responses of the linear gain
filter with fourth order spline transition function.</para>
        <figure id="uid56" orient="horizontal">
          <media type="application/postscript" src="figSp2.eps">
            <media type="image/png" src="figSp2.png"><!-- NOTE: width parameter changes size of image online (pixels). original width is 417. --><param name="width" value="417"/></media>
          </media>
          <caption>Ideal Increasing Amplitude Filter with Spline Transition
Function</caption>
        </figure>
      </section>
      <section id="uid57">
        <name>The Optimal Multiband Least Squared Error Design
Method</name>
        <para id="id2263501">The optimal multiband design method consists of two somewhat independent
parts. The first is the design of an optimal least squares lowpass filter
with a transition band as described above or as calculated by an inverse
FFT. The second part builds an optimal multiband filter from a
combination of these optimal lowpass filters and is the main point of this
<cnxn target="bid10"/>.</para>
        <para id="id2263516">The unweighted least squared error linear phase FIR filter design problem
is to find the filter coefficients that minimize the error defined by</para>
        <equation id="uid59">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:mi>q</m:mi>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:msubsup>
                <m:mo>∫</m:mo>
                <m:mn>0</m:mn>
                <m:mi>π</m:mi>
              </m:msubsup>
              <m:msup>
                <m:mrow>
                  <m:mo>|</m:mo>
                  <m:mi>A</m:mi>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>ω</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>-</m:mo>
                  <m:msub>
                    <m:mi>A</m:mi>
                    <m:mi>d</m:mi>
                  </m:msub>
                  <m:mrow>
                    <m:mo>(</m:mo>
                    <m:mi>ω</m:mi>
                    <m:mo>)</m:mo>
                  </m:mrow>
                  <m:mo>|</m:mo>
                </m:mrow>
                <m:mn>2</m:mn>
              </m:msup>
              <m:mspace width="0.166667em"/>
              <m:mi>d</m:mi>
              <m:mi>ω</m:mi>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2263601">where <m:math overflow="scroll"><m:mrow><m:mi>A</m:mi><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:math> is the amplitude frequency response of the actual filter
and <m:math overflow="scroll"><m:mrow><m:msub><m:mi>A</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> is the desired ideal amplitude response. This is done
by truncating the inverse discrete time Fourier transform of
<m:math overflow="scroll"><m:mrow><m:msub><m:mi>A</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math>. The difficulty is the analytical evaluation of the
integral in the inverse transform <cnxn target="bid6"/>. If a spline transition
function is used, an analytical formula can be derived for the filter that
minimizes (<cnxn target="uid59"/>). The details of this result can be found in
<cnxn target="bid9"/>, <cnxn target="bid10"/>.</para>
        <para id="id2263698">The infinitely long filters designed from the inverse discrete time
Fourier transform of the ideal response have a frequency response which is
the same as the ideal and, therefore, has no error. An ideal desired
amplitude response can be formulated as the sum of simpler ideal lowpass
filters, differentiators or Hilbert transformers together with their
spline transition functions by</para>
        <equation id="uid60">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msub>
                <m:mi>A</m:mi>
                <m:mi>d</m:mi>
              </m:msub>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>ω</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munder>
                <m:mo>∑</m:mo>
                <m:mi>k</m:mi>
              </m:munder>
              <m:msub>
                <m:mi>K</m:mi>
                <m:mi>k</m:mi>
              </m:msub>
              <m:mspace width="0.166667em"/>
              <m:msub>
                <m:mi>A</m:mi>
                <m:msub>
                  <m:mi>d</m:mi>
                  <m:mi>k</m:mi>
                </m:msub>
              </m:msub>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>ω</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mo>.</m:mo>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2263785">where <m:math overflow="scroll"><m:mrow><m:msub><m:mi>A</m:mi><m:msub><m:mi>d</m:mi><m:mi>k</m:mi></m:msub></m:msub><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> is the desired lowpass response with a transition
band in the <m:math overflow="scroll"><m:msup><m:mi>k</m:mi><m:mrow><m:mi>t</m:mi><m:mi>h</m:mi></m:mrow></m:msup></m:math> band such as given in (<cnxn target="element-610"/>) or (<cnxn target="element-558"/>) and
the <m:math overflow="scroll"><m:msub><m:mi>K</m:mi><m:mi>k</m:mi></m:msub></m:math> are chosen to build the desired <m:math overflow="scroll"><m:mrow><m:msub><m:mi>A</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math>. These <m:math overflow="scroll"><m:msub><m:mi>A</m:mi><m:msub><m:mi>d</m:mi><m:mi>k</m:mi></m:msub></m:msub></m:math>
are the forms considered in the previous section along with any others
that have analytical inverse DTFTs such as polynomials. Because of the
linearity of the Fourier transform, a multiband ideal response can be
constructed by simply adding and subtracting the impulse response of
appropriate ideal lowpass filters.</para>
        <equation id="uid61">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msub>
                <m:mover accent="true">
                  <m:mi>h</m:mi>
                  <m:mo>^</m:mo>
                </m:mover>
                <m:mi>d</m:mi>
              </m:msub>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munder>
                <m:mo>∑</m:mo>
                <m:mi>k</m:mi>
              </m:munder>
              <m:mspace width="0.166667em"/>
              <m:msub>
                <m:mi>K</m:mi>
                <m:mi>k</m:mi>
              </m:msub>
              <m:mspace width="0.166667em"/>
              <m:mspace width="0.166667em"/>
              <m:mtext>IDTFT</m:mtext>
              <m:mrow>
                <m:mo>{</m:mo>
                <m:msub>
                  <m:mi>A</m:mi>
                  <m:msub>
                    <m:mi>d</m:mi>
                    <m:mi>k</m:mi>
                  </m:msub>
                </m:msub>
                <m:mrow>
                  <m:mo>(</m:mo>
                  <m:mi>ω</m:mi>
                  <m:mo>)</m:mo>
                </m:mrow>
                <m:mo>}</m:mo>
              </m:mrow>
            </m:mrow>
          </m:math>
        </equation>
        <equation id="uid62">
          <m:math mode="display" overflow="scroll">
            <m:mrow>
              <m:msub>
                <m:mover accent="true">
                  <m:mi>h</m:mi>
                  <m:mo>^</m:mo>
                </m:mover>
                <m:mi>d</m:mi>
              </m:msub>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
              <m:mspace width="0.166667em"/>
              <m:mo>=</m:mo>
              <m:mspace width="0.166667em"/>
              <m:munder>
                <m:mo>∑</m:mo>
                <m:mi>k</m:mi>
              </m:munder>
              <m:mspace width="0.166667em"/>
              <m:msub>
                <m:mi>K</m:mi>
                <m:mi>k</m:mi>
              </m:msub>
              <m:mspace width="0.166667em"/>
              <m:msub>
                <m:mover accent="true">
                  <m:mi>h</m:mi>
                  <m:mo>^</m:mo>
                </m:mover>
                <m:msub>
                  <m:mi>d</m:mi>
                  <m:mi>k</m:mi>
                </m:msub>
              </m:msub>
              <m:mrow>
                <m:mo>(</m:mo>
                <m:mi>n</m:mi>
                <m:mo>)</m:mo>
              </m:mrow>
            </m:mrow>
          </m:math>
        </equation>
        <para id="id2264095">Because of the orthogonality of the basis functions of the Fourier
transform, the truncated sequence of the infinitely long impulse response
<m:math overflow="scroll"><m:mrow><m:msub><m:mover accent="true"><m:mi>h</m:mi><m:mo>^</m:mo></m:mover><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>n</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> will give an optimal approximation to <m:math overflow="scroll"><m:mrow><m:msub><m:mi>A</m:mi><m:mi>d</m:mi></m:msub><m:mrow><m:mo>(</m:mo><m:mi>ω</m:mi><m:mo>)</m:mo></m:mrow></m:mrow></m:math> in a
least squares sense. This argument allows no error weighting or “don't
care" transition bands or traditional windowing methods. It does,
however, allow the optimized spline transition functions <cnxn target="bid9"/>, <cnxn target="bid10"/>.</para>
        <para id="id2264172">Using these facts, an optimal multiband filter can be built up by
successively adding and subtracting the impulse responses of optimal
lowpass filters as done in (<cnxn target="uid61"/>). For example a bandpass filter
that approximates zero for <m:math overflow="scroll"><m:mrow><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>ω</m:mi><m:mn>1</m:mn></m:msub></m:mrow></m:math>, has a spline transition
band for <m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>1</m:mn></m:msub><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>ω</m:mi><m:mn>2</m:mn></m:msub></m:mrow></m:math>, approximates one (or some other
constant) for <m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>2</m:mn></m:msub><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>ω</m:mi><m:mn>3</m:mn></m:msub></m:mrow></m:math>, has an independent second
transition band for <m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>3</m:mn></m:msub><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>ω</m:mi><m:mn>4</m:mn></m:msub></m:mrow></m:math>, and finally approximates
zero for <m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>4</m:mn></m:msub><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:mi>π</m:mi></m:mrow></m:math> can be designed by first designing a simple
lowpass filter with transition band <m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>3</m:mn></m:msub><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>ω</m:mi><m:mn>4</m:mn></m:msub></m:mrow></m:math> and then
subtracting from its impulse response the impulse of a second lowpass
filter designed with a transition band <m:math overflow="scroll"><m:mrow><m:msub><m:mi>ω</m:mi><m:mn>1</m:mn></m:msub><m:mo>&lt;</m:mo><m:mi>ω</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>ω</m:mi><m:mn>2</m:mn></m:msub></m:mrow></m:math>. A
filter with two or more passbands can be designed by adding the impulse
responses of two or more single passband filters.</para>
        <para id="id2264395">Indeed, a completely general design method can be formulated by
alternately adding and subtracting lowpass filters starting with the
highest frequency transition band and moving sequentially down to the
lowest. If the ideal frequency response is not zero at <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mi>π</m:mi></m:mrow></m:math>, then
one starts with a constant frequency response (an impulse in the time
domain) and subtracts a lowpass filter (remember the length must be odd
for this case). By scaling each lowpass filter, different gains are
obtained in each band.</para>
        <para id="id2264421">Care must be taken that the constructed spline transition function
properly fit the bands on both sides. This will not automatically happen
if there are two adjacent bands with different slopes connected by one
transitions function which are simply added together. It will automatically
happen if each passband is separated by a stopband or if adjacent bands
have the same slopes.</para>
      </section>
      <section id="uid63">
        <name>A Matlab Filter Design Program</name>
        <para id="id2255383">A Matlab <cnxn target="bid11"/> program named fir3.m
 is given in the appendix of
this book that will design optimal filters using the method described
in the previous section. This particular program requires constant but
arbitrary passband gains and uses a format for specifications similar to
remez()
 in Matlab. It constructs the multiband filter from
(<cnxn target="uid62"/>) by adding and subtracting optimal lowpass filters designed
from the formula in (<cnxn target="uid54"/>) and calculated in the second program named
fir3lp.m
.</para>
        <para id="id2255424">The main program is given an even length vector f 
 containing the
normalized pass and stopband edges, including <m:math overflow="scroll"><m:mrow><m:mi>f</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math> and <m:math overflow="scroll"><m:mrow><m:mi>f</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow></m:math>. It is also
given an even length vector m 
 containing the ideal response at
each frequency in f
. Because the lowpass filter has a constant
passband, the ideal response of the multiband filter will have constant
passbands. This means m 
 will consist of adjacent terms that are
equal. An example Matlab function call is given in the next section.</para>
        <para id="id2255486">The simple program listed in the appendix will design filters with
constant gains in multiple passbands. From its construction it is easy to
see how adding the use of the linear gain lowpass filter to the unity gain
passband lowpass filter would allow designing optimal filters with linear
gains in the passbands. By adding all four basic lowpass designs a
calling program could be written that would automatically design one
filter with a combination of all four characteristics. If the real and
imaginary parts of a desired complex frequency response can be given in
terms of the basic filters, nonlinear phase filters can be designed also.</para>
        <para id="id2255500">The programs are written to be consistent with Matlab's convention of
normalizing for two samples per second sampling rate. The equations
most of this book, however, are normalized for one sample per second.</para>
      </section>
      <section id="uid64">
        <name>Design Examples</name>
        <para id="id2264712">To show the results of using this new design approach, two examples of
multiband filter design are presented here. The first is a filter with a
stopband from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>2</m:mn></m:mrow></m:math>,
a transition band from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>2</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>25</m:mn></m:mrow></m:math>,
a passband with gain equal
to 0.7 from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>25</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>5</m:mn></m:mrow></m:math>,
a transition band from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>5</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>55</m:mn></m:mrow></m:math>,
a passband with gain equal
to 0.5 from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>55</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>7</m:mn></m:mrow></m:math>,
a transition band from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>7</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>73</m:mn></m:mrow></m:math>,
a stopband from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>73</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>85</m:mn></m:mrow></m:math>,
a transition band from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>85</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>9</m:mn></m:mrow></m:math>, and
a passband with gain equal one from <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>9</m:mn></m:mrow></m:math> to <m:math overflow="scroll"><m:mrow><m:mi>ω</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow></m:math>. This
is called with the Matlab program by</para>
        <code type="block"> 
h  = fir3(51,[0 .2 .25 .5 .55 .7 .73 .85 .9 1],[0 0 .7 .7.5 .5 0 0 1 1])
</code>
        <para id="id2265076">and the amplitude response plot shown in <cnxn target="uid65"/>a. The
response for length of <m:math overflow="scroll"><m:mrow><m:mi>N</m:mi><m:mo>=</m:mo><m:mi>a</m:mi><m:mn>01</m:mn></m:mrow></m:math> is shown in Figures <cnxn target="uid65"/>b and in
<cnxn target="uid65"/>c the zero locations are given. As an example of how versatile
this approach can be, a length-101 linear phase multiband FIR filter was
designed with different types of filtering being done in different bands.
The signal frequencies in the band from <m:math overflow="scroll"><m:mrow><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:mi>f</m:mi><m:mo>&lt;</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>2</m:mn></m:mrow></m:math> is differentiated,in the
band from <m:math overflow="scroll"><m:mrow><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>25</m:mn><m:mo>&lt;</m:mo><m:mi>f</m:mi><m:mo>&lt;</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>4</m:mn></m:mrow></m:math> is rejected, in <m:math overflow="scroll"><m:mrow><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>4</m:mn><m:mo>&lt;</m:mo><m:mi>f</m:mi><m:mo>&lt;</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>2</m:mn></m:mrow></m:math> is hiltbert
transformed, in <m:math overflow="scroll"><m:mrow><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:mi>f</m:mi><m:mo>&lt;</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>2</m:mn></m:mrow></m:math> is rejected, and <m:math overflow="scroll"><m:mrow><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:mi>f</m:mi><m:mo>&lt;</m:mo><m:mn>0</m:mn><m:mo>.</m:mo><m:mn>2</m:mn></m:mrow></m:math> is highpass filtered.
In the transition bands between each of these processing bands, is an
optimal spline transition function. This is a truly versatile multiband
design technique with the only major limitation being that weighting is
not possible. However, that limitation is removed in the next secession.</para>
        <figure id="uid65" orient="horizontal">
          <media type="application/postscript" src="figMB1.eps">
            <media type="image/png" src="figMB1.png"><!-- NOTE: width parameter changes size of image online (pixels). original width is 386. --><param name="width" value="386"/></media>
          </media>
          <caption>Frequency Response of Length-15 FIR Filter Designed by Least
Squared Error</caption>
        </figure>
      </section>
    </section>
    <section id="uid66">
      <name>Weighted Least Integral Squares FIR Filter Design</name>
      <para id="id2265277">If the FIR filter design problem is posed as a weighted integral squared
error approximation problem, a simple analytical design formula as in
(<cnxn target="uid37"/>) or (<cnxn target="uid61"/>) is not possible (Recall that it is possible to
easily introduce weights in the discrete approximation problem
(<cnxn target="uid24"/>)). In this section we consider a multiband generalization
<cnxn target="bid10"/> of an approach which is a mixture of analytical formulas and
numerical solution of Toeplitz plus Hankel matrices which have been
presented in <cnxn target="bid12"/>, <cnxn target="bid13"/>, <cnxn target="bid9"/>.</para>
      <para id="id2265323">The most general definition of the linear phase weighted least squares FIR
filter design problem <cnxn target="bid12"/>, <cnxn target="bid14"/>, <cnxn target="bid15"/> defines the error measure
as in (<cnxn target=""/>) by</para>
      <equation id="uid68">
        <m:math mode="display" overflow="scroll">
          <m:mrow>
            <m:mi>q</m:mi>
            <m:mspace width="0.166667em"/>
            <m:mo>=</m:mo>
            <m:mspace width="0.166667em"/>
            <m:mfrac>
              <m:mn>1</m:mn>
              <m:mi>π</m:mi>
            </m:mfrac>
            <m:msub>
              <m:mo>∫</m:mo>
              <m:mi>Ω</m:mi>
            </m:msub>
            <m:mi>W</m:mi>
            <m:mrow>
              <m:mo>(</m:mo>
              <m:mi>ω</m:mi>
              <m:mo>)</m:mo>
            </m:mrow>
            <m:msup>
              <m:mrow>
                <m:mo>|</m:mo>
                <m:msub>
       