{"id":469,"date":"2017-09-14T12:36:23","date_gmt":"2017-09-14T15:36:23","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=469"},"modified":"2017-09-14T12:36:23","modified_gmt":"2017-09-14T15:36:23","slug":"jacobi-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/jacobi-m\/","title":{"rendered":"jacobi.m"},"content":{"rendered":"<pre>% Illustration of Jacobi iteration\r\n%  (Also known as Method of Simultaneous Displacement)\r\n%\r\n% The goal is to determine a set of values of x1...x4 that \r\n% satisfy the following equations...\r\n%   f1(x1,x2,x3,x4) = -2*x1 +   x2               + 1.5 = 0\r\n%   f2(x1,x2,x3,x4) =    x1 - 2*x2 +   x3        - 0.5 = 0\r\n%   f3(x1,x2,x3,x4) =           x2 - 2*x3 + x4   - 0.5 = 0\r\n%   f4(x1,x2,x3,x4) =                  x3 - 2*x4 + 0.5 = 0\r\n%\r\n% We will take an x1 out of f1 and an x2 out of f2 and so on.\r\n%   x1 = g1(x1,x2,x3,x4) = (x2 + 1.5) \/ 2\r\n%   x2 = g2(x1,x2,x3,x4) = (x1 + x3 - 0.5) \/ 2\r\n%   x3 = g3(x1,x2,x3,x4) = (x2 + x4 - 0.5) \/ 2\r\n%   x4 = g4(x1,x2,x3,x4) = (x3 + 0.5) \/ 2\r\n%\r\n% These are defined in files 'lin_g1.m' through 'lin_g4.m'\r\n\r\nfprintf('\\nSolution of System of Equations using Jacobi iteration\\n');\r\n\r\n      x1 = input('Enter x1 estimate        : ');\r\n      x2 = input('Enter x2 extimate        : ');\r\n      x3 = input('Enter x3 estimate        : ');\r\n      x4 = input('Enter x4 extimate        : ');\r\nmaxerror = input('Enter max approx error   : ');\r\n   maxit = input('Enter max # of iterations: ');\r\n\r\ncount = 0;\r\nerror = 100;\r\nfprintf('\\niteration      x1           x2          x3           x4\\n');\r\n\r\nwhile (error &gt; maxerror) &amp; (count &lt; maxit)\r\n   count = count + 1;\r\n   x1new = lin_g1(x1,x2,x3,x4);\r\n   x2new = lin_g2(x1,x2,x3,x4);\r\n   x3new = lin_g3(x1,x2,x3,x4);\r\n   x4new = lin_g4(x1,x2,x3,x4);\r\n\r\n   error1 = abs(x1new - x1);\r\n   error2 = abs(x2new - x2);\r\n   error3 = abs(x3new - x3);\r\n   error4 = abs(x4new - x4);\r\n   error = max([error1,error2,error3,error4]);\r\n  \r\n   fprintf('%6i    %10.6f  %10.6f  %10.6f  %10.6f\\n',...\r\n             count,x1new,x2new,x3new,x4new);\r\n\r\n   x1 = x1new;                           % assign new values\r\n   x2 = x2new;\r\n   x3 = x3new;\r\n   x4 = x4new;\r\nend\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>% Illustration of Jacobi iteration % (Also known as Method of Simultaneous Displacement) % % The goal is to determine a set of values of x1&#8230;x4 that % satisfy the following equations&#8230; % f1(x1,x2,x3,x4) = -2*x1 + x2 + 1.5 = 0 % f2(x1,x2,x3,x4) = x1 &#8211; 2*x2 + x3 &#8211; 0.5 = 0 % [&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-469","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/469","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=469"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/469\/revisions"}],"predecessor-version":[{"id":470,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/469\/revisions\/470"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}