[comp.lang.c] Numerical Recipes: Error in Chapter 12?

splin@mowlavi.berkeley.edu (Steven Lin) (03/03/91)

     Is the definition of the Fourier transform, (12.0.1), (12.0.3), (12.1.7),
and elsewhere throughout the entire chapter incorrect?  Specifically, the
exponential terms in (12.0.1) should be switched.  
     I discovered this error while trying out their fft routine, four1  on
page 411.  The routine implements (12.1.7) correctly, but (12.1.7) is not
the correct or, at least, standard definition of the DFT.  You can get four1
to implement the DFT correctly by changing one line from
  
       theta=6.28318530717959/(isign*mmax);

to

       theta=-6.28318530717959/(isign*mmax);
       
This change must also be done to the other FFT routines within that chapter.
I discovered these errors in a 1990 reprint.

If I am incorrect, please tell me.  Redirection to the proper newsgroup would
also be appreciated.

pa@appmag.com (Pierre Asselin) (03/05/91)

splin@mowlavi.berkeley.edu (Steven Lin) writes:


~     Is the definition of the Fourier transform, (12.0.1), (12.0.3), (12.1.7),
~and elsewhere throughout the entire chapter incorrect?  Specifically, the
~exponential terms in (12.0.1) should be switched.  [...]

Partly arbitrary.  If you are a physicist, everything is OK.   If
you are an electrical engineer, change the sign of `i'.

The EE convention is more natural when dealing with time signals.
The physicist convention is handy for waves in space and time.

  --Pierre Asselin, R&D, Applied Magnetics Corp.  I speak for me.

davis@pacific.mps.ohio-state.edu ("John E. Davis") (03/06/91)

In article <11617@pasteur.Berkeley.EDU> splin@mowlavi.berkeley.edu (Steven Lin) writes:
        Is the definition of the Fourier transform, (12.0.1), (12.0.3), (12.1.7),
   and elsewhere throughout the entire chapter incorrect?  Specifically, the
   exponential terms in (12.0.1) should be switched.  
        I discovered this error while trying out their fft routine, four1  on
   page 411.  The routine implements (12.1.7) correctly, but (12.1.7) is not
   the correct or, at least, standard definition of the DFT.  You can get four1
   to implement the DFT correctly by changing one line from
   [...]


There is nothing wrong with the routines-- it is just convention.  In fact,
their convention is the one that is usually employed in theoretical physics--
positive energy waves propagate forward in time.  So just by making a sign
change, you are making a change in the convention.

I would have mailed this to you personally but since you have called attention to
what you perceive is an error over this forum, I felt that the record has to
be set straight over the same forum.

--
John

  bitnet: davis@ohstpy
internet: davis@pacific.mps.ohio-state.edu