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)

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:
Mark 22: lrwork, liwork have been 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 parameter 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:     rwork(lrwork) – double array
This must be the same parameter 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:     iwork(liwork) – int64int32nag_int array
This must be the same parameter 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.

Input Parameters Omitted from the MATLAB Interface

lrwork liwork

Output Parameters

1:     yp(neqf) – double array
The approximate derivative of the solution component yiyi, as supplied in yiyi on output from the integration function at the output value of t. These values are obtained by the evaluation of y = f(x,y)y=f(x,y) except when the output value of the parameter t in the call to the integration function is tout and tcurrtouttcurrtout, 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.0tolfac1.0, returned when the integration function exits with ifail = 3ifail=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 = 4ifail=4, then badcmp specifies the index of the component which forced the error exit. Otherwise badcmp is 00.
11:   ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=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 parameters lrwork, liwork and neqf does not match the corresponding parameter supplied to nag_ode_ivp_adams_setup (d02qw).
This error exit may be caused by overwriting elements of rwork.

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

function nag_ode_ivp_adams_diag_example
t = 0;
y = [0; 1];
tout = 10;
neqg = int64(2);
rwork = zeros(97,1);
iwork = zeros(29, 1, 'int64');
neqf = int64(2);
[statefOut, altergOut, rwork, iwork, ifail] = ...
    nag_ode_ivp_adams_setup('S', int64(2), true, [1e-06;1e-06], [0.0001; 0.0001], false, true, ...
    10, 0, int64(0), int64(2), false, true, rwork, iwork);
[t, y, root, rwork, iwork, ifail] = ...
    nag_ode_ivp_adams_roots(@fcn, t, y, tout, @g, neqg, rwork, iwork);
[yp, tcurr, hlast, hnext, odlast, odnext, nsucc, nfail, tolfac, badcmp, ifail] = ...
    nag_ode_ivp_adams_diag(neqf, rwork, iwork)



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);
  else
    result = y(1);
  end
 

yp =

     1
     0


tcurr =

     0


hlast =

     0


hnext =

     0


odlast =

                    0


odnext =

                    0


nsucc =

                    0


nfail =

                    0


tolfac =

     1


badcmp =

                    0


ifail =

                    0


function d02qx_example
t = 0;
y = [0; 1];
tout = 10;
neqg = int64(2);
rwork = zeros(97,1);
iwork = zeros(29, 1, 'int64');
neqf = int64(2);
[statefOut, altergOut, rwork, iwork, ifail] = ...
    d02qw('S', int64(2), true, [1e-06;1e-06], [0.0001; 0.0001], false, true, ...
    10, 0, int64(0), int64(2), false, true, rwork, iwork);
[t, y, root, rwork, iwork, ifail] = ...
    d02qf(@fcn, t, y, tout, @g, neqg, rwork, iwork);
[yp, tcurr, hlast, hnext, odlast, odnext, nsucc, nfail, tolfac, badcmp, ifail] = ...
    d02qx(neqf, rwork, iwork)



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);
  else
    result = y(1);
  end
 

yp =

     1
     0


tcurr =

     0


hlast =

     0


hnext =

     0


odlast =

                    0


odnext =

                    0


nsucc =

                    0


nfail =

                    0


tolfac =

     1


badcmp =

                    0


ifail =

                    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–2013