{"id":520,"date":"2017-09-14T13:17:12","date_gmt":"2017-09-14T16:17:12","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=520"},"modified":"2017-09-14T13:17:12","modified_gmt":"2017-09-14T16:17:12","slug":"simpdemo-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/simpdemo-m\/","title":{"rendered":"simpdemo.m"},"content":{"rendered":"<pre>% Simpson's rule integration demo\r\n\r\nfprintf('\\n Simpsons 1\/3 rule integration demo\\n');\r\n\r\nn = 2;\r\nolderror = 1;\r\nfprintf('\\n  n        integral       error      fract prev error    flops\\n\\n');\r\nwhile n &lt; 32768\r\n  flops(0);         % floating point count to zero\r\n  t = clock;        % current time\r\n\r\n  a = 0;\r\n  b = pi;\r\n  h = (b-a)\/n;\r\n  x = a:h:b;\r\n  y = sin(x);\r\n  simpint = simp0(y,h);\r\n\r\n  error = 2.0 - simpint;  % exact result of integral is 2.0\r\n  ratio = error\/olderror;\r\n  olderror = error;\r\n  fprintf('%6.0f %14.9f %14.5e %10.3f % 14.0f\\n',n,simpint,error,ratio,flops);\r\n\r\n  n = n*2;\r\nend;\r\n\r\nfprintf('\\nelapsed time: %4.2f\\n\\n',etime(clock,t));<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>% Simpson&#8217;s rule integration demo fprintf(&#8216;\\n Simpsons 1\/3 rule integration demo\\n&#8217;); n = 2; olderror = 1; fprintf(&#8216;\\n n integral error fract prev error flops\\n\\n&#8217;); while n &lt; 32768 flops(0); % floating point count to zero t = clock; % current time a = 0; b = pi; h = (b-a)\/n; x = a:h:b; y [&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-520","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/520","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=520"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/520\/revisions"}],"predecessor-version":[{"id":521,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/520\/revisions\/521"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}