Rae & Napolitano Worked Example 10.4

Remove["Global`*"]
$Assumptions={a>0,m>0,ω>0,ℏ>0,x0>0};

Calculate the expectation of the Hamiltonian with the trial wave function. (We took the second derivative of the wave function by hand.)

avgH=Simplify[
(1/a)Integrate[
Cos[Pi x/(2a)]
(ℏ^2/(2m)(Pi/(2a))^2+m ω^2x^2/2)
Cos[Pi x/(2a)],
{x,-a,a}]]

Take the derivative with respect to a, set it to zero, and solve. Not being fancy, I knew ahead of time that the fourth solution is the positive solution, so I’m just picking out that one.

avgHderv=D[avgH,a]

aMin=a/.Solve[avgHderv==0,a][[4]]

N[aMin]

This value agrees with the textbook. Now evaluate the ground state eigenvalue approximation.

avgH/.a->aMin

N[%]

Now get the true ground state wave function, and see how close we are to orthogonality

x0=Sqrt[ℏ/(m ω)];
expFact=Exp[- x^2/(2x0^2)];
normSq=Integrate[expFact^2,{x,-∞,∞}];
u0=expFact/Sqrt[normSq]

v=(1/Sqrt[a])Cos[Pi x/(2a)];
Integrate[v^2,{x,-a,a}]==1

Integrate[u0^2,{x,-∞,∞}]==1

N[Integrate[v u0/.a->aMin,{x,-aMin,aMin}]]

ArcCos[Re[%]]

180 %/Pi