80% found this document useful (5 votes)
3K views11 pages

Scilab Programs

1. The document discusses several topics in linear algebra and quantum mechanics including matrix multiplication, eigenvalues and eigenvectors, moment of inertia tensors, and commutation relations. 2. Orthogonal polynomials like Hermite and Legendre polynomials are discussed as eigenfunctions of differential operators. Relations like the orthogonality of Hermite polynomials and Rodrigues' formula for Legendre polynomials are provided. 3. Determining the principal axes of a moment of inertia tensor through diagonalization is demonstrated. The commutator of position and momentum operators is shown to produce the eigenfunctions when acting on wavefunctions like Legendre and Hermite polynomials. 4. Estimating the ground state energy and wavefunction of a particle in an

Uploaded by

Prateek_14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
80% found this document useful (5 votes)
3K views11 pages

Scilab Programs

1. The document discusses several topics in linear algebra and quantum mechanics including matrix multiplication, eigenvalues and eigenvectors, moment of inertia tensors, and commutation relations. 2. Orthogonal polynomials like Hermite and Legendre polynomials are discussed as eigenfunctions of differential operators. Relations like the orthogonality of Hermite polynomials and Rodrigues' formula for Legendre polynomials are provided. 3. Determining the principal axes of a moment of inertia tensor through diagonalization is demonstrated. The commutator of position and momentum operators is shown to produce the eigenfunctions when acting on wavefunctions like Legendre and Hermite polynomials. 4. Estimating the ground state energy and wavefunction of a particle in an

Uploaded by

Prateek_14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

1.

Linear algebra:
1 Multiplication of two 3 x 3 matrices.

INPUT:
clc;
a=[1 2 3;4 5 6;1 4 3]
b=[2 1 1;1 3 2;3 1 4]
disp(a,"matrix a")
disp(b,"matrix b")
disp(a*b,"Product of a and b")

c=[6 8*(%i) 7;3 1 2*(%i);8 1*(%i) 5]


disp(c,"matrix c")
d=[2 -5 3*(%i) ;%i 2 3;-2*%i 3 -5]
disp(d,"matriix d")
disp(c*d,"Product of c and d")

OUTPUT:

matrix a matrix c

1 2 3 6 8.i 7
4 5 6 3 1 2.i
1 4 3 8 i 5

matrix b matriix d

2 1 1 2 -5 3.i
1 3 2 i 2 3
3 1 4 -2.i 3 -5

Product of a and b Product of c and d

13 10 17 4 - 14.i -9 + 16.i -35 + 42.i


31 25 38 10 + i -13 + 6.i 3 - i
15 16 21 15 - 10.i -25 + 2.i -25 + 27.i
2 Eigenvalue and eigenvectors of

2 1 1 1 -i 3+4i
1 3 2 i 2 4
3 1 4 3-4i 4 3

