<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Newton Rhapson - this one</title>
    <link>http://www.mapleprimes.com/questions/39589-Newton-Rhapson--This-One</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Thu, 11 Jun 2026 19:31:53 GMT</lastBuildDate>
    <pubDate>Thu, 11 Jun 2026 19:31:53 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Newton Rhapson - this one</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Newton Rhapson - this one</title>
      <link>http://www.mapleprimes.com/questions/39589-Newton-Rhapson--This-One</link>
    </image>
    <item>
      <title>evaluate f at point x</title>
      <link>http://www.mapleprimes.com/questions/39589-Newton-Rhapson--This-One?ref=Feed:MaplePrimes:Newton Rhapson - this one:Comments#answer72330</link>
      <itunes:summary>&lt;p&gt;You're using f/D(f) as the correction term. But you need both of those operators f and D(f) to actually be evaluated at the point x.&lt;/p&gt;
&lt;p&gt;Also, you can't have f be a parameter of procedure NR1 as well as a local variable. I deleted it as the latter.&lt;/p&gt;
&lt;pre&gt;
&amp;gt; NR1:= proc(f,x0,N)
&amp;gt; local x,k:
&amp;gt;  x := x0:
&amp;gt;  for k to N do:
&amp;gt;    x := x-f(x)/D(f)(x)
&amp;gt;  end do:
&amp;gt;   evalf(x):
&amp;gt;  end proc:

&amp;gt; f:= x-&amp;gt; x^2-2:

&amp;gt; NR1(f,1,10);
                                  1.414213562
&lt;/pre&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;You're using f/D(f) as the correction term. But you need both of those operators f and D(f) to actually be evaluated at the point x.&lt;/p&gt;
&lt;p&gt;Also, you can't have f be a parameter of procedure NR1 as well as a local variable. I deleted it as the latter.&lt;/p&gt;
&lt;pre&gt;
&amp;gt; NR1:= proc(f,x0,N)
&amp;gt; local x,k:
&amp;gt;  x := x0:
&amp;gt;  for k to N do:
&amp;gt;    x := x-f(x)/D(f)(x)
&amp;gt;  end do:
&amp;gt;   evalf(x):
&amp;gt;  end proc:

&amp;gt; f:= x-&amp;gt; x^2-2:

&amp;gt; NR1(f,1,10);
                                  1.414213562
&lt;/pre&gt;
&lt;p&gt;acer&lt;/p&gt;</description>
      <guid>72330</guid>
      <pubDate>Mon, 14 Apr 2008 22:38:33 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>Newton-Raphson</title>
      <link>http://www.mapleprimes.com/questions/39589-Newton-Rhapson--This-One?ref=Feed:MaplePrimes:Newton Rhapson - this one:Comments#answer72329</link>
      <itunes:summary>&lt;p&gt;There are several problems with your procedure.&lt;/p&gt;
