MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Fourier Transforms and Integers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg6507] Fourier Transforms and Integers
  • From: Sean Ross <SEAN at mail.creol.ucf.edu>
  • Date: Thu, 27 Mar 1997 02:43:02 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I am posting this for general interest, not necessarily as a question, but for
general interest.

Recently, the question came up about the mathematica function Fourier not giving 
the expected results when given integers as arguments.  I recently ran in to a
more advanced example of the same phenomena.

I am currently preparing to solve a system of coupled non-linear differential
equations.  Terms in the equations include first partial derivatives and Laplacians. 
I thought that the most convenient way to take the derivatives of a 2-D array of
data would be to take advantage of the fourier transform theorem which says
that Fourier[(2 Pi nu  j)^n F[nu]]=nth partial of f(t).  The code for the first partial of
a square 2-D array "profile" is:

           NN=Length[profile];

	k=-I 2. N[Pi](1/NN/deltax  Outer[Plus,
	RotateRight[Table[0,{i,1,NN}],NN/2+1],
	RotateRight[Table[i,{i,1,NN}]-NN/2.,NN/2+1]];

	newprofile=InverseFourier[k Fourier[profile]];

This code works OK, but introduces an extraneous imaginary component
proportional to the array "profile" so that for real input, I can separate the real part
out and have a first partial derivative.  After much pencil and paper work to
explain the imaginary part and some playing around with parameters in the code, I
found that the problem was in the integer input to the two Table statements.  The
following code only replaces a 0 with a 0.0, but this invokes the real addition and
mathematica interprets everything in  the symbol k as real.  The extraneous
imaginary components go away, the sun comes out and the world is right again.

           NN=Length[profile];

	k=-I 2. N[Pi](1/NN/deltax  Outer[Plus,
	RotateRight[Table[0.0,{i,1,NN}],NN/2+1],
	RotateRight[Table[i,{i,1,NN}]-NN/2.,NN/2+1]];

	newprofile=InverseFourier[k Fourier[profile]];

This just goes to show you that in a computer language that doesn't have type
declaration statements, you have to be careful.


  • Prev by Date: Symbols, names, objects: kludge
  • Next by Date: Plot3D precision limits?
  • Previous by thread: Re: Symbols, names, objects: kludge
  • Next by thread: Re: Fourier Transforms and Integers