So to gain a better understanding of how Discrete Fourier Transforms are done, I'm trying to program one in Mathematica so I can easily check my answers with the built-in Mathematica code. Based on Wolfram's page on the DFT, I see that I have to sum over N elements N times to calculate the full transform of a set with N discretizations. So I made a for() loop to calculate the DFT.
For[k = 0, k < m , k++,
For[x = 0, x < m , x++,
Ts[[k + 1]] += s[[x + 1]]*Exp[-2*I*π*k*x/m];
]
]
Ts being the transform of s and s being the set that I would like to transform. But every time I check the answer, it's wrong. I thought that I might have a few off-by-one errors but none of the places I would expect there to be an error seem to have one and shifting by one in most places either doesn't make sense or does not product the correct DFT. What am I misunderstanding?
Fourier[]is not the conventional one; look upFourierParameters. 2. You can useFourierMatrix[]as another possible check of your DFT. 3.Sum[]is built-in, as isTable[]. They should be better than your current loop. 4. Matters Computational is a very good reference for this sort of thing. – J. M.'s missing motivation Apr 07 '16 at 00:20