5.8 MATLAB function fzero
Thus far, we solved nonlinear equations using only one technique at a time.
However, if we solve for a root of a nonlinear equation by combining two or more
techniques, we can, for example, achieve the coupling of the robustness of a brack-
eting method of root finding with the convergence speed of an open-interval method.
Such combinations of methods of root finding are termed hybrid methods and are
much more powerful than using any single method alone. The MATLAB function
fzero is an example of using a hybrid method to find roots of a nonlinear equation.
The fzero function combines the reliable bisection method with faster convergence
methods: the secant method and inverse quadratic interpolation. The inverse
quadratic interpolation method is similar to the secant method, but instead of
using two endpoints to produce a secant line as an approximation of the function
near the root, three data points are used to approximate the function as a quadratic
% Input variables
% func : function that evaluates the system of nonlinear equations and
% the Jacobian matrix
% x : initial guess values of the independent variables
% tolx : tolerance for error in the solution
% tolfx : tolerance for error in function value
% Other variables
maxloops = 20;
[fx, J] = feval(func,x);
fprintf(‘ i x1(i+1) x2(i+1) f1(x(i)) f2(x(i)) \n’);
% Iterative solution scheme
for i = 1:maxloops
dx = J \ (-fx);
x=x+dx;
[fx, J] = feval(func,x);
fprintf(‘%2d %7.6f %7.6f %7.6f %7.6f \n’,...
i, x(1), x(2), fx(1), fx(2));
if (abs(dx) <=tolx & abs(fx) < tolfx)
% not use of element-wise AND operator
break % Jump out of the for loop
end
end
We run the user-defined function gen_newtonsmethod2 and specify the appropriate arguments
to solve our nonlinear problem in two variables. We use starting guesses of H
core
= 0.44 and δ =3
μmorσ = 0.8:
44
gen_newtonsmethod2(‘FahraeusLindquistExample ’,[0.44; 0.8],
0.002, 0.002)
i x1(i+1) x2(i+1) f1(x(i)) f2(x(i))
1 0.446066 0.876631 0.069204 0.020425
2 0.504801 0.837611 -0.006155 0.000113
3 0.500263 0.839328 0.001047 -0.000001
4 0.501049 0.839016 -0.000181 -0.000000
The solution obtained is H
core
= 0.501 and σ = 0.839 or δ = 2.41 μm.
346
Root-finding techniques for nonlinear equations