In effect we have approximated f(x) by a straight line; x is the intercept of that line with the x-axis. It may or may not be a good approximation for the root .
% Script to implement Newton's Method
del=1
x=3
k=0
func=inline('x^3-587')
deriv=inline('3*x^2')
while del >= 0.00005
k=k+1
if k <= 10
xnew=x-func(x)/deriv(x);
del=abs((xnew-x)/x);
disp(x);disp(func(x));disp(del)
x=xnew;
end
end
b. Algorithm
i) choose an initial estimate, xi
ii) compute f(xi) and
iii) compute the new estimate:
iv) return to step (ii) with i = i + 1
c. Comments
It turns out that if the initial estimate of the root is a good one, then the method is guaranteed to converge, and rapidly. Even if the estimate is not so good, the method will converge to a root—maybe not the one we anticipated.
Also, if there is a point nearby the method can have trouble. It’s always a good thing to graph f(x) first.
Share with your friends: |