{"id":562,"date":"2017-09-14T13:38:08","date_gmt":"2017-09-14T16:38:08","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=562"},"modified":"2017-09-14T13:38:08","modified_gmt":"2017-09-14T16:38:08","slug":"power-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/power-m\/","title":{"rendered":"power.m"},"content":{"rendered":"<pre>% \r\n% Solution of Eigen-value problem using the Power Method\r\n%\r\n\r\nA = [2 -1 0 0;-1 2 -1 0;0 -1 2 -1; 0 0 -1 2] % coef matrix\r\ny = [1; 0; 0; 0]                             % starting vector\r\n\r\nfprintf('\\nPower Method Demonstration\\n\\n');\r\nhighlow = input('Determine highest (1) or lowest (2) eigenvalue: ');\r\n\r\nif highlow == 2  % lowest eigenvalue case: calc matrix inverse\r\n  A = inv(A);\r\nend;\r\n\r\nlambda_old = 1;\r\nerror = 1;\r\ncount = 0;\r\n\r\nwhile abs(error) &gt; 0.01\r\n  count = count + 1;\r\n\r\n  y = A * y;          % new eigenvalue\r\n  lambda = max(y);    % new lambda\r\n  y = y\/lambda;       % normalize\r\n\r\n  error = (lambda - lambda_old)\/lambda * 100;\r\n  lambda_old = lambda;\r\n  fprintf('# %i Lambda = %f Error = %f\\n',count,lambda, error);\r\nend;\r\n\r\nif highlow == 1\r\n  fprintf('\\nHighest eigenvalue is %f\\n',lambda);\r\nelse\r\n  fprintf('\\nLowest eigenvalue is %f\\n',1\/lambda);\r\nend;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>% % Solution of Eigen-value problem using the Power Method % A = [2 -1 0 0;-1 2 -1 0;0 -1 2 -1; 0 0 -1 2] % coef matrix y = [1; 0; 0; 0] % starting vector fprintf(&#8216;\\nPower Method Demonstration\\n\\n&#8217;); highlow = input(&#8216;Determine highest (1) or lowest (2) eigenvalue: &#8216;); if highlow == [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-562","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=562"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/562\/revisions"}],"predecessor-version":[{"id":563,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/562\/revisions\/563"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}