None.
Open in the MATLAB editor: d02mw_example
function d02mw_example fprintf('d02mw example results\n\n'); % Initialize the problem, specifying that the Jacobian is to be % evaluated analytically using the provided routine jac. neq = int64(5); maxord = int64(5); jceval = 'Analytic'; hmax = 0; h0 = 0; itol = int64(1); lcom = int64(200); [icom, com, ifail] = d02mw(neq, maxord, jceval, hmax, h0, itol, lcom); % Set initial values rtol(1:neq) = 1e-8; atol = rtol; y = [1 0 0 1 1]; ydot = zeros(neq,1); t = 0; tout = 1; itask = int64(1); fprintf('\n t y\n'); fprintf('%6.4f %10.6f %10.6f %10.6f %10.6f %10.6f\n', t, y); [t, y, ydot, rtol, atol, itask, icom, com, user, ifail] = ... d02ne(... t, tout, y, ydot, rtol, atol, itask, @res, @jac, icom, com); fprintf('%6.4f %10.6f %10.6f %10.6f %10.6f %10.6f\n', t, y); fprintf('\nThe integrator returned with itask = %d\n', itask); g1 = y(1)^2+y(2)^2 - 1; g2 = y(1)*y(3) + y(2)*y(4); fprintf('The position-level constraint G1 = %12.4e\n',g1); fprintf('The velocity-level constraint G2 = %12.4e\n',g2); function [pd, user] = jac(neq, t, y, ydot, pd, cj, user) % r1 pd(1:neq:neq^2) = [-cj,0,1,0,0]; % r2 pd(2:neq:neq^2) = [0,-cj,0,1,0]; % r3 pd(3:neq:neq^2) = [-y(5),0,-cj,0,-y(1)]; %r4 pd(4:neq:neq^2) = [0,-y(5),0,-cj,-y(2)]; %r5 pd(5:neq:neq^2) = [0,-1,2*y(3),2*y(4),-1]; function [r, ires, user] = res(neq, t, y, ydot, ires, user) r = zeros(neq, 1); r(1) = y(3) - ydot(1); r(2) = y(4) - ydot(2); r(3) = -y(5)*y(1) - ydot(3); r(4) = -y(5)*y(2) - 1 - ydot(4); r(5) = y(3)^2 + y(4)^2 - y(5) - y(2);
d02mw example results t y 0.0000 1.000000 0.000000 0.000000 1.000000 1.000000 1.0000 0.867349 0.497701 -0.033748 0.058813 -0.493103 The integrator returned with itask = 3 The position-level constraint G1 = -8.5802e-09 The velocity-level constraint G2 = -3.0051e-08