&lt;p&gt;1) You have both a formal parameter f and a local variable f.&lt;br /&gt;
Get rid of the local variable.&lt;/p&gt;
&lt;p&gt;2) You need f(x)/D(f)(x) instead of f/D(f).&lt;/p&gt;
&lt;p&gt;3) It's probably a good idea to use floating point throughout on this.&lt;br /&gt;
I've seen students crash Maple in a Newton-Raphson loop, getting rational numbers&lt;br /&gt;
with huge numerators and denominators.&amp;nbsp; So make it &lt;/p&gt;
&lt;p&gt;x := evalf(x - f(x)/D(f)(x));&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;There are several problems with your procedure.&lt;/p&gt;
&lt;p&gt;1) You have both a formal parameter f and a local variable f.&lt;br /&gt;
Get rid of the local variable.&lt;/p&gt;
&lt;p&gt;2) You need f(x)/D(f)(x) instead of f/D(f).&lt;/p&gt;
&lt;p&gt;3) It's probably a good idea to use floating point throughout on this.&lt;br /&gt;
I've seen students crash Maple in a Newton-Raphson loop, getting rational numbers&lt;br /&gt;
with huge numerators and denominators.&amp;nbsp; So make it &lt;/p&gt;
&lt;p&gt;x := evalf(x - f(x)/D(f)(x));&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <guid>72329</guid>
      <pubDate>Mon, 14 Apr 2008 22:47:27 Z</pubDate>
      <itunes:author>Robert Israel</itunes:author>
      <author>Robert Israel</author>
    </item>
    <item>
      <title>Newton's method again</title>
      <link>http://www.mapleprimes.com/questions/39589-Newton-Rhapson--This-One?ref=Feed:MaplePrimes:Newton Rhapson - this one:Comments#answer71507</link>
      <itunes:summary>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;The discussion here is very interesting and useful. I still have a question regarding the Newton's method iteration or any other iteration. how can I implement the proc above for a function like : f(x) = sqrt(x-r)&amp;nbsp; for x&amp;gt;= r and f(x) = - sqrt(r-x)&amp;nbsp; for x&amp;lt;= r, where r is any ( choosen) real number. I know this function does not converge. and I want to see the result as output=plot.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks to all&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;The discussion here is very interesting and useful. I still have a question regarding the Newton's method iteration or any other iteration. how can I implement the proc above for a function like : f(x) = sqrt(x-r)&amp;nbsp; for x&amp;gt;= r and f(x) = - sqrt(r-x)&amp;nbsp; for x&amp;lt;= r, where r is any ( choosen) real number. I know this function does not converge. and I want to see the result as output=plot.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks to all&lt;/p&gt;</description>
      <guid>71507</guid>
      <pubDate>Sat, 24 May 2008 23:49:38 Z</pubDate>
      <itunes:author>adnan06</itunes:author>
      <author>adnan06</author>
    </item>
    <item>
      <title>Without procedures</title>
      <link>http://www.mapleprimes.com/questions/39589-Newton-Rhapson--This-One?ref=Feed:MaplePrimes:Newton Rhapson - this one:Comments#answer67346</link>
      <itunes:summary>&lt;p&gt;Hi all the discussions above have procedures. &lt;/p&gt;
&lt;p&gt;Is it possible to code in Newton's Method without using procedures?&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Hi all the discussions above have procedures. &lt;/p&gt;
&lt;p&gt;Is it possible to code in Newton's Method without using procedures?&lt;/p&gt;</description>
      <guid>67346</guid>
      <pubDate>Wed, 25 Feb 2009 18:15:29 Z</pubDate>
      <itunes:author>Jabz</itunes:author>
      <author>Jabz</author>
    </item>
    <item>
      <title>Newton's method</title>
      <link>http://www.mapleprimes.com/questions/39589-Newton-Rhapson--This-One?ref=Feed:MaplePrimes:Newton Rhapson - this one:Comments#answer67342</link>
      <itunes:summary>&lt;p&gt;Without using a procedure, it can be done just by executing the body of a procedure.&lt;/p&gt;
&lt;p&gt;For example, if you need to find a root of x^4+3*x^3-x-10=0 correct to 8 decimal places, with initial approximation x0=-3.2, that can be done as&lt;/p&gt;
&lt;pre&gt;
f:=x-&amp;gt;x^4+3*x^3-x-10:
x:=-3.2:
n:=8:
while f(x-0.5*0.1^n)*f(x+0.5*0.1^n)&amp;gt;0 do 
    x:=x-f(x)/D(f)(x) od;

                          x := -3.206173582

                          x := -3.206142669
&lt;/pre&gt;
&lt;p&gt;However, if you need to do that more than once, it is more conveniet to use it in the form of a procedure,&lt;/p&gt;
&lt;pre&gt;
Newt:=proc (f,x0,n) 
    local x; 
    x:=x0; 
    while f(x-0.5*0.1^n)*f(x+0.5*0.1^n)&amp;gt;0 do 
        x:=x-f(x)/D(f)(x) 
    od 
end:
&lt;/pre&gt;
&lt;p&gt;In this case, if you need to find another root, with the initial approximation x0=1.4, correct to 8 decimal places, that can be done as&lt;/p&gt;
&lt;pre&gt;
Newt(f, 1.4 ,8); 
                             1.375064696
&lt;/pre&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Without using a procedure, it can be done just by executing the body of a procedure.&lt;/p&gt;
&lt;p&gt;For example, if you need to find a root of x^4+3*x^3-x-10=0 correct to 8 decimal places, with initial approximation x0=-3.2, that can be done as&lt;/p&gt;
&lt;pre&gt;
f:=x-&amp;gt;x^4+3*x^3-x-10:
x:=-3.2:
n:=8:
while f(x-0.5*0.1^n)*f(x+0.5*0.1^n)&amp;gt;0 do 
    x:=x-f(x)/D(f)(x) od;

                          x := -3.206173582

                          x := -3.206142669
