Question

1. [2+1+1pt] Power Method and Inverse Iteration. (a) Implement the Power Method. Use your code to find an eigenvector of -2 1code in matlab

0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc

clear all

close all

format long

A=[-2,1,4;1,1,1;4,1,-2];

x0=[1;-2;-1];

disp('First 5 iterates for first x0 are');

[x,lam]=powerMethod(A,x0);

x0=[1;2;1];

disp('First 5 iterates for second x0 are');

[x,lam]=powerMethod(A,x0);

disp('Eigen vectors using eig are');

[E,~]=eig(A)

function [x,lam]=powerMethod(A,x)

%Power method for finding largest eigenvalue and eigenvector of A

maxIter = 5; %maximum no;of iterations

tol = 1e-10; %tolerance

converged = 0; %flag for convergence

  

n = length(A);

x = x/norm(x); %random vector for starting

iter = 1;

  

while (iter <=maxIter) %while still not converged and below maximum Iterations

x_old = x;

x = A*x;

x = x/norm(x)

lam = x'*A*x;

converged = (norm(x - x_old) < tol);

iter = iter + 1;

end

end

Add a comment
Know the answer?
Add Answer to:
code in matlab 1. [2+1+1pt] Power Method and Inverse Iteration. (a) Implement the Power Method. Use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT