Hi, Read and have a complete understanding of the following information. You've to use the following information to solve three problem in MATLAB.      Description and Background
One method discussed here is to calculate the spectrum of a matrix is the "Pure" QR Algorithm, which produces an upper triangular matrix T for a given matrix A such that AU = T, where U is As T and A are similar, they have the same eigenvalues.
turns out that there are certain conditions on A necessary for convergence. While it is not da@ necessary for a matrix A to be real and symmetric, it can be shown that if this is the case then the QR Algorithm will always (eventually) converge. The original algorithm the following until convergence: repeated EDT
QRT-1 Determine the QR-Decomposition of the prior iteration
TRQUpdate to get closer to upper-triangular
UkUk-1QkUpdate the transformation matrix
At convergence you have the required relationship.
One method to improve the algorithm is to introduce a Wilkinson shift. Let mu_{k} be the shift, where k is an iteration the actual shift will be defined later. The iteration is then

Q_{k}R_{k} = T_{k-1}- mu_{k-1}I
T_{k} = R_{k}_Q_{k} + mu_{k-1}I 
U_{k} =  U_{k-1}Q_{k}
There are various choices for the shift, one of which we define here. Consider the portion of the matrix T_{k-1}:T_{k-1} = 

⎡ t_{1,1}     ⋯   t_{1,n-1}        t_{1,n}   ⎤
⎢  ⋮              ⋱                              ⋮       ⎥
⎢ t_{n-1},1  ⋯   t_{n-1},n-1   t_{n-1},n ⎥
⎣ t_{n,1}    ⋯    t_{n},{n-1}     t_{n,n}    ⎦     . Construct a 2x2 matrix containing the lower right portion of the matrix:                                                                                                             [ t_{n-1},n-1   t_{n-1},n ⎥
⎣ t_{n},{n-1}     t_{n,n}    ]. It is clear from this that there are upto two eigen values mu_{1} and mu_{2} for this matrix . We define the wilkinson shift as mu_{k} = mu_{1} if |mu_{1} -  t_{n,n}   | and mu_{k} = mu_{2} otherwise.                                                                                                                                                                                                 
Now based on the above provided information solve the Problems:
Note: You are allowed to use any functions provided in the base Matlab install function other than any which returns eigenvalues/eigenvectors. 
Problem 1: Construct a Matlab function [D, Q, iter] =  aboda_final_p1 (A, tol) based on the "Pure" QR Algorithm where A is a real and matrix, tol is the convergence tolerance, D is a matrix that contains the eigenvalues of A on the diagonal, Q is a unitary matrix such that Q^T AQ= D, and iter is the number of iterations necessary for convergence. To define convergence let T_{k,-1} be the first sub-diagonal of the matrix T_{k} as defined in the iteration above. Let T_{k,0} be the diagonal of the same. Consider the method as converged when ||T_{k,-1}||T_{k,0}||2 < tol. The first sub-diagonal of a matrix T can be obtain in Matlab via a diag (T, -1) call while the diagonal can be obtained via a diag(T) call.
8:
Problem 2: Construct a Matlab function [D, Q, iter] = aboda_final p2 (A, tol) based on the QR Algorithm with the Wilkinson shift described above. The inputs and outputs, in addition to the convergence criteria, are the same a Problem 1.
Problem 3: Construct a Matlab function [mu, var] = aboda_final_p3 (eigFunc, m, tol, which returns the mean and variance of the number of iterations necessary to compute the spectrum using a given function. The input eigFunc is a function handle to a spectrum calculation function with the same calls as in Problem 1 and 2, m is the size of the square matrix to use, tol is the tolerance to use in eigFunc, and N is the number of samples to take. On output mu will contain the average number of iterations and var will be the variance. For each iteration use the function rand to compute a random matrix of the appropriate size. To make it reproducible set a seed of 0 (see the Matlab documentation on how to do this). Hint: Be sure that the input matrix to eigFunc is symmetric!