-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrootfinding.m
More file actions
21 lines (18 loc) · 781 Bytes
/
rootfinding.m
File metadata and controls
21 lines (18 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function[lambda] = rootfinding(f, intervals, tol)
% rootfinding -- Computes roots of a transcendental equation
%
% lambda = rootfinding(f, intervals, tol)
%
% The input f is a function handle evaluting a scalar function of one
% variable. This function uses matlab's fzero to find N roots of this
% equations, where N == size(intervals, 1). Here, intervals is a N x 2 matrix, where each row is a bounding interval for the root.
%
% The last input tol is a scalar that denotes how far from the interval edges
% to begin searching. (The assumption is that endpoints of the interval are
% poles for f.)
N = size(intervals, 1);
assert(size(intervals, 2) == 2);
lambda = zeros([N 1]);
for n = 1:N
lambda(n) = fzero(f, [intervals(n,1) + tol, intervals(n,2) - tol]);
end