<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Why isn't the code working properly?</title>
    <link>http://www.mapleprimes.com/questions/36481-Why-Isnt-The-Code-Working-Properly</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 09 Jun 2026 07:40:36 GMT</lastBuildDate>
    <pubDate>Tue, 09 Jun 2026 07:40:36 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Why isn't the code working properly?</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Why isn't the code working properly?</title>
      <link>http://www.mapleprimes.com/questions/36481-Why-Isnt-The-Code-Working-Properly</link>
    </image>
    <item>
      <title>n</title>
      <link>http://www.mapleprimes.com/questions/36481-Why-Isnt-The-Code-Working-Properly?ref=Feed:MaplePrimes:Why isn't the code working properly?:Comments#answer62370</link>
      <itunes:summary>&lt;p&gt;What is is 'n' doing there?&amp;nbsp; It is in the snippet ( f(x)^2) n&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;What is is 'n' doing there?&amp;nbsp; It is in the snippet ( f(x)^2) n&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <guid>62370</guid>
      <pubDate>Wed, 28 Oct 2009 22:44:00 Z</pubDate>
      <itunes:author>Joe
 Riel
</itunes:author>
      <author>Joe
 Riel
</author>
    </item>
    <item>
      <title>suggestion</title>
      <link>http://www.mapleprimes.com/questions/36481-Why-Isnt-The-Code-Working-Properly?ref=Feed:MaplePrimes:Why isn't the code working properly?:Comments#answer62372</link>
      <itunes:summary>&lt;p&gt;There is no good reason to recompute D(f) and (D@@2)(f) inside the loop.&amp;nbsp; Better to assign them to local variables.&amp;nbsp; You may then notice that there is a problem, no argument is passed to (D@@2)(f).&amp;nbsp; If you also assign some intermediate computations, you can then quickly see where things are going wrong by tracing the procedure call (i.e. call debug(NEWTON_RALPH) before evaluating.&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;There is no good reason to recompute D(f) and (D@@2)(f) inside the loop.&amp;nbsp; Better to assign them to local variables.&amp;nbsp; You may then notice that there is a problem, no argument is passed to (D@@2)(f).&amp;nbsp; If you also assign some intermediate computations, you can then quickly see where things are going wrong by tracing the procedure call (i.e. call debug(NEWTON_RALPH) before evaluating.&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;</description>
      <guid>62372</guid>
      <pubDate>Wed, 28 Oct 2009 23:18:21 Z</pubDate>
      <itunes:author>Joe
 Riel
</itunes:author>
      <author>Joe
 Riel
</author>
    </item>
    <item>
      <title>Thank U</title>
      <link>http://www.mapleprimes.com/questions/36481-Why-Isnt-The-Code-Working-Properly?ref=Feed:MaplePrimes:Why isn't the code working properly?:Comments#answer62369</link>
      <itunes:summary>&lt;p&gt;Thanx for ur help Joe and pagan much appriciated.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Thanx for ur help Joe and pagan much appriciated.&lt;/p&gt;</description>
      <guid>62369</guid>
      <pubDate>Thu, 29 Oct 2009 22:14:47 Z</pubDate>
      <itunes:author>Jabz</itunes:author>
      <author>Jabz</author>
    </item>
    <item>
      <title>Newton_Raph</title>
      <link>http://www.mapleprimes.com/questions/36481-Why-Isnt-The-Code-Working-Properly?ref=Feed:MaplePrimes:Why isn't the code working properly?:Comments#answer62374</link>
      <itunes:summary>&lt;p&gt;I had a quick look at the code and it seems that you're trying to evaluate f(x) while f is not a function.&lt;/p&gt;
&lt;p&gt;Try the folowing:&lt;/p&gt;
&lt;p&gt;f := x -&amp;gt; x^2-5:&lt;/p&gt;
&lt;p&gt;NEWTON_RAPH:= proc(z,M)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; local x,A:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; x := z:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for A to M do:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; x := (x -(f(x)/D(f)(x)) -((((D@@2)(f))*((f(x))^2))/(2*(D(f)(x))^3)))&lt;br /&gt;
&amp;nbsp;&amp;nbsp; end do:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; evalf(x):&lt;br /&gt;
&amp;nbsp; end proc:&lt;/p&gt;
&lt;p&gt;NEWTON_RAPH(0.1,10);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;I had a quick look at the code and it seems that you're trying to evaluate f(x) while f is not a function.&lt;/p&gt;
&lt;p&gt;Try the folowing:&lt;/p&gt;
&lt;p&gt;f := x -&amp;gt; x^2-5:&lt;/p&gt;
&lt;p&gt;NEWTON_RAPH:= proc(z,M)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; local x,A:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; x := z:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; for A to M do:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; x := (x -(f(x)/D(f)(x)) -((((D@@2)(f))*((f(x))^2))/(2*(D(f)(x))^3)))&lt;br /&gt;
&amp;nbsp;&amp;nbsp; end do:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; evalf(x):&lt;br /&gt;
&amp;nbsp; end proc:&lt;/p&gt;
&lt;p&gt;NEWTON_RAPH(0.1,10);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <guid>62374</guid>
      <pubDate>Fri, 30 Oct 2009 19:06:57 Z</pubDate>
      <itunes:author>mbendame</itunes:author>
      <author>mbendame</author>
    </item>
    <item>
      <title>sign error</title>
      <link>http://www.mapleprimes.com/questions/36481-Why-Isnt-The-Code-Working-Properly?ref=Feed:MaplePrimes:Why isn't the code working properly?:Comments#answer62375</link>
      <itunes:summary>i noticed that there is an error in the sign of third term of x update equation (for higher order Newton iteration):
the line
x := (x -(f(x)/D(f)(x)) -((((D@@2)(f))*((f(x))^2))/(2*(D(f)(x))^3)))
should be
x := x -(f(x)/D(f)(x)) + ((((D@@2)(f))*((f(x))^2))/(2*(D(f)(x))^3));

then following modified code finds the solution
NEWTON_RAPH:= proc(f,z,M)
local x,A;
x := z:
for A to M do:
x := x -(f(x)/D(f)(x)) + ((((D@@2)(f))*((f(x))^2))/(2*(D(f)(x))^3));
end do:
evalf(x):
proc: f:= x-&amp;gt; x^2-5:
NEWTON_RAPH(f,1,10);
evalf(%);</itunes:summary>
      <description>i noticed that there is an error in the sign of third term of x update equation (for higher order Newton iteration):
the line
x := (x -(f(x)/D(f)(x)) -((((D@@2)(f))*((f(x))^2))/(2*(D(f)(x))^3)))
should be
x := x -(f(x)/D(f)(x)) + ((((D@@2)(f))*((f(x))^2))/(2*(D(f)(x))^3));

then following modified code finds the solution
NEWTON_RAPH:= proc(f,z,M)
local x,A;
x := z:
for A to M do:
x := x -(f(x)/D(f)(x)) + ((((D@@2)(f))*((f(x))^2))/(2*(D(f)(x))^3));
end do:
evalf(x):
proc: f:= x-&amp;gt; x^2-5:
NEWTON_RAPH(f,1,10);
evalf(%);</description>
      <guid>62375</guid>
      <pubDate>Sat, 31 Oct 2009 10:36:57 Z</pubDate>
      <itunes:author>Hakan
 Tiftikci
</itunes:author>
      <author>Hakan
 Tiftikci
</author>
    </item>
    <item>
      <title>Thank u</title>
      <link>http://www.mapleprimes.com/questions/36481-Why-Isnt-The-Code-Working-Properly?ref=Feed:MaplePrimes:Why isn't the code working properly?:Comments#answer62377</link>
      <itunes:summary>&lt;p&gt;Thank u everyone who posted a reply i a,m very grateful 4 ur assistance&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Thank u everyone who posted a reply i a,m very grateful 4 ur assistance&lt;/p&gt;</description>
      <guid>62377</guid>
      <pubDate>Thu, 12 Nov 2009 09:02:01 Z</pubDate>
      <itunes:author>Jabz</itunes:author>
      <author>Jabz</author>
    </item>
  </channel>
</rss>