You are on page 1of 11

ATMA RAM SANATAN

DHARMA COLLEGE

By – Devesh Sharma
Roll no – 86034
Program – BSc (H) Physics
Semester – 5th

Submitted to – Dr. Ashutosh Vishwabandhu


Mr. Mohd. Sadiq
PRACTICAL – 1.a
AIM:
To find out the largest Eigenvalues and Eigenvectors of given matrices using Power
Method.

THEORY:
Power method is used to approximate the largest eigenvalue using iterations. First, we assume that the
matrix A has a dominant eigenvalue with corresponding dominant eigenvectors. Then we choose an
initial approximation of one of the dominant eigenvectors of A. This initial approximation must be a
nonzero vector in Rn.
Finally, we form the sequence given by –
X1 = AX0
X2 = AX1 = A(AX0) = A2X0
X3 = AX2 = A(A2X0) = A3X0
...
Xk = AXk-1 = A(Ak-1X0) = AkX0

For large powers of k, and by properly scaling this sequence, we will see that we obtain a good
approximation of the dominant eigenvector of A.

PROGRAM:
I) For Matrix
2 1 1
(1 3 2 )
3 1 4
clc
clear
A = [2 1 1;1 3 2;3 1 4]
[X,y] = spec(A)
disp(y)
X0 = [1;1;0]
for i = 1:15
B = A*X0
n = max(abs(B))
X0 = B/n
end
disp("Largest Eigenvalue by power method")
disp(n)
disp("Eigenvector against largest eigenvalue")
disp(X0)

II) For Matrix


1 − 𝑖 3 + 4𝑖
( 𝑖 2 4 )
3 − 4𝑖 4 3
B = [1 complex(0,-1) complex(3,4); complex(0,1) 2 4; complex(3,-4) 4 3]
[X1,y1] = spec(B)
disp("Eigenvalues by Spec")
disp(y1)
X0 = [1;1;0]
for i = 1:15
C = B*X0
n1 = max(abs(C))
X0 = C/n1
end
disp("Largest Eigenvalue by power method ")
disp(n1)
disp("Eigenvector against largest eigenvalue")
disp(X0)

III) For Matrix


2 −𝑖 2𝑖
(𝑖 4 3)
−2𝑖 3 5
B = [2 complex(0,-1) complex(0,2);complex(0,1) 4 3;complex(0,-2) 3 5]
[X1,y1] = spec(B)
disp(y1)
X0 = [1;1;0]
for i = 1:15
C = B*X0
n1 = max(abs(C))
X0 = C/n1
end
disp("Largest Eigenvalue by power method ")
disp(n1)
disp("Eigenvector against largest eigenvalue")
disp(X0)

OUTPUT:
I
Eigenvalues by Spec
6.095824 0. 0.
0. 1.452088 + 0.4336988i 0.
0. 0. 1.452088 - 0.4336988i

Largest Eigenvalue by power method

6.095824

Eigenvector against largest eigenvalue

0.4362882
0.7869595
1.
II

Eigenvalues by Spec

-4.746829 0. 0.
0. 2.3968018 0.
0. 0. 8.3500273

Largest Eigenvalue by power method

8.3543765

Eigenvector against largest eigenvalue

0.5908225 + 0.209909i
0.5189118 - 0.209909i
0.8766081 - 0.4812049i
III
Eigenvalues by Spec
-0.3871996 0. 0.
0. 3.6916109 0.
0. 0. 7.6955887

Largest Eigenvalue by power method

7.6956222

Eigenvector against largest eigenvalue

0.0612283 + 0.210286i
0.7225442 - 0.210286i
0.9601535 - 0.2794731i

RESULT –
We obtained the required the eigenvalues of given matrices by using Power method

Largest eigenvalue for matrix I : 6.095824


Largest eigenvalue for matrix II: 8.3543765
Largest eigenvalue for matrix III: 7.6956222
PRACTICAL – 1.b
AIM:
To find out the largest Eigenvalues and Eigenvectors of given matrices using QR
Method.

THEORY:
The QR algorithm computes a Schur decomposition of a matrix. The QR algorithm consists of two
separate stages. First, by means of a similarity transformation, the original matrix is transformed in a
finite number of steps to Hessenberg form or – in the Hermitian/symmetric case – to real tridiagonal
form. This first stage of the algorithm prepares its second stage, the actual QR iterations that are
applied to the Hessenberg or tridiagonal matrix.

We notice first that


Ak = RkQk = Q*k Ak-1Qk

and hence Ak and Ak−1 are unitarily similar. The matrix sequence {Ak} converges (under certain
assumptions) towards an upper triangular matrix with diagonal elements its eigenvalues.

PROGRAM:
I) For Matrix
2 1 1
(1 3 2 )
3 1 4
lc
A = [2 1 1;1 3 2;3 1 4]
for i = 1:100
[Q,R] = qr(A)
A = R*Q
disp(A)
end
disp(diag(A))

II) For Matrix


1 − 𝑖 3 + 4𝑖
( 𝑖 2 4 )
3 − 4𝑖 4 3

A = [1 complex(0,-1) complex(3,4); complex(0,1) 2 4; complex(3,-4) 4 3]


