Skip to content
Snippets Groups Projects
Commit 8b4a0d0e authored by VaishnavaHari S's avatar VaishnavaHari S
Browse files

Add new file

parent 4b6136fe
Branches
No related tags found
No related merge requests found
function p = bisection(f,a,b)
% provide the equation you want to solve with R.H.S = 0 form.
% Write the L.H.S by using inline function
% Give initial guesses.
% Solves it by method of bisection.
% A very simple code. But may come handy
if f(a)*f(b)>0
disp('Wrong choice bro')
else
p = (a + b)/2;
err = abs(f(p));
while err > 1e-7
if f(a)*f(p)<0
b = p;
else
a = p;
end
p = (a + b)/2;
err = abs(f(p));
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment