{"id":462,"date":"2017-09-14T12:31:21","date_gmt":"2017-09-14T15:31:21","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=462"},"modified":"2017-09-14T12:31:21","modified_gmt":"2017-09-14T15:31:21","slug":"oneptrx-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/oneptrx-m\/","title":{"rendered":"oneptrx.m"},"content":{"rendered":"<pre>% Demonstration of One Point Iteration WITH RELAXATION\r\nclear;\r\n\r\n% define the function and its x = g(x) version\r\nf = 'x^4 - 5*x^3 - 124*x^2 + 380*x + 1200';\r\n% version 1 of g(x)\r\ndisp('Version 1 of g')\r\ng = '-1200\/(x^3 - 5*x^2 - 124*x + 380)';\r\n% version 2 of g(x)\r\n%disp('Version 2 of g')\r\n%g = '(5*x^3 + 124*x^2 - 380*x - 1200)\/x^3';\r\n% version 3 of g(x)\r\n%disp('Version 3 of g')\r\n%g = '(-x^4 + 5*x^3 - 380*x - 1200)\/(-124*x)';\r\n\r\n\r\n       x = input ('Enter initial guess of root : ');\r\n       W = input ('Enter relaxation factor W   : ');\r\nmaxerror = 0.1; % maximum error\r\n   maxit = 30;  % maximum number of iterations\r\n   count = 0;   % iteration counter\r\n   error = 1;   % starting error (100 percent)\r\n\r\nfprintf('\\n Iteration      x       g(x)     error(%%)    f(x)\\n\\n');\r\n\r\n% this is where all the work gets done.....\r\n\r\nwhile (error &gt; maxerror) &amp; (count &lt; maxit)\r\n  count = count + 1;\r\n  temp = eval(g);\r\n\r\n  xnew = x + W*(temp - x);\r\n\r\n  error = abs((xnew - x)\/xnew) * 100;\r\n  fprintf('%7g %10.4f %10.4f %10.4f  %10.4f\\n',count,x,xnew,error,eval(f));\r\n  x = xnew;\r\nend\r\n\r\nfprintf('\\nRoot is %g   Function at root is %g\\n',x,eval(f))\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>% Demonstration of One Point Iteration WITH RELAXATION clear; % define the function and its x = g(x) version f = &#8216;x^4 &#8211; 5*x^3 &#8211; 124*x^2 + 380*x + 1200&#8217;; % version 1 of g(x) disp(&#8216;Version 1 of g&#8217;) g = &#8216;-1200\/(x^3 &#8211; 5*x^2 &#8211; 124*x + 380)&#8217;; % version 2 of g(x) %disp(&#8216;Version 2 [&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-462","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/462","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=462"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/462\/revisions"}],"predecessor-version":[{"id":463,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/462\/revisions\/463"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}