I have been having a big problem understanding the concept of numerical ifft.
Consider a function in spatial domain like f(x)=-2/pi*Ln(abs(x))
in which x
is between -Lx
and Lx
. The fourier transform of this function is F(w)=2/abs(w)
.
I want to figure out whether these two are numerically the same using ifft command in Matlab. If you run the simple code below, you will see the difference that bothers me:
clc
clear all
Lx=0.0005;
N=pow2(10);
dx=2*Lx/(N-1);
w=pi/(N*dx)*linspace(-N/2,N/2,N);
Hw=2./abs(w);
hx=1/dx*abs(fftshift(ifft(Hw)));
x=linspace(-Lx,Lx,N);
hxexact=-2/pi.*log(abs(x));
plot(x,hx,x,hxexact,'r')
legend('ifft','exact')
here is the output:
I would appreciate that if anyone could help me with this.