- #1
avikarto
- 56
- 9
I am trying to program something using a backwards FFT, and am attempting to feed it a delta function as a test condition since this result is known. However, my results are nonsense compared to what is expected.
It should be the case that if we have $$F(\omega)=\delta(\omega-1.5)=\frac{1}{\sqrt{2 \pi}}\int f(t)\:e^{-i \omega t}$$ the result would look like $$f(t)=\frac{Cos(1.5 t)-i Sin(1.5)t}{\sqrt{2 \pi}}$$ However, my method returns the same exact thing for the real and imag parts of f(t); these parts oscillate with frequency much greater than the expected 1.5 and are immediately on top of each other when plotted.
Numerically, i tried inputing two types of "delta function" arrays: one that was zero everywhere on the grid except at w=1.5, where it was equal to 1/dw (normalization), and another where each grid point was calculated as in a Gaussian, $$F(\omega)=\frac{1}{\sigma \sqrt{2\pi}} exp\left(-\frac{(\omega-1.5)^2}{2 \sigma^2}\right),$$ where I let sigma be small for a narrow spike. Both of these input types give the same result. I even tried a much finer grid, but the result was again the same. I am left to believe that the method is somehow flawed, but it took it almost exactly off of Intel's MKL help page with example FFTs (link), using the 1D out-of-place complex-to-complex transform.
My code follows. Any assistance in locating the issue would be greatly appreciated. Thanks.
It should be the case that if we have $$F(\omega)=\delta(\omega-1.5)=\frac{1}{\sqrt{2 \pi}}\int f(t)\:e^{-i \omega t}$$ the result would look like $$f(t)=\frac{Cos(1.5 t)-i Sin(1.5)t}{\sqrt{2 \pi}}$$ However, my method returns the same exact thing for the real and imag parts of f(t); these parts oscillate with frequency much greater than the expected 1.5 and are immediately on top of each other when plotted.
Numerically, i tried inputing two types of "delta function" arrays: one that was zero everywhere on the grid except at w=1.5, where it was equal to 1/dw (normalization), and another where each grid point was calculated as in a Gaussian, $$F(\omega)=\frac{1}{\sigma \sqrt{2\pi}} exp\left(-\frac{(\omega-1.5)^2}{2 \sigma^2}\right),$$ where I let sigma be small for a narrow spike. Both of these input types give the same result. I even tried a much finer grid, but the result was again the same. I am left to believe that the method is somehow flawed, but it took it almost exactly off of Intel's MKL help page with example FFTs (link), using the 1D out-of-place complex-to-complex transform.
My code follows. Any assistance in locating the issue would be greatly appreciated. Thanks.
Fortran:
use MKL_DFTI
function FFTB(nListIn,nLength)
integer status,nLength
type(DFTI_DESCRIPTOR), POINTER :: My_Desc_Handle
complex*16 nListIn(-nLength:nLength),FFTB(-nLength:nLength)
My_Desc_Handle => null()
status=DftiCreateDescriptor(My_Desc_Handle,DFTI_DOUBLE,DFTI_COMPLEX,1,2*nLength)
status=DftiSetValue(My_Desc_Handle,DFTI_PLACEMENT,DFTI_NOT_INPLACE)
status=DftiCommitDescriptor(My_Desc_Handle)
if (status .ne. 0) then
if (.not. DftiErrorClass(status,DFTI_NO_ERROR)) then
print *, 'Error: ', DftiErrorMessage(status)
endif
endif
status=DftiComputeBackward(My_Desc_Handle,nListIn,FFTB)
status=DftiFreeDescriptor(My_Desc_Handle)
return
end function FFTB