Re: Fourier Question
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg1615] Re: Fourier Question
- From: rknapp (Robert Knapp)
- Date: Thu, 6 Jul 1995 22:32:57 -0400
- Organization: The Santa Fe Institute
In article <3t2ium$mie at news0.cybernetics.net> jt12799 at glibm3.cen.uiuc.edu (Jehan Tsai) writes:
>
> I have a question concerning the Mathematica command 'Fourier'
> Recently, I have been experimenting with this command for a program I have
> been working on that requires it. For the most part, it seems to work as
> expected, except when we multiply the list by Exp[I b x], which is supposed
> to cause a shift in the frequency domain. However, it does not seem to
> perform as expected shifting the function around strangely in the frequency
> domain. According to references, Exp[I 2 Pi f0/N x] Should cause a shift
> of f0, but does not. Below are the commands I used in my trial.
>
> g=UnitStep[x+5]-UnitStep[x-5];
> b= ;
> f1=Table[N[g*Exp[I x b]],{x,-63,64}];
> f2=Fourier[f1];
> ListPlot[Abs[f2]];
>
> A comparison of this plot with the Fourier of sampled function g by itself
> indicates that for whatever b I choose has no correlation on the shift itself.
> I'm not sure what the problem is, whether I am misunderstanding the actual
> code, the way Mathematica does the FFT or whether I am just plotting the
> samples over an incorrect interval. I am interested in any help or
> suggestions in what the problem is. Thanks in advance.
>
> J.T. Tsai
Your references are correct. The values of the transform should shift
by f0 in the negative direction. I am not quite sure what values you
were trying for b, but I suspect you may not have included the
2Pi/128 factor. Below, I have produced a table which indicates that
the Fourier function is reflecting this accurately. Rather than
creating a plot, which is hard to send via nntp, I have simply tracked
the position of the maximum of the modulus of the transform. I have
also put in more general variables so that the proper scaling is clear.
In[89]:=
Table[
g=UnitStep[x+5]-UnitStep[x-5];
n = 128;
b = j 2*Pi/n;
f1=Table[N[g*Exp[I x b]],{x,1-n/2,n/2}];
f2=Fourier[f1];
f3 = Sort[Transpose[{Abs[f2],Range[n]}]];
Last[f3],
{j,1280,1280+128,16}] // TableForm
Out[89]//TableForm=
0.883883 1
0.883883 113
0.883883 97
0.883883 81
0.883883 65
0.883883 49
0.883883 33
0.883883 17
0.883883 1
Note that if non integer multiples of 2Pi/n are used, the value of the
maximum will change as well as its position. For example setting b to
integers gives shifts that look somewhat random, but are really quite
predicatble:
In[92]:=
Table[
g=UnitStep[x+5]-UnitStep[x-5];
n = 128;
b = j;
f1=Table[N[g*Exp[I x b]],{x,1-n/2,n/2}];
f2=Fourier[f1];
f3 = Sort[Transpose[{Abs[f2],Range[n]}]];
Join[Last[f3],{N[b*n/(2*Pi)]}],
{j,1,10}] // TableForm
Out[92]//TableForm=
0.882669 109 20.3718
0.883306 88 40.7437
0.883766 68 61.1155
0.881798 48 81.4873
0.883709 27 101.859
0.883415 7 122.231
0.882498 114 142.603
0.883878 94 162.975
0.882829 74 183.346
0.883187 53 203.718
The last column gives the predicted shift.
Rob Knapp
WRI