MATH304_HW04_20080373

MATH304_HW04_20080373 - hw04 Math304_Numerical Methods HW#4...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Math304_Numerical Methods HW#4 Due:26.03.2010 Seçkin Fidan 20080373 hw04 Page 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page 2
Background image of page 2
function [eigval,eigvec] = power_iter(A,qo) % Call : [lambda,v] = power_iter(A) or % [lambda,v] = power_iter(A,qo) - qo is the initial vector % % Task : Computes an eigenvalue and an associated % eigenvector of A using power iteration. [m,n] = size(A); error('A must be square') if m ~= n end if nargin < 2 qo = randn(n,1); end epsln = 10^-15; iter = 1; fprintf('The estimate of the eigenvalue at each iteration\n'); fprintf('------------------------------------------------\n'); qo = qo/norm(qo); q = A*qo; qold = qo; fprintf('iter %02.2d : %1.15f\n', iter, q'*A*q); while iter == 1 | (norm(q-qold) > epsln) qold = q; q = q/norm(q); iter = iter+1; q = A*qold; end eigvec = q; eigval = q'*A*q; return (a) >> B1 = [ 1 0 1; 0 -0.8 0; 1 0 1] B1 = 1.0000 0 1.0000 0 -0.8000 0 1.0000 0 1.0000 >> [a,b] = power_iter(B1) The estimate of the eigenvalue at each iteration
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

MATH304_HW04_20080373 - hw04 Math304_Numerical Methods HW#4...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online