Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In this section from Wikipedia about IDFT, three methods are given for expressing the Inverse Discrete Fourier Transform in terms of the direct transform.

Being curious, I implemented the three methods in Octave:

% define TD signal
N = 1024; n = [1:N]-1; f = [4 8];
x0 = sin(2*pi*n'*f/N);
x0 = sum(x0');

% calculate FD spectrum
y0 = fft(x0);

% trick #1
y1 = fliplr(y0);
x1 = fft(y1) / N;

% trick #2
y2 = conj(y0);
x2 = conj(fft(y2)) / N;

% trick #3
y3 = imag(y0) + i*real(y0);
x3 = fft(y3) / N;
x3 = imag(x3) + i*real(x3);

% plot results
plot(n,x0,'m-o', n,x1,'r-*', n,x2,'g-^', n,x3,'bxo');
axis tight

If happens that tricks #2 and #3 work well, while trick #1 fails to generate the correct result.

Am I missing something in the explanation, or is there an error in Wikipedia?

UPDATE: It seems like the magnitude of the y1 result is actually OK, it is just that the angle is doing funny things. Replacing the plot line with:

plot(n,abs(x0),'m-o', n,abs(x1),'r-*', n,abs(x2),'g-^', n,abs(x3),'bxo');

shows the overlap.

share|cite|improve this question
In your definition of $n$, you create a row vector. x0 would then be a row vector, except that you take the sin of n': n-transposed. So x0 would, I believe, be a column vector. Which means that y0 would be a column vector, and so fliplr would be operating on a column vector and hence do nothing (at least, this would be the case if Octave works as MATLAB does). Did you check that y0 is a row vector, as expected? – Emily Sep 6 '12 at 21:12
@EdGorcenski - x0 is being transposed in the sum() as well, so I end up with a row vector. Typing whos shows all vectors have a 1 in their 1st dimension. – ysap Sep 6 '12 at 21:33
Ah, so it is; I missed that! – Emily Sep 6 '12 at 21:49
@EdGorcenski - I just posted an update to the question. – ysap Sep 6 '12 at 21:49
up vote 3 down vote accepted

I found my mistake. According to Wikipedia, using the 1st method, the indices of the reversed series are modulo N. So the correct code is:

% trick #1
y1 = [y0(1) fliplr(y0(2:N))];
x1 = fft(y1) / N;

and not as posted in the question.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.