Comparison of exact psi and psi from keeping cn with n < 100. 2 1.5 psi 1 0.5 0 -0.5 0 0.2 0.4 0.6 x 0.8 1 09/11/12 10:37:02 leftsidehw3.m % Code used for HW3 problem 2 part (c). nterms = 100; n = 1:2:nterms; % note that only keeping odd terms c = 4*sqrt(6)*sin(n*pi/2)./(n * pi).^2; % coefficients from solution x = 0:0.001:1; psi = 0*x; for counter = 1:length(n) % again only keep odd terms psi = psi + c(counter)*sqrt(2)*sin(pi*n(counter)*x); % note n(counter) end exactpsi = sqrt(12)*(0.5 - abs(x - 0.5)); plot(x,psi,x,exactpsi) xlabel(’x’) ylabel(’psi’) title(’Comparison of exact psi and psi from keeping c_n with n < 100.’) 1 09/11/12 10:49:09 moviehw3.m 1 % Here we start with the wave function of leftsidehw3.m % and then time evolve by including the proper phase % factors. At each step in time |psi|^2 is plotted. nterms = 100; % Number of terms kept in the series. n = 1:2:nterms; % note that only keeping odd terms c = 4*sqrt(6)*sin(n*pi/2)./(n * pi).^2; % coefficients from solution x = 0:0.001:1; tmax = 2*pi; % This is the maximum time kept because after this the % wave function repeats. ntime = 100; % number of time steps for tcounter = 0:ntime, t = tcounter*tmax/ntime; psi = 0*x; for counter = 1:length(n) % again only keep odd terms psi = psi +c(counter)*sqrt(2)*sin(pi*n(counter)*x)*exp(-i*n(counter)^2 *t);%note n(counter) end plot(x,abs(psi).^2) xlabel(’x’) ylabel(’|psi|^2’) pause(0.5); end 09/11/12 10:57:05 description Getting the code (or experiment) to work is only the beginning of understanding the science. |psi|^2 started out at t = 0 peaked at x = 1/2 . As the wave function evolved in time, probability density moved towards the edges (x = 0 and x = 1) and then back to the center (x = 1/2). This process repeated several times in the period set in moviehw3.m . In comparing this to the case where all the probability density was on the left side of the well to begin with, the wave function was much smoother. This is because the c_n decay more rapidly with increasing n in this case. Note the excellent fit one obtains for psi(x,0) after just keeping a small number of terms. 1