From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Newton's Divided Difference Method
Date: Fri, 2 Mar 2012 03:45:17 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 14
Message-ID: <jipfod$g6v$>
References: <jipbfo$4db$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1330659917 16607 (2 Mar 2012 03:45:17 GMT)
NNTP-Posting-Date: Fri, 2 Mar 2012 03:45:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:759546

"Akmal " <> wrote in message <jipbfo$4db$>...
> I'm writing a code for interpolation using Newton's method. The code works but it gave me a different value. When I enter f(x) = log(x), x0=1, it gave me y=1 which is wrong. Can anyone help me?
> ......
>     if x==y
> ......
> Warning: FOR loop index is too large. Truncating to 9223372036854775807. 
- - - - - - - - -
  Why do you say that y = 1 is wrong?  That is the solution to log(y) = 0 which is apparently what you were seeking.

  You shouldn't be requiring exact equality in your loop where you write "x==y".  That is apparently what caused the warning message.  The code never achieved exact equality.  It probably eventually began bouncing back and forth between two different values and would have never stopped if it were not for the excessive size of 'u'.  You should only require that your value becomes approximately zero to within some tolerance.

  Note: This is not interpolation.  Newton's method allows you to solve an equation for an unknown value.

Roger Stafford