Getting FFTs to behave

  • Thread starter birdhen
  • Start date
Hi there,

I am having trouble with some Fast Fourier Transforms.
I have been using both matlab and FFTW in c.
The problem is that I want to calculate the potential of a system from the overdensity. The equation in Fourier space is simple

phi(k)= -del(k)/(k^2) ,

where del is the overdensity, phi is the potential and k is the wavenumber.

To test this I use a simple del(x) = x, and feed this in to the fft. I then run through the k values and divide through by k squared. When k =0, I am not sure what to do as obviously you can't divide by zero.
I have tried a variety of things such as setting phi(k) = 0 when k=0, or just leaving phi(k) = del(k)..both of which I am sure are wrong.

When I reverse FFT this phi(k), my result is always a sine wave with a wavelength the size of the x range, where as I am expecting (1/6)*x^3.

I am having trouble finding the answer online. Maybe I am searching for the wrong thing. Can anyone help?
Best wishes,
 

DrClaude

Mentor
6,807
2,923
When k =0, I am not sure what to do as obviously you can't divide by zero.
I have tried a variety of things such as setting phi(k) = 0 when k=0, or just leaving phi(k) = del(k)..both of which I am sure are wrong.
The best choice here is to set up a grid of points such that ##k=0## is not included. This may require a shift that will add a complex phase to the result of the FFT, which can then be removed.
 

Want to reply to this thread?

"Getting FFTs to behave" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top