0% found this document useful (0 votes)
18 views1 page

ML Program 4

The document defines variables and sets up a 1D potential well problem to find and plot the lowest energy eigenstates and eigenfunctions using the finite difference method and eigensolver.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

ML Program 4

The document defines variables and sets up a 1D potential well problem to find and plot the lowest energy eigenstates and eigenfunctions using the finite difference method and eigensolver.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

L = 5;

N = 1000;

x = linspace(-L,L,N)';

dx = x(2) - x(1);

U = 1/2*100*x.^(2);

e = ones(N,1); Lap = spdiags([e -2*e e],[-1 0 1],N,N)/dx^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');

lgnd_str = [repmat('E = ',nmodes,1),num2str(E)];

legend(lgnd_str)

shg

You might also like