Docsity

2 Problems for Exam - Numerical Analysis | MCS 471, Exams of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
MCS 471 - Computer Problem 2
Write a Matlab function, called myeig, to implement the shifted inverse power method for the
eigenvalue problem Ax =λx. The value of the shifted parameter is αand is input by the user.
Recall how one might guess the values of α. For example, if α=0, then this iteration method
yields the smallest (in absolute value) eigenvalue and its corresponding eigenvector.
The inputs into the function should be the matrix A, the value of α, and the initial starting
vector for the iteration. The outputs should be the approximation to the smallest eigenvalue and
its corresponding eigenvector.
To invert the matrix Ain the iteration use Matlab’s LU decomposition command a nd
then invert the Land Useparately. The stopping criterion is when the 2 norm of the difference
between two consecutive eigenvector iterates is less than 10−4. Compare your results with the
results obtained using the build-in Matlab command eig:
[lambda, v] = eig(A)
1. Test your program on:
A=
2.5−2.53.00.5
0.05.0−2.02.0
−0.5−0.54.02.5
−2.5−2.55.03.5
Use the shifts α=0,2.5,4.5and an initial vector with all ones.
2. Consider
A=
011 −5
−217 −7
−426−10
Use the shift α=0,4.2and the starting vector (1,2,1)0. Repeat using the same shifts but
with the starting vector (1,1,1)0. Write a short report describing the outcome.
Here is a crude program for the power method
a = [ 0 11 -5;-2 17 -7; -4 26 -10]
x = [1 1 1]’
err = 1;
while(err-0.001 >=0)
y = a*x;
c1 = norm(y,inf);
y = y/c1;
err = norm(y-x);
x=y;
end
x
c1

Partial preview of the text

Download 2 Problems for Exam - Numerical Analysis | MCS 471 and more Exams Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

MCS 471 - Computer Problem 2

Write a Matlab function, called myeig , to implement the shifted inverse power method for the eigenvalue problem Ax = λx. The value of the shifted parameter is α and is input by the user. Recall how one might guess the values of α. For example, if α = 0, then this iteration method yields the smallest (in absolute value) eigenvalue and its corresponding eigenvector. The inputs into the function should be the matrix A, the value of α, and the initial starting vector for the iteration. The outputs should be the approximation to the smallest eigenvalue and its corresponding eigenvector. To invert the matrix A in the iteration use Matlab’s LU decomposition command and then invert the L and U separately. The stopping criterion is when the 2 norm of the difference between two consecutive eigenvector iterates is less than 10 −^4. Compare your results with the results obtained using the build-in Matlab command eig:

[lambda, v] = eig(A)

  1. Test your program on:

A =

Use the shifts α = 0, 2. 5 , 4. 5 and an initial vector with all ones.

  1. Consider

A =

Use the shift α = 0, 4. 2 and the starting vector (1, 2 , 1)^0. Repeat using the same shifts but with the starting vector (1, 1 , 1)^0. Write a short report describing the outcome.

Here is a crude program for the power method

a = [ 0 11 -5;-2 17 -7; -4 26 -10] x = [1 1 1]’ err = 1; while (err-0.001 > = 0) y = a*x; c1 = norm(y,inf); y = y/c1; err = norm(y-x); x=y; end x c