n = 1:100;
c = (1 - cos(pi*0.5*n))*2./(pi*n);

x = 0:0.001:1;
nmax = 100;

for counter2 = 0:100,

t = counter2*0.04;
psi = 0*x;

for counter = 1:nmax,
   psi = psi + c(counter)*sqrt(2)*sin(pi*counter*x)*exp(-i*counter^2 * t);
endfor

plot(x,abs(psi).^2)
axis([0 1 0 3])
xlabel('x')
ylabel('|\psi |^2')

pause(0.5);

endfor