INPUT:
INPUT:
clc;
clc;
a=[1 -%i 3+4*(%i) ;%i 2 4;3-4*%i 4 3]
a=[2 1 1;1 3 2;3 1 4]
disp(a,"matrix a")
disp(a,"matrix a")
[r,e]=spec(a)
[r,e]=spec(a)
disp(r, "Eigenvectors")
disp([r,e],"Eigenvectors and
disp(e,"Eigenvalues")
Eigenvalues")

OUTPUT:
OUTPUT:
matrix a
matrix a
1 -i 3 + 4.i
2 1 1
i 2 4
1 3 2
3 – 4.i 4 3
3 1 4

Eigenvectors and Eigenvalues Eigenvectors


0.324 0.389 - 0.187i 0.389 + 0.187i -0.34 - 0.52i -0.27 + 0.55i -0.319 - 0.359i
0.585 0.54 + 0.272i 0.538 - 0.272i -0.45 + 0.05i -0.36 - 0.689i -0.425 - 0.05i
0.744 -0.67034 -0.670345 0.635 0.1023784 -0.7653665

Eigenvalues
6.095824 0. 0. -4.746829 0 0
0 1.4521 + 0.433i 0. 0 2.3968018 0
0 0 1.4521 - 0.433 0 0 8.3500273
2 -i 2i
i 4 3
-2i 3 5

INPUT:
clc;
a=[2 -%i 2*(%i) ;%i 4 3;-2*%i 3 5]
disp(a,"matrix a")
[r,e]=spec(a)
disp(r, "Eigenvectors")
disp(e,"Eigenvalues")

OUTPUT:

matrix a
2 -i 2.i
i 4 3
-2.i 3 5

Eigenvectors

0.6662617i -0.7255184i 0.1723904i

0.5184148 0.6168052 0.5922816

-0.5360424 -0.3052448 0.7870731

Eigenvalues

-0.3871996 0. 0.

0. 3.6916109 0.

0. 0. 7.6955887
2. Orthogonal polynomials as eigenfunctions of Hermitian differential operators.

Hermite Polynomials:
/
(−1) 𝑛! (2𝑥)
H (x) =
𝑘! (𝑛 − 2𝑘)!

Orthogonality relation:

0, n≠m
e H (x)H (x)dx =
√π2 n!, n=m

INPUT:
clc;
funcprot(0)
function y=H(n, x)
y=0
for i=0:floor(n/2)
y =y+((factorial(n)*((-1)^i)*(2*x)^(n-2*i))/(factorial(i)*factorial(n-2*i)))
end
endfunction
n=input("Order of Hermite Polynomial(n): ")
x=poly(0,"x");
disp(H(n,x),"Hermite Polynomial H(n,x)")
s=-2:0.0001:2
plot2d(s,H(n,s),5)

m=input("Order of 2nd Hermite Polynomial for orthogonality relation(m): ")


z= integrate('(exp(-(t)^2))*H(n,t)*H(m,t)','t',-100,100)
disp(z,"Orthogonality relation of Hermite Polynomials")

disp("Theoritical value")
if n==m then
disp(factorial(n)*(2^n)*sqrt(%pi))
else
disp(0)
end
OUTPUT:

Order of Hermite Polynomial(n): 3


Hermite Polynomial H(n,x)
-12x3 +8x

Order of 2nd Hermite Polynomial for orthogonality relation(m): 3

Orthogonality relation of Hermite Polynomials


85.077785

Theoritical value
85.077785
3. Determination of the principal axes of moment of inertia through diagonalization

( ) ( ) ( )
I𝒋𝒑 = m [δ (r ) −r r ]

INPUT:
clc;
clf();
n=input("no. of particles: ")
MI1=zeros(3,3);
MI2=zeros(3,3);
krocdelta=eye(3,3);
for i=1:n
m(i)=input("mass of particle " +string(i)+ " : ")
end
disp(m)
for i=1:n
for j=1:3
r(i,j)=input("coordinate " +string(j)+ " of particle "+string(i)+ " : ")
end
end
disp(r)
for j=1:3
for k=1:3
for i=1:n
MI1(j,k)=MI1(j,k)+m(i)*r(i,j)*r(i,k);
end
end
end
sqr=r'*r;
for j=1:3
for k=1:3
for i=1:n
MI2(j,k)=MI2(j,k)+m(i)*krocdelta(j,k)*sqr(k,k);

end disp("Moment of Inertia tensor")


end disp(MI)
end [R,v]=spec(MI)
MI=MI2-MI1 disp(R,"Principal axis")
OUTPUT:

no. of particles: 2

mass of particle 1 : 67
mass of particle 2 : 89
67. Moment of Inertia tensor
89.
541476. -36582. -10452.
coordinate 1 of particle 1 : 78 -36582. 4428. -1205.
coordinate 2 of particle 1 : 7 -10452. -1205. 959.
coordinate 3 of particle 1 : 2
coordinate 1 of particle 2 : 0 Principal axis
coordinate 2 of particle 2 : 1
coordinate 3 of particle 2 : 3 -0.0553779 -0.0431459 -0.9975328
-0.5906563 -0.8040893 0.0675692
78. 7. 2. -0.8050208 0.5929409 0.0190444
0. 1. 3.

4. Vector space of wave functions in Quantum Mechanics: Position and momentum


differential operators and their commutator, wave functions for stationary states
as eigenfunctions of Hermitian differential operator.

x=x
Commutator:
∂ [𝑎 , 𝑏]= 𝑎𝑏-𝑏𝑎
p = −iℏ
∂x

( )
[𝑥 ,𝑝̂ ]𝜓= x −iℏ − −iℏ =𝑖ℏ𝜓

Let us see the action of the commutator on legendre and hermite polynomials as
wavefunctions
1 d
Legendre Polynomial: P (x) = (x − 1) (Rodrigue s formula)
2 n! dx
/
(−1) 𝑛! (2𝑥)
Hermite Polynomial: H (x) =
𝑘! (𝑛 − 2𝑘)!

 To show [𝑥 ,𝑝̂ ] P (x) = 𝑖ℏP (x)

INPUT:

clc; disp(legendrepoly,"Legendre
x=poly(0,"x"); Polynomial");
p=(x^(2)-1);
n=input("order of polynomial: "); ///commutator
printf("the action of commutator on
///making legendre polynomial(Rodrigue's legendre polynomial of order %i",n);
formula)
for k=0:n z=-%i*x*derivat(legendrepoly); ///let
p=(x^(2)-1)^(k); hbar=1
end
if (n==0) then w=x*legendrepoly;
legendrepoly=p t=-%i*derivat(w);
else commutator=z-t;
y=derivat(p) disp(commutator)
for j=1:n-1
y=derivat(y)
end
legendrepoly=(y)/(factorial(n)*2^n)
end
OUTPUT:

order of polynomial: 4

Legendre Polynomial
0.375 -3.75𝑥 +4.375𝑥

the action of commutator on legendre polynomial of order 4

Real part
0

Imaginary part
0.375 -3.75𝑥 +4.375𝑥

 The output is 𝑖ℏP (x) (where ℏ=1)

 To show [𝑥 ,𝑝̂ ] H (x) = 𝑖ℏH (x)

INPUT:
clc; printf("the action of commutator on
funcprot(0) Hermite polynomial of order %i",n);
function y=H(n, x)
y=0 z=-%i*x*derivat(H(n,x)); //hbar=1
for i=0:floor(n/2) w=x*H(n,x);
y =y+((factorial(n)*((- t=-%i*derivat(w);
1)^i)*(2*x)^(n- commutator=z-t;
2*i))/(factorial(i)*factorial(n-2*i))) disp(commutator)
end
endfunction
n=input("Order of Hermite
Polynomial(n): ")
x=poly(0,"x");
disp(H(n,x),"Hermite Polynomial H(n,x)")
OUTPUT:
Order of Hermite Polynomial(n): 3

Hermite Polynomial H(n,x)


-12x +8𝑥

the action of commutator on Hermite polynomial of order 3

Real part
0
Imaginary part
-12x +8𝑥

 The output is 𝑖ℏH (x) (where ℏ=1)

5. Estimation of ground state energy and wave function of a quantum system.

 Particle in an infinite potential box

2 𝑛𝜋𝑥
𝑊𝑎𝑣𝑒𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛: 𝜓 (𝑥) = sin
𝑎 𝑎
𝑛 𝜋 ℏ
𝐸𝑛𝑒𝑟𝑔𝑦: 𝐸 =
2𝑚𝑎

n-state of the particle (n=1→ground state)


a-Length of the box
m-mass of the particle

INPUT:
clc; n=input("State(n),whose eigenvalue you
funcprot(0); seek: ")
hbar=6.626*10^(-34)/(2*%pi)
if d<20 then
a=input("Length of the box: ") disp("Answer would not be accurate,
m=input("Mass of the particle(in Kg): ") re-enter: ")
d=input("No. of divisions: ") d=input("No. of divisions: ")
end if j<d-1
k=hbar**2/m H(j,j+1)=-k
function potential=V(x) H(j+1,j)=-k
potential=0 end
endfunction end
RH=H/(2*(h**2))
xmax=a [ef,ev]=spec(RH)
xmin=0
h=(xmax-xmin)/d s=linspace(h,a,d-1)
plot2d(s,ef(:,n))
r=0 ///r≡x disp(nansum(ev(:,n)),"Eigenvalue of the
H=zeros(d-1,d-1) ///psi is zero at x=0 asked state")
and x=a(or dh)
for j=1:d-1 En=(n^2*(%pi)^2*hbar^2)/(2*m*(a^2))
r=r+h disp(En,"Theoritical value for the
H(j,j)=2*(k-V(r)*(h**2)) eigenvalue(i.e,energy)")

OUTPUT:

Length of the box: 12


Mass of the particle(in Kg): 0.000003

No. of divisions: 100


State(n),whose eigenvalue you seek: 1

Eigenvalue of the asked state


1.270D-64

Theoritical value for the


eigenvalue(i.e,energy)
1.270D-64

 So Ground state energy for


the particle = 1.270D-64

Graph of 𝝍𝟏 (𝒙) →

You might also like