nag_ode_ivp_2nd_rkn_setup (d02lx) is a setup function which must be called prior to the first call of the integrator
nag_ode_ivp_2nd_rkn (d02la) and may be called prior to any continuation call to
nag_ode_ivp_2nd_rkn (d02la).
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: |
lrwork was removed from the interface |
nag_ode_ivp_2nd_rkn_setup (d02lx) permits you to set optional inputs prior to any call of
nag_ode_ivp_2nd_rkn (d02la). It must be called before the first call of function
nag_ode_ivp_2nd_rkn (d02la) and it may be called before any continuation call of function
nag_ode_ivp_2nd_rkn (d02la).
None.
Not applicable.
Prior to a continuation call of
nag_ode_ivp_2nd_rkn (d02la), you may reset any of the optional parameters by calling
nag_ode_ivp_2nd_rkn_setup (d02lx) with
. You may reset:
h |
to override the internal step size selection; |
tol, thres, thresp |
to change the error requirements; |
maxstp |
to increase or decrease the number of steps attempted before an error exit is returned; |
onestp |
to change the mode of operation of nag_ode_ivp_2nd_rkn (d02la); |
high |
to change the order of the method being used. |
function d02lx_example
fprintf('d02lx example results\n\n');
neq = 2;
h = 0;
reltol = 1e-4;
thresh = zeros(neq,1);
threshp = zeros(neq,1);
maxstp = int64(0);
start = true;
onestp = true;
high = false;
rwork = zeros(16+20*neq,1);
[start, rwork, ifail] = ...
d02lx(h, reltol, thresh, threshp, maxstp, start, onestp, high, rwork);
t = 0;
tend = 20;
y = [0.5; 0];
yp = [0; sqrt(3)];
ydp = zeros(neq, 1);
[t, y, yp, ydp, rwork, ifail] = d02la(@fcn, t, tend, y, yp, ydp, rwork);
fprintf('Solution at first time step, t = %6.3f:\n', t);
fprintf(' y = %6.3f, %6.3f\n',y);
fprintf(' y'' = %6.3f, %6.3f\n',yp);
fprintf(' y'''' = %6.3f, %6.3f\n',ydp);
function ydp = fcn(neq, t, y)
r = sqrt(y(1)^2+y(2)^2)^3;
f = zeros(2,1);
ydp(1) = -y(1)/r;
ydp(2) = -y(2)/r;
d02lx example results
Solution at first time step, t = 0.062:
y = 0.492, 0.108
y' = -0.246, 1.705
y'' = -3.848, -0.841