In [28]:
HERMITE6 = [ (x)->(1), # Hermite_0 polynomial
             (x)->(2x), 
             (x)->(4x^2-2),
             (x)->(8x^3 - 12x),
             (x)->(16x^4 - 48x^2 + 12),
             (x)->(32x^5 - 160 - 120x) ]
SQRPI = 1.7724538509055159 # square root of pi
Out[28]:
1.7724538509055159
In [4]:
function getHermite(n)
    return HERMITE6[n+1] # because Jl start indicies at 1
end
Out[4]:
getHermite (generic function with 1 method)
In [5]:
function computeHermite(x,n)
    f = getHermite(n)
    return f(x)
end
Out[5]:
computeHermite (generic function with 1 method)
In [38]:
function qho_WaveFact(n)
    return (1 / sqrt( 2^n * factorial(n) ))
end

function qho_WaveNatX(x,n)
    norm = 0.10627834566699294
    WF = qho_WaveFact(n)
    H_n = computeHermite(x,n)
    
    return ( norm* WF * H_n * exp( -0.5 * x^2 ) )
end 
Out[38]:
qho_WaveNatX (generic function with 1 method)
In [15]:
function gaussianPert(x;alpha=4)
    return ( (1/alpha)*exp(-0.5x^2) )
end
Out[15]:
gaussianPert (generic function with 1 method)
In [42]:
function qho_EnergyN(n)
    norm4 = 0.10627834566699294^4
    hBar = 1.05457e-34
    return ( (n + 0.5) * norm4 * hBar^2 * pi )
end
Out[42]:
qho_EnergyN (generic function with 1 method)
In [39]:
wsp = linspace(-10,10,1000)
psi1 = zeros(1000)
phi1 = zeros(1000)
psi2 = zeros(1000)
phi2 = zeros(1000)
gPert1 = zeros(1000)
for i in [1:1000]
    psi1[i] = qho_WaveNatX( wsp[i], 0 )
    phi1[i] = qho_WaveNatX( wsp[i], 0 )
    psi2[i] = qho_WaveNatX( wsp[i], 1 )
    phi2[i] = qho_WaveNatX( wsp[i], 1 )
    gPert1[i] = gaussianPert( wsp[i] )
end

println(dot( psi1, phi1 ))
println(dot( psi2, phi2 ))
println(dot( psi1, phi2 ))
println(dot( psi2, phi1 ))
1.0
0.9999999999999998
-2.035545151696134e-17
-2.035545151696134e-17

In [40]:
for i in [1:1000]
    phi1[i] = gPert1[i] * phi1[i]
end
dot(phi1, psi1)
Out[40]:
0.2041241452319315
In [37]:
1/sqrt(88.53406985273054)
Out[37]:
0.10627834566699294
In [43]:
qho_EnergyN(0)
Out[43]:
2.2286909229549866e-72
In [44]:
16 * 4
Out[44]:
64
In [45]:
64 - 3 - 3
Out[45]:
58
In [46]:
58 / 5
Out[46]:
11.6
In [47]:
58 / 7
Out[47]:
8.285714285714286
In [55]:
acos(2/3)*180/pi
Out[55]:
48.189685104221404
In []:
d