&lt;/pre&gt;
&lt;p&gt;However, if you need to do that more than once, it is more conveniet to use it in the form of a procedure,&lt;/p&gt;
&lt;pre&gt;
Newt:=proc (f,x0,n) 
    local x; 
    x:=x0; 
    while f(x-0.5*0.1^n)*f(x+0.5*0.1^n)&amp;gt;0 do 
        x:=x-f(x)/D(f)(x) 
    od 
end:
&lt;/pre&gt;
&lt;p&gt;In this case, if you need to find another root, with the initial approximation x0=1.4, correct to 8 decimal places, that can be done as&lt;/p&gt;
&lt;pre&gt;
Newt(f, 1.4 ,8); 
                             1.375064696
&lt;/pre&gt;
&lt;p&gt;Alec&lt;/p&gt;</description>
      <guid>67342</guid>
      <pubDate>Wed, 25 Feb 2009 22:39:14 Z</pubDate>
      <itunes:author>alec</itunes:author>
      <author>alec</author>
    </item>
    <item>
      <title>Re: Without procedures</title>
      <link>http://www.mapleprimes.com/questions/39589-Newton-Rhapson--This-One?ref=Feed:MaplePrimes:Newton Rhapson - this one:Comments#comment82135</link>
      <itunes:summary>&lt;p&gt;Do you mean that you want the solving method to not be implemented as a (new) procedure?&lt;/p&gt;
&lt;p&gt;Or do you perhaps mean that you want f to be an expression rather than a procedure or operator? In that case, the function applications could be replaced by 2-argument &lt;b&gt;eval&lt;/b&gt; calls, or &lt;b&gt;unapply&lt;/b&gt; could be used to produce an operator equivalent at the start of the code. Eg, instead of,&lt;/p&gt;
&lt;pre&gt;
&amp;gt; f := x -&amp;gt; cos(Pi+x) -x: # the input

&amp;gt; f(1.1);
                                 -1.553596121
&lt;/pre&gt;
&lt;p&gt;could be,&lt;/p&gt;
&lt;pre&gt;
&amp;gt; f := cos(Pi+x) -x: # the input

&amp;gt; var := indets(f,And(name,Non(constant)));
                                  var := {x}

&amp;gt; if nops(var) &amp;lt;&amp;gt; 1 then error &amp;quot;expecting univariate expression&amp;quot;; end if;

&amp;gt; eval( f, var[1]=1.1 );
                                 -1.553596121

&amp;gt; F := unapply(f, var[1]);
                             F := x -&amp;gt; -cos(x) - x

&amp;gt; F(1.1);
                                 -1.553596121
&lt;/pre&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Do you mean that you want the solving method to not be implemented as a (new) procedure?&lt;/p&gt;
&lt;p&gt;Or do you perhaps mean that you want f to be an expression rather than a procedure or operator? In that case, the function applications could be replaced by 2-argument &lt;b&gt;eval&lt;/b&gt; calls, or &lt;b&gt;unapply&lt;/b&gt; could be used to produce an operator equivalent at the start of the code. Eg, instead of,&lt;/p&gt;
&lt;pre&gt;
&amp;gt; f := x -&amp;gt; cos(Pi+x) -x: # the input

&amp;gt; f(1.1);
                                 -1.553596121
&lt;/pre&gt;
&lt;p&gt;could be,&lt;/p&gt;
&lt;pre&gt;
&amp;gt; f := cos(Pi+x) -x: # the input

&amp;gt; var := indets(f,And(name,Non(constant)));
                                  var := {x}

&amp;gt; if nops(var) &amp;lt;&amp;gt; 1 then error &amp;quot;expecting univariate expression&amp;quot;; end if;

&amp;gt; eval( f, var[1]=1.1 );
                                 -1.553596121

&amp;gt; F := unapply(f, var[1]);
                             F := x -&amp;gt; -cos(x) - x

&amp;gt; F(1.1);
                                 -1.553596121
&lt;/pre&gt;
&lt;p&gt;acer&lt;/p&gt;</description>
      <guid>82135</guid>
      <pubDate>Wed, 25 Feb 2009 23:10:03 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
  </channel>
</rss>