First-order Euler method for the finite square well with a bump in the middle

stepsize

h=.01;

number of steps

n= 1000;

set the depth of the well

ν=100;

u=0;

Look for odd solutions

y1=0;
y2=1;

Look for even solutions

y1=1;
y2=0;

Guess for energy - remember negative for bound states

ϵ= -83.00000000000;

H[x_]=HeavisideTheta[x];

g[x_]= ν/4*(3H[x]+H[x - 1/2]-4H[x-1]);

For[i=1,i<=n,i++,
u=u+h;
y1=y1 +h*y2;
y2=y2 - h*(g[u]+ϵ)*y1;
a[i]=u; b[i]=y1;
]

ListPlot[Table[{a[i],b[i]},{i,1,n}],PlotRange->{-300,300}]

ListPlot[Table[{a[i],b[i]},{i,1,n}],PlotRange->{-5,5}]

Plot half (u>0) of the potential energy

Plot[-g[u],{u,0,2},PlotStyle->{Thickness->0.01,RGBColor[1,0,0]}]