Description
Write a computer program for finding eigenvalues of a matrix A. The program should have the
following features:
Input: The program should read – (i) the elements of the matrix A, (ii) maximum iterations, (iii)
threshold on approximate relative error, and (iv) shifting scalar, if needed.
Options: The user should have the option of selecting one of the following methods–
a. Direct power method (to find the eigenvalue having the maximum magnitude and the
corresponding eigenvector)
b. Inverse power method (to find the eigenvalue having the minimum magnitude and the
corresponding eigenvector)
c. Shifted-power method (to find intermediate eigenvalues [based on Gershgorin disc]
and corresponding eigenvectors)
d. QR method (to find all eigenvalues of a matrix; write your own program for GramSchmidt process)
Output: The output from the program should be written in a text file. This file should contain
eigenvalues and the corresponding normalized eigenvectors (unit length) for options
(a) to (c), and only eigenvalues for option (d). Number of iterations required should
also be written as an output.
Note: Use a column vector of appropriate size with each element unity as the guess vector for
initiating the power methods.
Submission
Make a single zip folder with all your program file(s) name it roll number_CA3.zip (e.g., If your
roll number is 123456, the folder name should be ‘123456_CA3.zip’). The folder should include –
(i) All the computer program file(s), input file(s) and output file(s)
(ii) A PDF file of the plots and the solution of the test cases given in this assignment.
Upload the zip file on mooKIT. In case of any difficulties with mooKIT upload, you may email
the solution to eso208.sec*@gmail.com, where * is section number 1-10. Example: for section
J5, it is eso208.sec5@gmail.com; for section J10, it is eso208.sec10@gmail.com. The subject
line of the email should be same as your folder name.
2
Test data:
Sample input file
3
8.0 -1.0 -1.0
-1.0 4.0 -2.0
-1.0 -2.0 10.0
100
0.001
8.0
Sample output files
1. Direct power method
Eigenvalue
10.7787
Eigenvector
-0.2509
-0.2397
0.9379
Iterations
30
8 1 1
1 4 2
1 2 10
maximum iterations = 100
tolerance on approximate relative error (%) = 0.001
shifting scalar = 8.0
A
3
2. Inverse power method
Eigenvalue
3.0749
Eigenvector
0.2482
0.9205
0.3017
Iterations
12
3. Shifted power method
Eigenvalue
8.1461
Eigenvector
0.9356
-0.3085
0.1718
Iterations
6
4. QR method
Eigenvalues
10.7788
8.1462
3.0749
Iterations
23