(i) | |x − α| ∼ eps $|x-\alpha |\sim {\mathbf{eps}}$, |
(ii) | |f(x)| < eta $\left|f\left(x\right)\right|<{\mathbf{eta}}$. |
Input Parameters
Output Parameters
Open in the MATLAB editor: nag_roots_contfn_cntin_example
function nag_roots_contfn_cntin_example 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] = nag_roots_contfn_cntin(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);
With eps = 1.00e-03, root = 0.56715 With eps = 1.00e-04, root = 0.56715
Open in the MATLAB editor: c05aw_example
function c05aw_example 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);
With eps = 1.00e-03, root = 0.56715 With eps = 1.00e-04, root = 0.56715