clear all

Lx=2*pi;

Nx=128;
dx=Lx/Nx;

x=[0:Nx-1]*dx;

kx=2*pi/Lx*[0:Nx/2-1,-Nx/2:-1];

kxs=fftshift(kx);

f=sin(x).*exp(-(x-pi).^2);
dfan=(cos(x)-2*(x-pi).*sin(x)).*exp(-(x-pi).^2);

fhat=fft(f);
fhats=fftshift(fhat)

f1=real(ifft(fhat));
figure(45)
plot(x,f,'r',x,f1,'ob','linewidth',2)
xlabel('$x$','Interpreter','Latex')
ylabel('$f(x)$','Interpreter','Latex')
set(gca,'Fontsize',24)
grid on

figure(46)
plot(kxs,(abs(fhats)).^2,'b',kxs,(abs(fhats)).^2,'ob','linewidth',2,'markersize',14)
xlabel('$k_x$','Interpreter','Latex')
ylabel('$|\hat f(k_x)|^2$','Interpreter','Latex')
xlim([-10 10])
set(gca,'Fontsize',24)
grid on

dfhat=1i*kx.*fhat;

df=real(ifft(dfhat));
figure(47)
plot(x,dfan,'ob',x,df,'r','linewidth',2)
xlabel('$x$','Interpreter','Latex')
ylabel('$d f(x)/ dx$','Interpreter','Latex')
set(gca,'Fontsize',24)
grid on







