% athalg
clear all,close all,clc
dx=.005; L=40; x=.001:dx:L;;n=length(x);
D2=diag(ones([n-1,1]),-1)-2*diag(ones([n,1]),0)+diag(ones([n-1],1),1);D2=D2/dx^2;
hbar=1;m=1;pot=-diag(1./x);H=-D2/2+pot;en=eig(H);
en(1:4),exa=-0.5./[1:4]'.^2;[en(1:4) exa]