Done - Eigen Values - Eigen Vectors - Diagonalize a Matrix
ToBeDone - Integrate an Integral - Express a pontential \(P\) as in the basis of wavefunctions from another
using PyPlot
whos()
max(2,4)
a = zeros(5,5)
function identitymat(n,m)
mat = zeros(n,m)
for i = [1:min(n,m)]
mat[i,i] = 1.0
end
return mat
end
function identity(n)
return identitymat(n,n)
end
a = identitymat(6,6)
b = identity(6)
a*b
v = [1:6]
a*v
c = round(rand(5,5)*10)
c * [1:5]
ec = eigvecs(c)
vc = eigvals(c)
vc[1] * ec[:,1]
c * ec[:,1]
function withintolerance(u,v, tol)
pass = true
if (length(u) != length(v))
println(" OOPS - u and v are not of the same length!")
return 1
end
for i = [1:length(u)]
if ( real(v[i] - u[i]) > tol )
pass = false
end
end
return pass
end
c1 = vc[1] * ec[:,1]
c2 = c * ec[:,1]
withintolerance(c1, c2, 1e-13)
1e-4 / 10.0
real(1+0im - 2+0im)
function perr(o,a)
return abs(o-a)*100/a
end
c
diag(c)
inv(c)
dc = diag(inv(ec)*c*ec)
quadgk
quadgk(sin,0,2pi)
quadgk(x->cos(x),0,2pi)
#compose two functions
function myCompose(f,g)
#given two functions of 1 variable each
return (x,y)->(f(x)*g(y))
end
foo = myCompose(x->x, x->x)
println(foo(2,2))
println(foo(2,4))
function compose(f,g)
return (x)->(f(x)*g(x))
end
println(quadgk(sin,0,pi))
println(quadgk(compose(sin,cos),0,pi))
[sin, cos]
Array(Function, 10)
#return the nth wavefunction of QHO
function wavefuncQHO(n)
mw
Cn = 1/(2^n * factorial(n))
return x->(Cn*mw*)