(i) | , |
(ii) | . |
Input Parameters
Output Parameters
Open in the MATLAB editor: c05aw_example
function c05aw_example fprintf('c05aw example results\n\n'); x = 1; eta = 0; nfmax = int64(200); fprintf('\n'); % Repeat with tolerance eps set to varying powers of 10 for k=3:4 [xOut, user, ifail] = c05aw(x, 10^-k, eta, @f, nfmax); switch ifail case {0} fprintf('With eps = %10.2e, root = %14.5f\n', 10^-k, xOut); case {3, 4} fprintf('With eps = %10.2e, final value = %14.5f\n', 10^-k, xOut); otherwise break; end end function [result, user] = f(x, user) result = x - exp(-x);
c05aw example results With eps = 1.00e-03, root = 0.56715 With eps = 1.00e-04, root = 0.56715