Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

On the internet I have found the definition of the DFT to be : $$ F(k) = \frac{1}{\sqrt{N}} \sum\limits_{n=0}^{N-1} f(n) e^{-\frac{2\pi}{N}jkn} $$ But in this article I have found an implementation which doesn't really match the formular above. Are there different definitions ? Can I exchange the $e^{-\frac{2\pi}{N}jkn}$-part with something else? And if yes, why ?

The implementation in the article I mentioned above looks similar to:

for (i = 0; i <= transformLength /2; i++) {
   cosPart[i] = 0;
   sinPart[i] = 0;
   for (k = 0; k < transformLength; k++) {

       tmp = 2*i*M_PI*( double)k/(double)transformLength;
       sinPart[i] += inputData[k] * (-1) * sin(tmp);
      cosPart[i] += inputData[k] * cos(tmp);
    }   
}

Could someone explain to me the context between the sin/cos functions and the e-function in the definition formular?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

The following equation holds for all $z\in\mathbb{C}$:

$e^{iz}=\cos z+i\sin z$

With, of course, $i=\sqrt{-1}$. This relation is known as Euler's formula, and you can see it is true by looking at the power series of the exponential, the cosine and the sine.

The article you linked computes the imaginary part of the Fourier transform explicitly, meaning without using complex numbers, and saves it separately as sinPart.

share|improve this answer
add comment

What has not been mentioned is that different books, papers, and software will have different conventions on the normalization of the discrete Fourier transform. One normalization that is a bit more common than the one in the OP is

$$X_n=\sum_{k=0}^{N-1} x_k \exp\left(-\frac{2\pi i kn}{N}\right)$$

that is, without the normalizing factor in front that makes for convenient formulae for the forward and inverse transform. Sometimes, one will have a forward transform without the minus sign in the exponential. If you're going to be doing Fourier work, ensure that the normalization conventions you are using in your work is the same as the convention in the software you will be using.

share|improve this answer
add comment

Your Answer

 
discard

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.