I have an array with N purely real points representing a spatial function:
[f_0, f_1, f_2, ... , f_{N-1}]
The function values are spaced in with a distance dx.
Therefore the Nyquist frequency is given by f_N = 1/(2*dx)
I calculate the Fourier transform of the array in C using FFTW2, with the function for purely 1d real inputs rfftw. This leads to only N/2 independent complex numbers, which are stored in a "half complex array":
[r_0, r_1, .... r_{N/2}, i_{N+1}/2-1 , ..., i_2, i_1], where r denotes the real and i the imaginary part.
Now I would like to know what the frequency domain of this array looks like. Is r_{N/2} the value at f_N or (f_N/)2?
I already have the code and it seems to work, i just don't know how to interpret the frequency axis.
Your notation is confused. If your input is
then
f_n
is the input value at positionn
, it is not a position itself. The inputs are at integer indicesn = 0 … N-1
. Thus the question asking about “the value at f_N” makes no sense.The FFTW half-complex output is:
Here,
r_n + i * i_n
is the value at positionn
. Frequencies are the integer indicesn = 0 … N-1
. The Nyquist frequency is related toN
, notf_N
(which is not even defined in your input!). It is given byN/2.0
.If you assume a certain sampling
dx
in your input, such that the sample at positionn
has ax = n*dx
, then you can also translate frequency bins to physical frequencies, withdf = 1/(N*dx)
. Thus, the frequency at indexn
isn/(N*dx)
. With the understanding that the value for frequencyn/(N*dx)
is equal to that for(n+k*N)/(N*dx)
, withk
any positive or negative integer (from which you can obtain the negative frequencies that many expect to find in a Fourier transform).