Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.
On entry, | , |
or | , |
or | , |
or | , |
or | . |
Open in the MATLAB editor: d02mz_example
function d02mz_example fprintf('d02mz example results\n\n'); % Integrate to using B.D.F formulae with a functional iteration method neq = int64(3); maxord = int64(5); sdysav = int64(maxord+1); petzld = false; const = zeros(6,1); tcrit = 0; hmin = 1e-10; hmax = 10; h0 = 0; maxstp = int64(200); mxhnil = int64(5); rwork = zeros(16+20*neq,1); [const, rwork, ifail] = d02nv(... neq, sdysav, maxord, 'functional-iteration', ... petzld, const, tcrit, hmin, hmax, h0, maxstp, ... mxhnil, 'average-l2', rwork); % Use numerical Jacobian if functional iteration encounters any difficulty. nwkjac = int64(neq * (neq + 1)); [rwork, ifail] = d02ns(neq, neq, 'numerical', nwkjac, rwork); algequ = zeros(1, neq); lderiv = zeros(1, 2); % Variable and array initializations for integrator % Initial conditions t = 0; tout = 0.1; y = [1; 0; 0]; ydot = zeros(1, neq); % vector tolerances itol = int64(4); rtol = [1.0e-4; 1.0e-3; 1.0e-4]; atol = [1.0e-7; 1.0e-8; 1.0e-7]; inform = zeros(23, 1, 'int64'); ysav = zeros(neq, sdysav); wkjac = zeros(1, nwkjac); lderiv = [false; false]; itask = int64(2); itrace = int64(0); % Intialize for solution output xout = 0.02e0; fprintf('\n x y(1) y(2) y(3)\n'); fprintf('%8.3f %13.5f %13.5f %13.5f\n', t, y); while (t < tout) [t, tout, y, ydot, rwork, inform, ysav, wkjac, lderiv, ifail] = ... d02ng(... t, tout, y, ydot, rwork, rtol, atol, itol, inform, ... @resid, ysav, 'd02ngz', wkjac, 'd02nby', lderiv, itask, ... itrace); while (xout <= t) [sol, ifail] = d02mz(xout, neq, neq, ysav, rwork); fprintf('%8.3f %13.5f %13.5f %13.5f\n', xout, sol); xout = xout + 0.02e0; end end function [r, ires] = resid(neq, t, y, ydot, ires) r = -ydot; if ires == int64(1) r(1) = -0.04e0*y(1) + 1.0e4*y(2)*y(3) + r(1); r(2) = 0.04e0*y(1) - 1.0e4*y(2)*y(3) - 3.0e7*y(2)*y(2) + r(2); r(3) = 3.0e7*y(2)*y(2) + r(3); end
d02mz example results x y(1) y(2) y(3) 0.000 1.00000 0.00000 0.00000 0.020 0.99920 0.00004 0.00076 0.040 0.99841 0.00004 0.00155 0.060 0.99763 0.00004 0.00234 0.080 0.99685 0.00004 0.00311 0.100 0.99608 0.00004 0.00389