%% Newton method matlab sample Examples %Dejen Ketema, March,2019. %f = @(x)(x/2).^2-sin(x); %% Example 1 convergence % f=@(x)x.^2-1; % df=@(x)2*x; % p0=4; % tol=.0001; % xmin=0; % xmax=3; % p=newton_table_2019(f,df,p0,tol); %%Example 2 %%Drawbacks of the Newton-Raphson Method %%Root jumping % f=@(x)sin(x); % df=@(x)cos(x);% % p0=1; % tol=.0001; % xmin=0; % xmax=3; % p=newton_table_2019(f,df,p0,tol); %% Divergence at inflection points % f=@(x)(x-1).^3+0.512; % df=@(x)3*x(x-1).^2; % p0=10; % tol=.0001; % xmin=0; % xmax=3; % p=newton_table_2019(f,df,p0,tol); %%Division by zero % f=@(x)x.^3-0.03*x.^2+2.4* 1.0000e-06; % df=@(x)3*x.^2-0.06*x; % p0=4; % tol=.0001; % xmin=0; % xmax=3; % p=newton_table_2019(f,df,p0,tol); %%Oscillations near local maximum and minimum %f=@(x)x.^3-2*x.^2-1; %df=@(x)3*x.^2-4*x; %f=@(x)x.^2-x-1; %df=@(x)2*x-1; f=@(x)x.^2-4; df=@(x)2*x; p0=1; tol=0.1; p=newton_table_2019(f,df,p0,tol);