Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
%Initial variables
xr = 0;
es = 0.0001;
maxit = 300;
xl=1;%inital guess
xu=300;%initial guess
dx= 10e-6;
%Plot function
N=20; %spacing
maxit = linspace(1,400,N);
ea_nr=zeros(1,N); % appr error Newton-Raphson method
ea_ms=zeros(1,N); % appr error Modified Secant method
ea_fp=zeros(1,N); % appr error false point method
ea_bs=zeros(1,N); % appr error bisect method
for i=1:length(maxit)
[root_nr,ea_nr(i),iter_nr]= newtraph(@ (theta) projectile(theta),@ (theta) dprojectile_dtheta (theta),xr,es,maxit(i)); %roots for newtraph
[root_ms,ea_ms(i),iter_ms]=mod_secant(@ (theta) projectile(theta),dx,xr,es,maxit(i)); %roots for mod_secant
[root_fp,fx_fp,ea_fp(i),iter_fp]=falsepos(@ (theta) projectile(theta),xl,xu,es,maxit(i)); %roots for falsepos
[root_bs,fx_bs,ea_bs(i),iter_bs]=bisect(@ (theta) projectile(theta),xl,xu,es,maxit(i)); %roots for bisect
end
setdefaults
semilogy(maxit,abs(ea_nr),maxit,abs(ea_ms),maxit,abs(ea_fp),maxit,abs(ea_bs))
legend('newton-raphson','mod-secant','false point','bisection')