lambda0_um = 1e6*lambda0;
Epsilon_0 = 8.8541878128*1e-12;
T = linspace(-twidth/2, twidth/2, n);
sigma = FWHM/((2*log(2))^0.5);
gaussian = exp(-T.^2/sigma^2);
N = sqrt(sum(gaussian.^2)*dt);
x = linspace(-10e-3, 10e-3, 256);
gaussian_space = zeros(length(x),length(x));
for i_index = 1:length(x)
gaussian_space(i_index,j) = exp(-(x(i_index).^2 + x(j).^2)/w0^2);
N = sqrt(sum(sum(gaussian_space.^2))*(dx)^2);
gaussian_space = gaussian_space / N;
Laser_operation_freq = 5e3;
Pulse_energy = Average_power / Laser_operation_freq;
Total_initial_intensity = 0.5*c*Epsilon_0*(sum(sum(gaussian_space.^2))*(dx)^2) * (sum(gaussian.^2)*dt);
Normalization = sqrt(Total_initial_intensity/Pulse_energy);
E_x_y_t = (1/Normalization)*gaussian_space.*reshape(fin_t,1,1,[]);
frequencies = linspace(-Dnu/2, Dnu/2, n);
fx = linspace(-dfx*(n_x/2), dfx*(n_x/2), n_x);
fy = linspace(-dfy*(n_x/2), dfy*(n_x/2), n_x);
wavelength_freq_um = 1e6*c./frequencies;
[i_index, j, k] = ndgrid(1:length(x), 1:length(x), 1:length(frequencies));
phase_first_focal_length = (2.*pi*frequencies(k)./c).*(x(i_index).^2+x(j).^2)/(2*first_focal_length);
E_f = fftshift(fft(E_x_y_t, [], 3),3);
E_f = E_f.*exp(-1i*phase_first_focal_length);
E_x_y_t = ifft(ifftshift(E_f,3), [], 3);