ML Program 4
ML Program 4
N = 1000;
x = linspace(-L,L,N)';
dx = x(2) - x(1);
U = 1/2*100*x.^(2);
hbar = 1; m = 1;
H = -1/2*(hbar^2/m)*Lap + spdiags(U,0,N,N);
nmodes = 3; options.disp = 0;
[V,E] = eigs(H,nmodes,'sa',options);
[E,ind] = sort(diag(E));
V = V(:,ind);
Usc = U*max(abs(V(:)))/max(abs(U));
plot(x,V,x,Usc,'--k');
legend(lgnd_str)
shg