https : // www . wolfram . com/mathematica/newin7/content/TranscendentalRoots/FindTheEnergySpectrumForAFinitePotentialWell . html
​
Find the Energy Spectrum for a Finite Potential Well
Find the energy spectrum for particles of mass m in a potential well of width L and height Γ . Show the solutions normalized to be 1 at L/2.
In[]:=
Remove["Global`*"]​​α=Sqrt[​​2m(Γ-Ε)]/ℏ;k=Sqrt[​​2mΕ]/ℏ;​​Subscript[ψ,1]=GExp[αx];Subscript[ψ,2]=​​ASin[kx]+BCos[kx];Subscript[ψ,3]=HExp[-αx];​​bconds={(Subscript[ψ,1]/.x->-L/2)==(Subscript[ψ,​​2]/.x->-L/2),(Subscript[ψ,2]/.​​x->L/2)==(Subscript[ψ,3]/.x->L/2),(
∂
x
ψ
1
/.x->-L/2)==(
∂
x
ψ
2
/.x->-L/2),(
∂
x
ψ
2
/.x->L/2)==(
∂
x
ψ
3
/.x->L/2)};​​d=Det[CoefficientArrays[bconds,{A,B,G,H}][[2]]];​​ℏ=1;L=1;Γ=100;m=1;​​spec=Reduce[d==0&&Ε>1/1000,Ε,​​Reals]
Out[]=
Ε
3.78
…
||Ε
15.1
…
||Ε
33.5
…
||Ε
58.6
…
||Ε
88.1
…
In[]:=
sols=(Piecewise[{{Subscript[ψ,1],x<-L/2},{Subscript[ψ,2],-L/2<x<L/2}},Subscript[ψ,3]]/.#/.Solve[bconds/.#,{A,B,G}]/.H->(Exp[Sqrt[(Γ-Ε)/2]]/.#))&/@N[{ToRules[spec]},20];​​Plot[sols,{x,-L,L},PlotRange->All]
Out[]=
In[]:=
ψ[x_]:=Piecewise[{{Subscript[ψ,1],x<-L/2},{Subscript[ψ,2],-L/2<x<L/2}},Subscript[ψ,3]]​​CostNorm:=1/Sqrt[NIntegrate[Abs[ψ[x]]^2,{x,-L,L}]];​​ψ[x_]:=CostNormψ[x];​​sols=(ψ[x]/.#/.Solve[bconds/.#,{A,B,G}]/.H->(Exp[Sqrt[(Γ-Ε)/2]]/.#))&/@N[{ToRules[spec]},20]​​Plot[sols,{x,-L,L},PlotRange->All]
Out[]=
{TerminatedEvaluation[RecursionLimit],TerminatedEvaluation[RecursionLimit],TerminatedEvaluation[RecursionLimit],TerminatedEvaluation[RecursionLimit],TerminatedEvaluation[RecursionLimit]}
Out[]=
-1.0
-0.5
0.5
1.0
-1.0
-0.5
0.5
1.0