Permalink
Cannot retrieve contributors at this time
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?
roots_and_optimization/four_func.asv
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (20 sloc)
788 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Define Variables | |
xr = 0; | |
es = 0.0001; | |
maxit = 300; | |
xl=1;%inital guess | |
xu=300;%initial guess | |
dx= 10e-6; | |
%Plot | |
N=20; | |
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 n | |
[root_ms,ea_ms(i),iter_ms]=mod_secant(@ (theta) projectile(theta),dx,xr,es,maxit(i)); | |
[root_fp,fx_fp,ea_fp(i),iter_fp]=falsepos(@ (theta) projectile(theta),xl,xu,es,maxit(i)); | |
[root_bs,fx_bs,ea_bs(i),iter_bs]=bisect(@ (theta) projectile(theta),xl,xu,es,maxit(i)); | |
end |