# 0 Hz (quite sharp) peak in FFT and division by 0

In a previous question, link, I asked about how I could most effectively do a Fourier Transform of a radial function given at certain values and which we knew the asymptotical behaviour of. The Fourier transform reading $$\frac{4\pi}{q}\int^{\infty}_0 dr\, r \sin(qr) f(r).$$ I tried several ways and ended up choosing FFT, which approximates it by calculating the DFT over the interval $[0,\Delta r]$ with $N$ points. (I used more particularly the NAG subroutine C06FAF)

I still get some issue around $q=0$. Indeed, as can be seen on the figure , I have some weird peak at very low frequencies. The black curve that is flat in q=0 is the analytical result while other curves are FFT calculations with increasing $\Delta r$. ($\color{blue}{\Delta r} >\color{red}{\Delta r} > {\bf \color{black}{\Delta r}} > \color{magenta}{\Delta r}$ and the dashed one being the highest $\Delta r$). As can be seen, this peak is narrower when $\Delta r$ gets larger.

The question is from where this peak does come ? And how could I get rid of it ? I already tried to take the mean of the function and substract it to the function but it does not change anything.

One subsidiary question is also the following : the subroutine calculates the integral. I then have to divide by $q$ to get this $4\pi/q$ factor. Though, at $q=0$, this can't be done for obvious reasons. So, what can be done instead ?

EDIT : the problem of the wide peak was simply due to the fact that I was doing a bad conversion between $q$ and the frequency from the routine. As far as the problem of the division by $q=0$ is concerned, I'm happy with Endulum's answer.

First, do you really need to divide by $q$? In the problems where these transforms come up, you can often get away with working with $rf(r)$ and $q\hat{f}(q)$ in their own right. Decide if you can put off dividing by $q$ until later on in the problem.
At such a time that you actually do need $q=0$, you can use the fact that $$\lim_{q\to 0} {\sin{(q r)} \over {q r}} = 1$$ for any finite $r$. Thus you have $$\hat{f}(0)\approx \lim_{q\to 0} 4\pi\int_0^R dr~{\sin{(q r)} \over {q r}} r^2 f(r) = 4\pi\int_0^R dr~r^2 f(r)$$ assuming $r^2 f(r)$ is well-behaved on $[0, R]$.