MathMath

Help › Functions

Fourier transforms

fft FFT ifft IFFT cfft CFFT icfft ICFFT

fft(v) As in Mathcad

The first half of the spectrum of 2^m real values, scaled by 1/√n.

v is a column vector of real values, 8 or more of them, and their number n must be a power of two (8, 16, 32…). The result has n/2 + 1 complex values, for frequencies 0 up to the Nyquist frequency; the other half is their mirror image, so it is left out.

Uses a positive exponent, e^(+2πi·jk/n), and scales by 1/√n. FFT differs: it uses a negative exponent and scales by 1/n, so its first value is the mean. ifft takes the result back. For any length, or complex values, use cfft.

Units

The result has the units of v.

Refused

  • A vector with fewer than 8 values, or a length that is not a power of two.
  • Complex values (use cfft), or anything but a column vector.
v≔⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛​11111111​⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞​
fft(v)=⎝⎜⎜⎜⎜⎛​2.8280000​⎠⎟⎟⎟⎟⎞​

FFT(v) As in Mathcad

The first half of the spectrum of 2^m real values, scaled by 1/n, so the first value is the mean.

Takes the same vectors as fft, and gives the same n/2 + 1 values, but uses a negative exponent, e^(−2πi·jk/n), and scales by 1/n instead of 1/√n. The first value is therefore the mean of v, and a sine of amplitude 1 shows as a peak of 1/2. IFFT takes the result back.

Units

The result has the units of v.

Refused

  • A vector with fewer than 8 values, or a length that is not a power of two.
  • Complex values (use CFFT), or anything but a column vector.
v≔⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛​13131313​⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞​
FFT(v)=⎝⎜⎜⎜⎜⎛​2000−1​⎠⎟⎟⎟⎟⎞​

ifft(w) As in Mathcad

The 2^m real values whose fft is the half spectrum w.

w is a column vector of 2^(m−1) + 1 values (5, 9, 17, 33…), the half spectrum that fft gives. The other half is filled in as the complex conjugate mirror image, so the result is real and has 2^m values. Uses a negative exponent and scales by 1/√n, the reverse of fft. It does not undo FFT, which scales differently: use IFFT for that.

Units

The result has the units of w.

Refused

  • A length other than 2^m + 1, such as 4 or 10.
  • Anything but a column vector.
v≔⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛​12345678​⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞​
ifft(fft(v))=⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛​12345678​⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞​

IFFT(w) As in Mathcad

The 2^m real values whose FFT is the half spectrum w.

w is a column vector of 2^(m−1) + 1 values (5, 9, 17, 33…), as FFT gives. The other half is filled in as the complex conjugate mirror image, so the result is real and has 2^m values. Uses a positive exponent and no scaling, the reverse of FFT. It does not undo fft, which scales differently: use ifft for that.

Units

The result has the units of w.

Refused

  • A length other than 2^m + 1, such as 4 or 10.
  • Anything but a column vector.
v≔⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛​12345678​⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞​
IFFT(FFT(v))=⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛​12345678​⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞​

cfft(A) As in Mathcad

The complex Fourier transform of a vector or matrix of any size, scaled by 1/√n.

A can hold real or complex values, and any number of them: no power of two is needed. The result has the same size as A and holds every frequency. For a matrix the transform is two-dimensional, taken down each column and then along each row, and n is the total number of elements.

Uses a positive exponent and scales by 1/√n, as fft does. CFFT differs: it uses a negative exponent and scales by 1/n. icfft takes the result back.

Units

The result has the units of A.

Refused

  • Nested arrays or text, or an empty array.
v≔⎝⎜⎜⎛​1111​⎠⎟⎟⎞​
cfft(v)=⎝⎜⎜⎛​2000​⎠⎟⎟⎞​

CFFT(A) As in Mathcad

The complex Fourier transform of a vector or matrix of any size, scaled by 1/n, so the first value is the mean.

Takes the same arrays as cfft, of any size and real or complex, and gives every frequency. Uses a negative exponent and scales by 1/n instead of 1/√n, so the first value is the mean of A. ICFFT takes the result back.

Units

The result has the units of A.

Refused

  • Nested arrays or text, or an empty array.
v≔⎝⎜⎜⎛​1313​⎠⎟⎟⎞​
CFFT(v)=⎝⎜⎜⎛​20−10​⎠⎟⎟⎞​

icfft(A) As in Mathcad

The inverse of cfft: a negative exponent and a 1/√n scale.

Takes a vector or matrix of any size, real or complex, and gives the same size. icfft(cfft(A)) is A again, apart from rounding in the last digits. It does not undo CFFT, which scales differently: use ICFFT for that.

Units

The result has the units of A.

Refused

  • Nested arrays or text, or an empty array.
w≔⎝⎜⎜⎛​2000​⎠⎟⎟⎞​
icfft(w)=⎝⎜⎜⎛​1111​⎠⎟⎟⎞​

ICFFT(A) As in Mathcad

The inverse of CFFT: a positive exponent and no scaling.

Takes a vector or matrix of any size, real or complex, and gives the same size. ICFFT(CFFT(A)) is A again, apart from rounding in the last digits. It does not undo cfft, which scales differently: use icfft for that.

Units

The result has the units of A.

Refused

  • Nested arrays or text, or an empty array.
w≔⎝⎜⎜⎛​2000​⎠⎟⎟⎞​
ICFFT(w)=⎝⎜⎜⎛​2222​⎠⎟⎟⎞​