n = 4;
A = [ 5 -2 -1 0; -2 5 -1 -1; -1 -1 4 -1; 0 -1 -1 5 ];
x0 = ones( n, 1 );
[ lambda1_c, x1, k_c ] = power_method( A, x0, 1e-6,100 );
lambda1_c
%   lambda1_c =
%       7.2589
k_c
%   k_c =
%       23

lambda1_ex = max( eig( A ) );
rel_err = abs( lambda1_c - lambda1_ex ) / abs( lambda1_ex )
%   rel_err =
%      7.9711e-07

invA = inv( A );
[ lambda1_inv_c, x1_inv, k_c ] = power_method( invA, x0, 1e-6, 100 );
lambdan_c = 1 / lambda1_inv_c
%   lambdan_c =
%       1.5919
k_c
%   k_c =
%        6

shift = 5;
[ lambda_s, x, k_c ] = power_method( A - shift * eye( n ), x0, 1e-6, 100 );
lambdan_c = lambda_s + shift
%   lambdan_c =
%    1.5919
k_c
%      k_c =
%      13