{"id":145,"date":"2017-09-13T10:29:17","date_gmt":"2017-09-13T13:29:17","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=145"},"modified":"2017-09-13T10:29:17","modified_gmt":"2017-09-13T13:29:17","slug":"newton1-f","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/newton1-f\/","title":{"rendered":"newton1.f"},"content":{"rendered":"<pre>c&lt;html&gt;\r\nc&lt;head&gt;&lt;title&gt;newton1.f&lt;\/title&gt;&lt;\/head&gt;\r\nc&lt;body&gt;\r\nc&lt;pre&gt;\r\n      program newton\r\nc\r\nc   Use a Newton iteration to solve the equation\r\nc\r\nc   John Mahaffy  2\/14\/95\r\nc\r\nc     x**3+x-10=0\r\nc\r\nc    x    -     current approximation to the solution\r\nc    f(x) -     x**3+x-10\r\nc    dfdx    -  derivative of f with respect to x\r\nc    xo    -    previous guess for solution\r\nc    eps   -    convergence criterion\r\nc    dx    -    change in solution approximation\r\nc    it    -    number of iterations\r\nc    itmax -    maximum number of iterations\r\nc\r\nc\r\n      implicit none\r\n      real x,f,dfdx,xo,eps,fx,dx,abs\r\n      integer it,itmax                                              \r\nc\r\nc\r\nc     Now start executable fortran statements\r\nc\r\n      eps=1.e-5\r\n      itmax=10\r\n      print *,'What is your initial guess for the solution?'\r\n      read *, x\r\n      xo= x*(1+10.*eps)\r\n      it=0\r\nc     &lt;a name=1&gt;&lt;font color=FF0000&gt;\r\n      do while (abs(x-xo).gt.eps*abs(x).and.it.le.itmax)\r\nc                ^^^^^^^^^^^^^^^^^^^^^       &lt;\/font&gt;&lt;\/a&gt;\r\n\t it=it+1\r\n         xo=x\r\n         fx=f(xo,dfdx)\r\nc             ^^^^^^^\r\nc                ^  This area between the parentheses is often refered to as the\r\nc                ^  calling sequence, and contains arguments passed as input to\r\nc                ^  the function and passed back as output from the function\r\nc \r\n         dx = -fx\/dfdx\r\n         x=xo+dx\r\n         print *, ' x = ',x,',  f(x) = ',fx, ', dx = ',dx\r\nc&lt;a name=\"ed\"&gt;&lt;font color=\"FF0000\"&gt;\r\n         end do\r\nc&lt;\/a&gt;&lt;\/font&gt;\r\n      stop\r\n      end\r\n      function f(x,deriv)\r\nc                ^^^^^^^\r\nc                ^  These are the \"dummy\" arguments of the function.  They need not be the\r\nc                ^  same variable names as those appearing in the calling sequence\r\nc                ^  where the function is referenced.  However the number of arguments\r\nc                ^  here should match the number in the reference to the function.\r\nc                ^  It is also very important to match the data types between corresponding\r\nc                ^  arguments here and in the calling sequence.\r\nc\r\nc   Evaluate the function f(x)=x**3+x-10\r\nc   also return the derivative of the function\r\nc                                             \r\n      implicit none\r\n      real f,x,deriv\r\nc\r\nc   John Mahaffy  2\/14\/95\r\nc\r\nc   Function arguments can receive data from the line of the program calling \r\nc   the function, but can also pass data back to the program using the function.\r\nc   Documentation of arguements should clearly delimit those receiving input for\r\nc   the function from those transmitting output.\r\nc\r\nc   INPUT\r\nc        \r\nc   x   -   independent variable\r\nc\r\nc   OUTPUT\r\nc\r\nc   f     -   value of the function\r\nc   deriv -   derivative of the function with respect to x\r\nc\r\n      deriv=3*x**2+1\r\n      f=x**3+x-10\r\n      return\r\nc&lt;a name=\"end\"&gt;&lt;font color=\"FF0000\"&gt;\r\n      end\r\nc&lt;\/font&gt;&lt;\/a&gt;\r\nc&lt;\/pre&gt;\r\nc&lt;\/body&gt;\r\nc&lt;\/html&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>c&lt;html&gt; c&lt;head&gt;&lt;title&gt;newton1.f&lt;\/title&gt;&lt;\/head&gt; c&lt;body&gt; c&lt;pre&gt; program newton c c Use a Newton iteration to solve the equation c c John Mahaffy 2\/14\/95 c c x**3+x-10=0 c c x &#8211; current approximation to the solution c f(x) &#8211; x**3+x-10 c dfdx &#8211; derivative of f with respect to x c xo &#8211; previous guess for solution c [&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-145","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/145","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=145"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/145\/revisions"}],"predecessor-version":[{"id":146,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/145\/revisions\/146"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}