% convFFT Compute the convolution of two Gaussians using fft

% Set up computational grid

xMin = -10;  xMax = 10; xDomain = xMax-xMin;

x = linspace(xMin, xMax-xDomain/N, N); dx = x(2)-x(1);
    
% Fourier space discretization

dom = 2*pi/xDomain; om = [0:N/2,-N/2+1:-1]*dom;
phase = dx*exp(-1i*om.*xMin);

u = exp(-x.^2); v = exp(-2*x.^2);

fnumF = fft(u).*fft(v).*phase;

fnum = real(ifft(fnumF));

fana = sqrt(3*pi)/3*exp(-2/3*x.^2);

plot(x,fnum,x,fana,'o')