hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_ode_ivp_adams_diag (d02qx)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_ode_ivp_adams_diag (d02qx) is a diagnostic function which may be called after a call to either of the integration functions nag_ode_ivp_adams_roots (d02qf) and nag_ode_ivp_adams_roots_revcom (d02qg).

Syntax

[yp, tcurr, hlast, hnext, odlast, odnext, nsucc, nfail, tolfac, badcmp, ifail] = d02qx(neqf, rwork, iwork)
[yp, tcurr, hlast, hnext, odlast, odnext, nsucc, nfail, tolfac, badcmp, ifail] = nag_ode_ivp_adams_diag(neqf, rwork, iwork)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: lrwork and liwork were removed from the interface

Description

nag_ode_ivp_adams_diag (d02qx) permits you to extract information about the performance of nag_ode_ivp_adams_roots (d02qf) or nag_ode_ivp_adams_roots_revcom (d02qg). It may only be called after a call to nag_ode_ivp_adams_roots (d02qf) or nag_ode_ivp_adams_roots_revcom (d02qg).

References

None.

Parameters

Compulsory Input Parameters

1:     neqf int64int32nag_int scalar
The number of first-order ordinary differential equations solved by the integration function. It must be the same argument neqf supplied to the setup function nag_ode_ivp_adams_setup (d02qw) and the integration functions nag_ode_ivp_adams_roots (d02qf) or nag_ode_ivp_adams_roots_revcom (d02qg).
2:     rworklrwork – double array
This must be the same argument rwork as supplied to nag_ode_ivp_adams_roots (d02qf) or nag_ode_ivp_adams_roots_revcom (d02qg). It is used to pass information from the integration function to nag_ode_ivp_adams_diag (d02qx) and therefore the contents of this array must not be changed before calling nag_ode_ivp_adams_diag (d02qx).
3:     iworkliwork int64int32nag_int array
This must be the same argument iwork as supplied to nag_ode_ivp_adams_roots (d02qf) or nag_ode_ivp_adams_roots_revcom (d02qg). It is used to pass information from the integration function to nag_ode_ivp_adams_diag (d02qx) and therefore the contents of this array must not be changed before calling nag_ode_ivp_adams_diag (d02qx).

Optional Input Parameters

None.

Output Parameters

1:     ypneqf – double array
The approximate derivative of the solution component yi, as supplied in yi on output from the integration function at the output value of t. These values are obtained by the evaluation of y=fx,y except when the output value of the argument t in the call to the integration function is tout and tcurrtout, in which case they are obtained by interpolation.
2:     tcurr – double scalar
The value of the independent variable which the integrator has actually reached. tcurr will always be at least as far as the output value of the argument t (from the integration function) in the direction of integration, but may be further.
3:     hlast – double scalar
The last successful step size used by the integrator.
4:     hnext – double scalar
The next step size which the integration function would attempt.
5:     odlast int64int32nag_int scalar
The order of the method last used (successfully) by the integration function.
6:     odnext int64int32nag_int scalar
The order of the method which the integration function would attempt on the next step.
7:     nsucc int64int32nag_int scalar
The number of steps attempted by the integration function that have been successful since the start of the current problem.
8:     nfail int64int32nag_int scalar
The number of steps attempted by the integration function that have failed since the start of the current problem.
9:     tolfac – double scalar
A tolerance scale factor, tolfac1.0, returned when the integration function exits with ifail=3. If rtol and atol are uniformly scaled up by a factor of tolfac and nag_ode_ivp_adams_setup (d02qw) is called, the next call to the integration function is deemed likely to succeed.
10:   badcmp int64int32nag_int scalar
If the integration function returned with ifail=4, then badcmp specifies the index of the component which forced the error exit. Otherwise badcmp is 0.
11:   ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
An integration function (nag_ode_ivp_adams_roots (d02qf) or nag_ode_ivp_adams_roots_revcom (d02qg)) has not been called or one or more of the arguments lrwork, liwork and neqf does not match the corresponding argument supplied to nag_ode_ivp_adams_setup (d02qw).
This error exit may be caused by overwriting elements of rwork.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

You should call nag_ode_ivp_adams_rootdiag (d02qy) for information about any roots detected by nag_ode_ivp_adams_roots (d02qf) or nag_ode_ivp_adams_roots_revcom (d02qg).

Example

See Example in nag_ode_ivp_adams_roots (d02qf).
function d02qx_example


fprintf('d02qx example results\n\n');

neqf   = int64(2);
neqg   = int64(2);
vectol = true;
atol   = [1e-06;  1e-06];
rtol   = [0.0001; 0.0001];
onestp = false;
crit   = true;
tcrit  = 10;
hmax   = 0;
maxstp = int64(0);
lrwork = 23*(1+neqf) + 14*neqg;
alterg = false;
sophst = true;

lrwork = 23*(1+neqf) + 14*neqg;
rwork  = zeros(lrwork,1);
liwork = 21 + 4*neqg;
iwork  = zeros(liwork, 1, 'int64');

% Adams method setup
[statefOut, altergOut, rwork, iwork, ifail] = ...
  d02qw(...
        'Start', neqf, vectol, atol, rtol, onestp, crit, tcrit, hmax, ...
        maxstp, neqg, alterg, sophst, rwork, iwork);

% Integrate from t = 0 to 10
t    = 0;
tout = 10;
y    = [0; 1];

[t, y, root, rwork, iwork, ifail] = ...
    d02qf(...
          @fcn, t, y, tout, @g, neqg, rwork, iwork);

% Display solution and integration statistics.
fprintf('Solution and root functions at t = %7.4f is:\n',t);
[yp, tcurr, hlast, hnext, odlast, odnext, ...
 nsucc, nfail, tolfac, badcmp, ifail] = ...
  d02qx(neqf, rwork, iwork);
fprintf('\n y :');
fprintf('%10.4f',y);
fprintf('\n y'':');
fprintf('%10.4f',yp);
fprintf('\n g :');
for i=1:neqg
  root = g(neqf,t,y,yp,i);
  fprintf('%10.4f',root);
end
fprintf('\n\nDiagnostics:\n');
fprintf('  Current value of t     = %7.4f\n',tcurr);
fprintf('  last time-step         = %7.4f\n',hlast);
fprintf('  next time-step         = %7.4f\n',hnext);
fprintf('  last method order used = %7d\n',odlast);
fprintf('  next method order used = %7d\n',odnext);
fprintf('  successful steps       = %7d\n',nsucc);
fprintf('  failed steps           = %7d\n',nfail);




function f = fcn(neqf, x, y)
  f=zeros(neqf,1);
  f(1)=y(2);
  f(2)=-y(1);

function result = g(neqf, x, y, yp, k)
  if (k == 1)
    result = yp(1)+0.5;
  else
    result = y(1)-sqrt(0.5);
  end
d02qx example results

Solution and root functions at t =  0.7854 is:

 y :    0.7071    0.7071
 y':    0.7071   -0.7071
 g :    1.2071    0.0000

Diagnostics:
  Current value of t     =  0.9037
  last time-step         =  0.3620
  next time-step         =  0.3258
  last method order used =       5
  next method order used =       5
  successful steps       =      10
  failed steps           =       0

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015