for i = 1:100
[Q,R] = qr(A)
A = R*Q
end

a = diag(A)
disp("Eigenvalues evaluated by QR method")
disp(a)

III) For Matrix


2 −𝑖 2𝑖
(𝑖 4 3)
−2𝑖 3 5

A = [2 complex(0,-1) complex(0,2);complex(0,1) 4 3;complex(0,-2) 3 5]


for i = 1:100
[Q,R] = qr(A)
A = R*Q
end

a = diag(A)
disp("Eigenvalues evaluated by QR method")
disp(a)

OUTPUT:
I

Eigenvalues evaluated by QR method

6.095824

1.770067

1.134109

II

Eigenvalues evaluated by QR method

8.3500273

-4.746829 + 1.786D-16i

2.3968018 + 1.497D-16i
III

Eigenvalues evaluated by QR method

7.6955887

3.6916109 ,

-0.3871996

RESULT –
We obtained the required the eigenvalues of given matrices by using QR method
Largest eigenvalue for matrix I : 6.095824
Largest eigenvalue for matrix II: 8.3500273
Largest eigenvalue for matrix III: 7.6955887
PRACTICAL – 2.a
AIM:
To show that eigenfunctions of legendre operator give orthogonal polynomial.

THEORY:
We know Legendre equation, which is:

We can write it as:


= 𝑙(𝑙 + 1)𝑦
We can consider legendre operator as:

𝜙=
Then we can write legendre equation as:

𝜙y = λy . . . . . . . . . (1)
Where, λ = 𝑙(𝑙 + 1)
Equation (1) looks like an eigenvalue problem. Hence, we can solve it as eigen value problem and we will
get Legendre polynomials as eigenfunction of legendre operator. Also, the eigenvalue would be 𝑙(𝑙 + 1).

We can construct Legendre operator by using finite difference formula:

Central difference formula for single derivative - [f]’(x)={f(x+h)-f(x-h).}/2h + O[ℎ2 ]

Central difference formula for double derivative - [f]”(x)={f(x+h)-2f(x)+f(x-h).}/ℎ2 + O[ℎ2 ]

CODE:
clc //clearing console
clear //clearing variables from previous workspace
clf //clearing graph window
x = -1:0.1:1 //creating array from -1 to 1 with stepsize 0.1
n = length(x) //length of array
I = eye(n,n)
Xmat = diag(x) //dreating diagonal matrix fro array points
A=zeros(n,n)
v=zeros(n,n)
A(1,[1:2])=[-2,1]; //creating matrix for double derivative operator
A(n,[n-1:n])=[1,-2];
for i=2:n-1
A(i,[ i-1:i+1])=[1,-2,1];
end
B=zeros(n,n) //creating matrix for single derivative operator
B(1,[1:2])=[0,1];
B(n,[n-1:n])=[-1,0];
for i=2:n-1
B(i,[i-1:i+1])=[-1,0,1];
end
L = (Xmat*Xmat -I)*(A/0.01) + (2*Xmat)*(B/0.2) //generating legendre operator
p2 = 0.5*(3*x.*x - 1) //creating array for second order legendre polynomial to be operated on
disp(p2)
e = L*p2' //operating legendre operator on legendre polynomial
plot(x,6*p2,'b*') //plotting legendre polynomial multiplied with its eigenvalue
plot(x,e,'r--') //plotting legendre operator operated upon legendre polynomial
legend("L.y","$\lambda.y$")

OUTPUT

RESULT
We plotted legendre polynomial after being operated by legendre operator and legendre polynomial
multiplied by its eigen value (6). We can clearly observe that both the plots overlap each other. Hence
we can conclude that 𝜙y = λy.

Since legendre polynomials are orthogonal polynomial, we can say that eigenfunctions of legendre
operator gives orthogonal polynomials.
PRACTICAL – 2.b
AIM
To show that eigenfunctions of Hermitian operator give orthogonal polynomial.

THEORY
Let us consider Hermite function:

We can also write it as:


= −𝜆𝑦

𝑑2 𝑑
Where, 𝜙 = 𝑑𝑥 − 2𝑥 𝑑𝑥 is Hermitian operator and −𝜆 its eigenvalue.

We can solve Hermite equation as eigenvalue problem using Hermitian operator and Hermite
polynomial as its eigenfunction.

We can write double derivative and single derivative in matrix form by using finite difference
method.

Central difference formula for single derivative - [f]’(x)={f(x+h)-f(x-h).}/2h + O[ℎ2 ]


Central difference formula for double derivative - [f]”(x)={f(x+h)-2f(x)+f(x-h).}/ℎ2 + O[ℎ2 ]
We can work with matrices in scilab to solve the hermite equation as eigenvalue problem and
can check for hermite polynomials as its eigenfunction which is an orthogonal polynomial

CODE
OUTPUT

RESULT
Hence, we operated Hermite polynomial with Hermitian Operator and found out that it gives
Hermite polynomial multiplied with a constant number. Hence, Hermite polynomial is eigen
function of the Hermitian Operator. Also, we know that Hermite polynomial is an orthogonal
polynomial. Hence, eigenfunctions of Hermitian Operator are Orthogonal polynomials.

You might also like