Skip to content

Commit

Permalink
added check for perfect initial guess, updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaskis committed Oct 17, 2022
1 parent 10ac4ba commit 3b132e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Binary file modified EXAMPLES.mlx
Binary file not shown.
Binary file modified Root_Finding_Methods.pdf
Binary file not shown.
10 changes: 8 additions & 2 deletions bisection_method.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
% See also fzero, newtons_method, secant_method.
%
% Copyright © 2021 Tamas Kis
% Last Update: 2022-07-06
% Last Update: 2022-10-16
% Website: https://tamaskis.github.io
% Contact: tamas.a.kis@outlook.com
%
Expand Down Expand Up @@ -76,6 +76,12 @@
% root estimate at first iteration
c = (a+b)/2;

% returns root estimate at first iteration if it is a root of f(x)
if f(c) == 0
x = c;
return
end

% function evaluations at first iteration
fa = f(a);
fc = f(c);
Expand All @@ -85,7 +91,7 @@
x_all = zeros(1,k_max+1);
end

% bisection method
% iteration
for k = 1:k_max

% stores results in arrays
Expand Down

0 comments on commit 3b132e4

Please sign in to comment.