16

Is there a fast Fourier transform in Mathematica? Although looking in the help I could not find one.

I am looking to implement the equivalent of fft in MATLAB.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
500
  • 5,569
  • 6
  • 27
  • 49
  • There is definitely something different going on with Fourier[] than the fft function in Matlab. If you take the fft(eye(n)) in Matlab you get the FourierMatrix of n. In Mathematica you do not. FourierMatrix[n] does exist, but the method of obtaining it via Fourier[IdentityMatrix[n]] does not work in Mathematica, so the fft and Fourier functions are different somehow. – David Apr 14 '18 at 22:30
  • I have put some notes on how Mathematica implements a Fourier transform here. – Hugh Nov 04 '21 at 06:47

2 Answers2

19

Fourier[list] computes the discrete Fourier transform of list. I assume it uses the FFT when it can.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Cassini
  • 5,556
  • 5
  • 28
  • 38
  • 9
    Note that the normalization used by Mathematica is quite different from conventional (e.g. physics, signal processing) normalizations. Check the definition you are using, and set the option FourierParameters accordingly. – J. M.'s missing motivation Feb 02 '12 at 14:15
  • Is there a way to strip it out ? In Matalab syntax I need to do the following : function fs = MyFFT(fx)

    y = fftshift(fx); tmp = fft(y)/sqrt(length(fx)); fs = fftshift(tmp);

    – 500 Feb 02 '12 at 14:27
  • fftshift[vec_?VectorQ] := RotateRight[vec, Quotient[Length[vec], 2]] – J. M.'s missing motivation Feb 02 '12 at 14:39
  • 11
    For reference: MATLAB's fft(stuff) is equivalent to Mathematica's Fourier[stuff, FourierParameters -> {1, -1}]. To do fft(y)/sqrt(length(y)), one doesn't need to do an explicit division, as the adjustment of FourierParameters is all that's needed: Fourier[y, FourierParameters -> {0, -1}]. – J. M.'s missing motivation Feb 02 '12 at 15:00
  • @J.M. Thank You very much for the explanation, well it is actually the answer to my question... – 500 Feb 03 '12 at 03:50
  • @J.M. - Where is the explanation for FourierParameters? Mathematica only says is an option to Fourier and related functions that specifies the conventions to use in computing Fourier transforms. which says little about how to get a correct RMS normalization (which is what I want). – A. Vieira Sep 08 '17 at 14:19
  • 1
    @A.Vieira, under the fifth and sixth bullets of "Details and Options" for Fourier[] and fourth and fifth bullets of "Details and Options" for FourierTransform[], are explanations on how the FourierParameters option affects them. There should be similar notations in the other Fourier-related functions of Mathematica that take the FourierParameters setting. – J. M.'s missing motivation Sep 08 '17 at 14:29
  • @J.M. Thanks. That does it. I was checking the FourierParameters page which wasn't much help. – A. Vieira Sep 09 '17 at 10:04
16

Fourier uses FFT when possible

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
acl
  • 19,834
  • 3
  • 66
  • 91