1. newton method

Code:
if (x2 - x1)/x2 < err
return
end
Is this terminating condition correct for newton raphson method?

2. Originally Posted by ilikec
Code:

if (x2 - x1)/x2 < err
return
end
Is this terminating condition correct for newton raphson method?
No, it at least needs an abs() on the left of the inequality.

CB

3. cant i say

if feval(fx,x) < err
return
end

fx is the function
x is the value of x at current iteration

So fx(x) < err means x is very close to the root

Am i correct in this case?

4. Originally Posted by ilikec
cant i say

if feval(fx,x) < err
return
end

fx is the function
x is the value of x at current iteration

So fx(x) < err means x is very close to the root

Am i correct in this case?
suppose err=0.0001 and fx(x)=-200 ?

CB

5. oh yeah i forgot

it should be

abs(f(x) ) < err

absolute value so -200 will be 200 in this case

is it okay to use this technique?

6. Originally Posted by ilikec
oh yeah i forgot

it should be

abs(f(x) ) < err

absolute value so -200 will be 200 in this case

is it okay to use this technique?
Yes

CB