% % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % % Problem on EPage 62; Solutions on EPage 161 % %----- close all; clc; clear all; addpath('../../BookCode'); c = 5; xs = linspace( 0, +pi, 1000 ); ys = tan(xs) - c; plot( xs, ys, '-b' ); grid('on'); saveas( gcf, '../../WriteUp/Graphics/Chapter3/c_3_p_4_plot.eps', 'epsc' ); fn = @(x) ( tan(x) - c ); fn_prime = @(x) ( sec(x)^2 ); [x_root,n_iters] = fnewton( fn, fn_prime, 1.3, 1.e-6 ) [x_root,n_iters] = fnewton( fn, fn_prime, 1.4, 1.e-6 ) c = 10; fn = @(x) ( tan(x) - c ); [x_root,n_iters] = fnewton( fn, fn_prime, 1.3, 1.e-6 ) [x_root,n_iters] = fnewton( fn, fn_prime, 1.4, 1.e-6 )