- #1

- 835

- 30

Hi. I was checking the library for the discrete Fourier transform, fftw. So, I was using a functition ##f(x)=sin(kx)##, which when transformed must give a delta function in k. When I transform, and then transform back, I effectively recover the function, so I think I am doing something right. But when I try to plot the function in reciprocal space, the delta function doesn't appear where it should be.

The discrete Fourier transform of a function ##f(x)## is ##\hat f_k=h \sum_{j=1}^N e^{-ikx_j}f(x_j)## ##k=0,1,2...,N-1##.

The inverse transform is:

##f_j=\frac{1}{2\pi}\sum_{k=0}^N e^{ikx_j}\hat f_k##, ##j=1,2...,N##

For example, here I have used the case with k=2:

I am using for the discrete case: ##x=i*\Delta x##, with i from 0 to N, and similarly ##k=i\Delta x##. Is my choice for the discrete k wrong? and how should I fix this?

## Homework Equations

The discrete Fourier transform of a function ##f(x)## is ##\hat f_k=h \sum_{j=1}^N e^{-ikx_j}f(x_j)## ##k=0,1,2...,N-1##.

The inverse transform is:

##f_j=\frac{1}{2\pi}\sum_{k=0}^N e^{ikx_j}\hat f_k##, ##j=1,2...,N##

## The Attempt at a Solution

For example, here I have used the case with k=2:

I am using for the discrete case: ##x=i*\Delta x##, with i from 0 to N, and similarly ##k=i\Delta x##. Is my choice for the discrete k wrong? and how should I fix this?