{"id":464,"date":"2017-09-14T12:31:44","date_gmt":"2017-09-14T15:31:44","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=464"},"modified":"2017-09-14T12:31:44","modified_gmt":"2017-09-14T15:31:44","slug":"oneptrlx-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/oneptrlx-m\/","title":{"rendered":"oneptrlx.m"},"content":{"rendered":"<pre>% Demonstration of Gauss-Seidel (One Point Iteration) Root Finding\r\n%\r\n% The function is defined in the file 'fcn.m'. The contents of this file are:\r\n%\r\n%      function y = fcn(x)\r\n%      y = -1200\/(x^3 - 5*x^2 - 124*x + 380);\r\n\r\nfprintf('\\nDemonstration of One Point Iteration with relaxation\\n');\r\n\r\n       x = input ('Enter initial guess of root:        ');\r\n       w = input ('Enter relaxation factor:            ');\r\nmaxerror = input ('Enter maximum error (percent):      ');\r\n   maxit = input ('Enter maximum number of iterations: ');\r\n\r\nxinit = x;\r\nfor wloop = 1:14    % test out 0.1 &lt;= w &lt;= 1.4\r\n  x = xinit;\r\n  w = wloop * 0.1;\r\n  count = 0;   % iteration counter\r\n  error = 1;   % starting error (100 percent)\r\n\r\n%  fprintf('\\n Iteration      x    g(x)=xnew  error(percent)\\n\\n');\r\n\r\n  while (error &gt; maxerror) &amp; (count &lt; maxit)   % '&amp;' is logical AND\r\n    count = count + 1;\r\n    temp = fcn(x);\r\n    xnew = x + w * (temp - x);\r\n    error = abs((xnew - x)\/xnew) * 100;\r\n%   fprintf('%7g %10.4f %10.4f %10.4f\\n',count,x,xnew,error);\r\n    x = xnew;\r\n  end\r\n  wvect(wloop) = w;\r\n  countvect(wloop) = count;\r\n  fprintf('w = %g   # iter = %g\\n',w,count)\r\nend\r\n\r\nquickplt(wvect,countvect,'relaxation factor (w)','# of iterations',...\r\n         'optimal relaxation for one-point iteration')<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>% Demonstration of Gauss-Seidel (One Point Iteration) Root Finding % % The function is defined in the file &#8216;fcn.m&#8217;. The contents of this file are: % % function y = fcn(x) % y = -1200\/(x^3 &#8211; 5*x^2 &#8211; 124*x + 380); fprintf(&#8216;\\nDemonstration of One Point Iteration with relaxation\\n&#8217;); x = input (&#8216;Enter initial guess of [&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-464","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/464","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=464"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/464\/revisions"}],"predecessor-version":[{"id":465,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/464\/revisions\/465"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}