PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_ode_ivp_rkts_errass (d02pu)
Purpose
nag_ode_ivp_rkts_errass (d02pu) provides details about global error assessment computed during an integration with either
nag_ode_ivp_rkts_range (d02pe) or
nag_ode_ivp_rkts_onestep (d02pf).
Syntax
Description
nag_ode_ivp_rkts_errass (d02pu) and its associated functions (
nag_ode_ivp_rkts_range (d02pe),
nag_ode_ivp_rkts_onestep (d02pf),
nag_ode_ivp_rkts_setup (d02pq),
nag_ode_ivp_rkts_reset_tend (d02pr),
nag_ode_ivp_rkts_interp (d02ps) and
nag_ode_ivp_rkts_diag (d02pt)) solve the initial value problem for a first-order system of ordinary differential equations. The functions, based on Runge–Kutta methods and derived from RKSUITE (see
Brankin et al. (1991)), integrate
where
is the vector of
solution components and
is the independent variable.
After a call to
nag_ode_ivp_rkts_range (d02pe) or
nag_ode_ivp_rkts_onestep (d02pf),
nag_ode_ivp_rkts_errass (d02pu) can be called for information about error assessment, if this assessment was specified in the setup function
nag_ode_ivp_rkts_setup (d02pq). A more accurate ‘true’ solution
is computed in a secondary integration. The error is measured as specified in
nag_ode_ivp_rkts_setup (d02pq) for local error control. At each step in the primary integration, an average magnitude
of component
is computed, and the error in the component is
It is difficult to estimate reliably the true error at a single point. For this reason the RMS (root-mean-square) average of the estimated global error in each solution component is computed. This average is taken over all steps from the beginning of the integration through to the current integration point. If all has gone well, the average errors reported will be comparable to
tol (see
nag_ode_ivp_rkts_setup (d02pq)). The maximum error seen in any component in the integration so far and the point where the maximum error first occurred are also reported.
References
Brankin R W, Gladwell I and Shampine L F (1991) RKSUITE: A suite of Runge–Kutta codes for the initial value problems for ODEs SoftReport 91-S1 Southern Methodist University
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the number of ordinary differential equations in the system to be solved by the integration function.
Constraint:
.
- 2:
– int64int32nag_int array
- 3:
– double array
-
These must be the same arrays supplied in a previous call to
nag_ode_ivp_rkts_range (d02pe) or
nag_ode_ivp_rkts_onestep (d02pf). They must remain unchanged between calls.
Optional Input Parameters
None.
Output Parameters
- 1:
– double array
-
approximates the RMS average of the true error of the numerical solution for the th solution component, for . The average is taken over all steps from the beginning of the integration to the current integration point.
- 2:
– double scalar
-
The maximum weighted approximate true error taken over all solution components and all steps.
- 3:
– double scalar
-
The first value of the independent variable where an approximate true error attains the maximum value,
errmax.
- 4:
– int64int32nag_int array
- 5:
– double array
-
Information about the integration for use on subsequent calls to
nag_ode_ivp_rkts_range (d02pe) or
nag_ode_ivp_rkts_onestep (d02pf) or other associated functions.
- 6:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
No error assessment is available since the integrator has not actually taken any successful steps.
No error assessment is available since you did not ask for it in your call to the setup function.
On entry, a previous call to the setup function has not been made or the communication arrays have become corrupted, or a catastrophic error has already been detected elsewhere.
You cannot continue integrating the problem.
On entry, , but the value passed to the setup function was .
You cannot call this function before you have called the integrator.
You have already made one call to this function after the integrator could not achieve specified accuracy.
You cannot call this function again.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Not applicable.
Further Comments
If the integration has proceeded ‘well’ and the problem is smooth enough, stable and not too difficult then the values returned in the arguments
rmserr and
errmax should be comparable to the value of
tol specified in the prior call to
nag_ode_ivp_rkts_setup (d02pq).
Example
This example integrates a two body problem. The equations for the coordinates
of one body as functions of time
in a suitable frame of reference are
The initial conditions
lead to elliptic motion with
.
is selected and the system of ODEs is reposed as
over the range
. Relative error control is used with threshold values of
for each solution component and a high-order Runge–Kutta method (
) with tolerance
.
Note that for illustration purposes since it is not necessary for this problem, this example integrates to the end of the range regardless of efficiency concerns (i.e., returns from
nag_ode_ivp_rkts_range (d02pe) with
,
or
).
Open in the MATLAB editor:
d02pu_example
function d02pu_example
fprintf('d02pu example results\n\n');
n = int64(4);
method = int64(3);
tstart = 0;
tend = 3*pi;
ecc = 0.7;
yinit = [1-ecc; 0; 0; sqrt((1+ecc)/(1-ecc))];
hstart = 0;
thresh = [1e-10; 1e-10; 1e-10; 1e-10];
npts = 96;
ygot = zeros(n, 1);
ymax = zeros(n, 1);
tol = 1e-6;
tinc = (tend-tstart)/npts;
[iwsav, rwsav, ifail] = d02pq( ...
tstart, tend, yinit, tol, thresh, method);
fprintf('\nCalculation with TOL = %8.1e\n\n', tol);
fprintf(' t y1 y2 y3 y4\n');
fprintf(' %6.3f %8.4f %8.4f %8.4f %8.4f\n', tstart, yinit);
twant = tend;
ifail = int64(3);
while ifail == 2 || ifail == 3 || ifail == 4
[tgot, ygot, ypgot, ymax, user, iwsav, rwsav, ifail] = ...
d02pe(@f, twant, ygot, ymax, iwsav, rwsav);
end
fprintf(' %6.3f %8.4f %8.4f %8.4f %8.4f\n', tgot, ygot);
[rmserr, errmax, terrmx, iwsav, rwsav, ifail] = d02pu(n, iwsav, rwsav);
fprintf('\nComponentwise error assessment\n');
fprintf('%9.2e ', rmserr);
fprintf('\nMaximum global error, at t = %6.3f, was %9.2e\n', terrmx, errmax);
[fevals, stepcost, waste, stepsok, hnext, iwsav, ifail] = ...
d02pt(iwsav, rwsav);
fprintf('\nCost of the integration in evaluations of f is %d\n', fevals);
function [yp, user] = f(t, n, y, user)
r = sqrt(y(1)^2+y(2)^2);
yp = [y(3); y(4); -y(1)/r^3; -y(2)/r^3];
d02pu example results
Calculation with TOL = 1.0e-06
t y1 y2 y3 y4
0.000 0.3000 0.0000 0.0000 2.3805
9.425 -1.7000 0.0000 -0.0000 -0.4201
Componentwise error assessment
3.81e-06 7.10e-06 6.92e-06 2.10e-06
Maximum global error, at t = 6.302, was 3.43e-05
Cost of the integration in evaluations of f is 1361
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015