abserr = 1e-8;
relerr = 1e-6;
figure;
fplot(@e415f);
b = 100;
c = 600;
[b,c,residual,flag] = Zero('e415f',b,c,abserr,relerr);
% Check flag and print results.
fprintf('flag = %i \n',flag)
if flag == 0
fprintf('Computed a root b = %e \n',b);
elseif flag == 1
fprintf('Too much work \n');
fprintf('There is a root in [b,c] with \n');
fprintf('b = %e, c = %e \n',b,c);
elseif flag == 2
fprintf('Computed a pole b = %e \n',b);
end
fprintf('The residual f(b) = %e \n',residual);
function y = e415f( x )
y = 21.1306 - 3480.3 / x - 5.081 * log10(x);
return
stdout:
e415
flag = 0
Computed a root b = 4.569975e+02
The residual f(b) = -2.411655e-07