% Plots for the time-evolution of a free 10eV electron with 
% spread in momentum space equal to its momentum, (Delta p_x) = p0.
% The initial uncertainty in x is Delta x = a/sqrt(2) = hbar/2p0.

% Parameters for the wavefunction:
hbar = 1.055e-27;
m = 9.11e-28;
E = 10*1.602e-12; % 10eV in ergs
p0 = sqrt(2*m*E);
a = hbar/(sqrt(2)*p0);

% probability density
times = (0:4:20)*1e-17;
x = -1e-7:1e-10:1e-7;
rho = @(t) 1/sqrt(pi*(a^2+(hbar*t/(m*a))^2))*exp(-(x-p0*t/m).^2/(a^2+(hbar*t/(m*a))^2));
clf;
for t = times;
    plot(x,rho(t)); hold on;
    axis([x(500),x(2000),0,1.3e8]);
    xlabel('distance (cm)');
    ylabel('probability density')
    title('Evolution of a free electron (t=0 to t=.2 fs)')
end

% E. Boyda / SMC Phys125 / Fall '17. 