this project is about matlab

Job ID: 35171353

Budget: $10 – $30 USD

Write a MATLAB function, [lam, v, error] = poweriter(A, v0), to implement the Power
Iteration algorithm in the note to compute the largest eigenvalue (in modulus) of A and
its corresponding eigenvector. In the inputs, A is a real symmetric matrix, v0 is an initial
vector of unit length. In the outputs, lam is the computed eigenvalue, v is the eigenvector,
and error is a vector containing the values kAv
(k)−λ
(k)v
(k)k2 at each step of the algorithm.
Stop the iteration when error(k) ≤ 10−6
.
Test your code on a small problem to make sure it is correct.
2. Write a MATLAB function, [lam, v, error] = inverseiter(A, v0, mu), to implement the
Inverse Iteration algorithm to compute an eigenvalue (closest to mu) of A and its corresponding eigenvector. In the inputs, mu is an initial guess of the eigenvalue. A, v0,
lam, v, error have the same meanings as in Question 1. Also stop the iteration when
error(k) ≤ 10−6
.
Test your code on a small problem.
3. Write a Matlab function, [lam, v, error] = Rayleigh(A, v0), to implement the Rayleigh
Quotient algorithm to compute an eigenvalue of A and its corresponding eigenvector.
Also test your code on a small problem.
4. Generate a 500 × 500 matrix A by
m = 500;
[Q,R] = qr( rand(m) );
Lambda = diag(m:-1:1);
A = Q * Lambda * Q’
Then we know that the eigenvalues of A are m, m − 1, · · · , 1, with corresponding eigenvectors on columns of Q.
(a) Apply on A the functions poweriter, inverseiter, and Rayleigh, respectively, to compute
a pair of eigenvalue and eigenvector. The initial guess vector v0 can be taken as
v0 = ones(m,1). The input mu in inverseiter can be chosen as m − 0.2, such that it
converges to the largest eigenvalue m.
(b) Plot the three error vectors, error, obtained from the three algorithms, respectively,
in the same figure. The x-axis in your graph correspond to the dimension of the error
vector; the y-axis represent the values of error. For the plot, use loglog (log scale in
both x- and y- axes) to catch the behavior of convergence.
From your plot, which algorithm converges the fastest, which is the slowest?
How many iterations does each algorithm take to reach the convergence
Related categories: Matlab and Mathematica Algorithm