{"id":443,"date":"2017-09-14T12:23:50","date_gmt":"2017-09-14T15:23:50","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=443"},"modified":"2017-09-14T12:23:50","modified_gmt":"2017-09-14T15:23:50","slug":"incsrch-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/incsrch-m\/","title":{"rendered":"incsrch.m"},"content":{"rendered":"<pre>% root finding by incremental search\r\n%\r\n% This uses the external function func1.m defined as follows\r\n%\r\n%      function f = func1(x)\r\n%         f = (x-4)*(x-10)*(x-20) + 1;\r\n%\r\n% This has roots near x = 4, 10, 20\r\n\r\nclear\r\n\r\n% get a quick plot of the function\r\nxp = linspace(0,25);\r\nyp = func1(xp);\r\nplot(xp,yp)\r\n\r\n\r\nx = input('Enter starting x value :');\r\nxinc = input('Enter x increment :');\r\neps = input('Enter desired absolute accuracy :');\r\n\r\nfalse = 0;\r\ntrue = 1;\r\n\r\nfound = false;\r\n\r\nwhile found == false\r\n   xup = x + xinc;\r\n   flow = func1(x);\r\n   fup = func1(xup);\r\n   \r\n   if flow == 0 | fup == 0\r\n      found = true;\r\n   elseif flow*fup &lt; 0\r\n      fprintf('root between %g and %g\\n',x,xup)\r\n      if xinc &lt; eps\r\n         found = true;\r\n      else\r\n         xinc = xinc \/ 10;\r\n         fprintf('Changing increment to %g\\n\\n',xinc)\r\n      end\r\n   else\r\n      x = xup;\r\n   end\r\nend\r\n   \r\nx\r\nflow\r\nxup\r\nfup\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>% root finding by incremental search % % This uses the external function func1.m defined as follows % % function f = func1(x) % f = (x-4)*(x-10)*(x-20) + 1; % % This has roots near x = 4, 10, 20 clear % get a quick plot of the function xp = linspace(0,25); yp = func1(xp); [&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-443","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/443","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=443"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/443\/revisions"}],"predecessor-version":[{"id":444,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/443\/revisions\/444"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}