![Contents](../../images/content.png)
![Previous Chapter](../../images/backback.png)
![Start of Chapter](../../images/backstop.png)
![Previous Topic](../../images/back.png)
![Next Topic](../../images/fwd.png)
![Next Chapter](../../images/fwdfwd.png)
Finding a root of f(x) = cos(x):
eps_step = 1e-5; eps_abs = 1e-5; N = 100; x = 0.2; for i=1:N xn = x - cos(x)/( -sin(x) ); if abs( x - xn ) < eps_step && abs( cos( xn ) ) < eps_abs break; elseif i == N error( 'Newton\'s method did not converge' ); end x = xn; end xn
What happens if you start with smaller values of x? Why?
Copyright ©2005 by Douglas Wilhelm Harder. All rights reserved.