Fourier Transforms in Mathematica

Mathematica can find the Fourier transform of some functions via the command FourierTransform (the Fourier command is for the discrete Fourier transform, which we will see later).  There are different conventions for where the 2 Pi goes in the definition of the Fourier transform, depending on the field, whether mathematics, classical physics, quantum physics, signal processing, or something else.  To stick with our text's definition, you need to include FourierParameters->{0,-2 Pi} in the FourierTransform command.

To evaluate a command, put your cursor on that line and hit shift-enter. Save this file with your work in the exercises below and email to tleise@amherst.edu by next Wednesday.

Below are examples of Fourier transforms and inverse transforms so you can see how the syntax works:

Example 1

fhat=FourierTransform[Exp[-Abs[x]],x,ξ,FourierParameters->{0,-2Pi}]

InverseFourierTransform[fhat,ξ,x,FourierParameters->{0,-2Pi}]

In the code above, we defined “f-hat” as an expression. We can also define f and its transform as functions in Mathematica :

Clear[f,fhat] (* clears previous definitions to avoid trouble *)

f[x_]:=Exp[-Abs[x]]
ft=FourierTransform[f[x],x,ξ,FourierParameters->{0,-2Pi}]
fhat[ξ_]:=ft (* don't directly define function as FourierTransform -- will be very slow in plots *)
Plot[Abs[fhat[ξ]],{ξ,-15,15},PlotRange->All]

Example 2

f=Piecewise[{{x,0<x<1}}];
Plot[f,{x,-3,3}]

fhat=FourierTransform[f,x,ξ,FourierParameters->{0,-2Pi}]
Plot[Abs[fhat],{ξ,-30,30},PlotRange->All]

newf=InverseFourierTransform[fhat,ξ,x,FourierParameters->{0,-2Pi}]

Plot[{f,newf},{x,-3,3}] (* expressions for f and newf may look a bit different, but they are the same function *)

Example 3

A Gaussian is a function of form a Exp[-b x^2]. This is an important function for several applications, including probability and for the rigorous proof of the inverse transform formula. This function is particularly useful because the transform of a Gaussian is another Gaussian:

f=a Exp[-b x^2]; (* Gaussian *)
FourierTransform[f,x,ξ,FourierParameters->{0,-2Pi}]

Exercises

Exercise 1  Find a value for b in the Gaussian above so that the transform equals exactly the original Gaussian (but with x replaced by ξ).

Exercise 2  Use Mathematica to find the Fourier transform of 3 Cos[4 Pi x]. (Not a square integrable function, but the theory of generalized functions allows us to take the Fourier transform here.) This function is a pure tone with frequency 2 cycles per time unit (there are 2π radians per cycle).  Look carefully at the transformed function: the DiracDelta functions are telling you what frequencies present.

Exercise 3  Use Mathematica to find the Fourier transform of 3 Sin[4 Pi x].  Look carefully at this transformed function to see what the DiracDelta function pattern is for this function.

Exercise 4   Suppose the Fourier transform of a function is 

		2 DiracDelta[ξ-4]+(1/2) i DiracDelta[ξ-2]-(1/2) i DiracDelta[ξ+2]+2 DiracDelta[ξ+4].
            
What was the original function f(x), in terms of cosines and sines?  Do this using the patterns observed in Exercises 2 and 3, then check your answer using the FourierTransform command (hit “FullSimplify” to convert to trig form if needed).

Exercise 5  Scaling will play a crucial role with wavelets, so let's see how scaling affects the Fourier transform.  Plot the function f[x] and f[x/2] via Clear[f]; f[x_]:=Exp[-Abs[x]]; Plot[{f[x],f[x/2]},{x,-15,15},PlotStyle->{Blue,Red}, PlotRange -> All].  Then plot the Fourier transforms of f[x] and f[x/2] on a plot together with the same colors (so you can tell which transform goes with which function).  Experiment to find the general effect of scaling on the transform, in terms of what happens to the graph of the transform.

Exercise 6  Find and plot the Fourier transform of  Exp[-x^2].  Note the clustering of low frequencies, with extremely small amplitudes at high frequencies.  Now plot the Fourier transform of Exp[2 Pi I n x] Exp[-x^2] for n=1, n=4, and n=10.  What is the effect of the term Exp[2 Pi I n x]? (In Mathematica, capital I represents i = the square root of -1.)

The smoother the function f(x) is, the more rapidly its Fourier transform goes to zero at infinity (high frequencies).  For example, a Gaussian has continuous derivatives of all orders--it's as smooth as you can get--and its transform goes to zero exponentially fast.  Let's see how this principle plays out with a few other functions.  (Note that Fourier analysis can't yield any local information, like locations of singularities.  Wavelets will be the proper tool for finding local information.)

Exercise 7   Let's compare the transforms of three functions: 

	(a) f[x_]:=Exp[-Abs[x]] UnitStep[x] (has a jump discontinuity)
	(b) g[x_]:=Exp[-Abs[x]] (continuous but derivative has a jump discontinuity)
	(c) h[x_]:=Exp[-Abs[x]] Abs[x^3] (continuous first and second derivatives, but third derivative has a jump discontinuity)
	
How fast do the transforms go to zero as the frequency goes to infinity, that is, O(1/(ξ^k)) for what k?  How does this compare to the number of continuous derivatives?  To see the connection, try asking Mathematica for the Fourier transform of a derivative, D[q[x],x].  How does this explain why transforms of smoother functions decay more rapidly?