D02TZF (PDF version)
D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD02TZF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D02TZF returns information about the solution of a general two-point boundary value problem computed by D02TKF.

## 2  Specification

 SUBROUTINE D02TZF ( MXMESH, NMESH, MESH, IPMESH, ERMX, IERMX, IJERMX, RWORK, IWORK, IFAIL)
 INTEGER MXMESH, NMESH, IPMESH(MXMESH), IERMX, IJERMX, IWORK(*), IFAIL REAL (KIND=nag_wp) MESH(MXMESH), ERMX, RWORK(*)

## 3  Description

D02TZF and its associated routines (D02TKF, D02TVF, D02TXF and D02TYF) solve the two-point boundary value problem for a nonlinear mixed order system of ordinary differential equations
 $y1m1 x = f1 x,y1,y11,…,y1m1-1,y2,…,ynmn-1 y2m2 x = f2 x,y1,y11,…,y1m1-1,y2,…,ynmn-1 ⋮ ynmn x = fn x,y1,y11,…,y1m1-1,y2,…,ynmn-1$
over an interval $\left[a,b\right]$ subject to $p$ ($\text{}>0$) nonlinear boundary conditions at $a$ and $q$ ($\text{}>0$) nonlinear boundary conditions at $b$, where $p+q=\sum _{i=1}^{n}{m}_{i}$. Note that ${y}_{i}^{\left(m\right)}\left(x\right)$ is the $m$th derivative of the $i$th solution component. Hence ${y}_{i}^{\left(0\right)}\left(x\right)={y}_{i}\left(x\right)$. The left boundary conditions at $a$ are defined as
 $gizya=0, i=1,2,…,p,$
and the right boundary conditions at $b$ as
 $g-jzyb=0, j=1,2,…,q,$
where $y=\left({y}_{1},{y}_{2},\dots ,{y}_{n}\right)$ and
 $zyx = y1x, y11 x ,…, y1m1-1 x ,y2x,…, ynmn-1 x .$
First, D02TVF must be called to specify the initial mesh, error requirements and other details. Then, D02TKF can be used to solve the boundary value problem. After successful computation, D02TZF can be used to ascertain details about the final mesh. D02TYF can be used to compute the approximate solution anywhere on the interval $\left[a,b\right]$ using interpolation.
The routines are based on modified versions of the codes COLSYS and COLNEW (see Ascher et al. (1979) and Ascher and Bader (1987)). A comprehensive treatment of the numerical solution of boundary value problems can be found in Ascher et al. (1988) and Keller (1992).

## 4  References

Ascher U M and Bader G (1987) A new basis implementation for a mixed order boundary value ODE solver SIAM J. Sci. Stat. Comput. 8 483–500
Ascher U M, Christiansen J and Russell R D (1979) A collocation solver for mixed order systems of boundary value problems Math. Comput. 33 659–679
Ascher U M, Mattheij R M M and Russell R D (1988) Numerical Solution of Boundary Value Problems for Ordinary Differential Equations Prentice–Hall
Cole J D (1968) Perturbation Methods in Applied Mathematics Blaisdell, Waltham, Mass.
Keller H B (1992) Numerical Methods for Two-point Boundary-value Problems Dover, New York

## 5  Parameters

1:     MXMESH – INTEGERInput
On entry: the maximum number of points allowed in the mesh.
Constraint: this must be identical to the value supplied for the parameter MXMESH in the prior call to D02TVF.
2:     NMESH – INTEGEROutput
On exit: the number of points in the mesh last used by D02TKF.
3:     MESH(MXMESH) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{MESH}}\left(\mathit{i}\right)$ contains the $\mathit{i}$th point of the mesh last used by D02TKF, for $\mathit{i}=1,2,\dots ,{\mathbf{NMESH}}$. ${\mathbf{MESH}}\left(1\right)$ will contain $a$ and ${\mathbf{MESH}}\left({\mathbf{NMESH}}\right)$ will contain $b$. The remaining elements of MESH are not initialized.
4:     IPMESH(MXMESH) – INTEGER arrayOutput
On exit: ${\mathbf{IPMESH}}\left(\mathit{i}\right)$ specifies the nature of the point ${\mathbf{MESH}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NMESH}}$, in the final mesh computed by D02TKF.
${\mathbf{IPMESH}}\left(i\right)=1$
Indicates that the $i$th point is a fixed point and was used by the solver before an extrapolation-like error test.
${\mathbf{IPMESH}}\left(i\right)=2$
Indicates that the $i$th point was used by the solver before an extrapolation-like error test.
${\mathbf{IPMESH}}\left(i\right)=3$
Indicates that the $i$th point was used by the solver only as part of an extrapolation-like error test.
The remaining elements of IPMESH are initialized to $-1$.
See Section 8 for advice on how these values may be used in conjunction with a continuation process.
5:     ERMX – REAL (KIND=nag_wp)Output
On exit: an estimate of the maximum error in the solution computed by D02TKF, that is
 $ERMX=max⁡yi-vi 1.0+vi$
where ${v}_{i}$ is the approximate solution for the $i$th solution component. If D02TKF returned successfully with ${\mathbf{IFAIL}}={\mathbf{0}}$, then ERMX will be less than ${\mathbf{TOLS}}\left({\mathbf{IJERMX}}\right)$ where TOLS contains the error requirements as specified in Sections 3 and 5 in D02TVF.
If D02TKF returned with ${\mathbf{IFAIL}}={\mathbf{5}}$, then ERMX will be greater than ${\mathbf{TOLS}}\left({\mathbf{IJERMX}}\right)$.
If D02TKF returned any other value for IFAIL then an error estimate is not available and ERMX is initialized to $0.0$.
6:     IERMX – INTEGEROutput
On exit: indicates the mesh sub-interval where the value of ERMX has been computed, that is $\left[{\mathbf{MESH}}\left({\mathbf{IERMX}}\right),{\mathbf{MESH}}\left({\mathbf{IERMX}}+1\right)\right]$.
If an estimate of the error is not available then IERMX is initialized to $0$.
7:     IJERMX – INTEGEROutput
On exit: indicates the component $i$ ($\text{}={\mathbf{IJERMX}}$) of the solution for which ERMX has been computed, that is the approximation of ${y}_{i}$ on $\left[{\mathbf{MESH}}\left({\mathbf{IERMX}}\right),{\mathbf{MESH}}\left({\mathbf{IERMX}}+1\right)\right]$ is estimated to have the largest error of all components ${y}_{i}$ over mesh sub-intervals defined by MESH.
If an estimate of the error is not available then IJERMX is initialized to $0$.
8:     RWORK($*$) – REAL (KIND=nag_wp) arrayCommunication Array
Note: the dimension of the array RWORK must be at least ${\mathbf{LRWORK}}$ (see D02TVF).
On entry: this must be the same array as supplied to D02TKF and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
9:     IWORK($*$) – INTEGER arrayCommunication Array
Note: the dimension of the array IWORK must be at least ${\mathbf{LIWORK}}$ (see D02TVF).
On entry: this must be the same array as supplied to D02TKF and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
10:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if ${\mathbf{IFAIL}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}1$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: D02TZF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
On entry, an illegal value for MXMESH was specified, or an invalid call to D02TZF was made, for example without a previous call to the solver routine D02TKF.
${\mathbf{IFAIL}}=2$
The solver routine D02TKF did not converge to a solution or did not satisfy the error requirements. The last mesh computed by D02TKF has been returned by D02TZF. This mesh should be treated with extreme caution as nothing can be said regarding its quality or suitability for any subsequent computation.

Not applicable.

## 8  Further Comments

Note that
• if D02TKF returned ${\mathbf{IFAIL}}={\mathbf{0}}$, ${\mathbf{4}}$ or ${\mathbf{5}}$ then it will always be the case that ${\mathbf{IPMESH}}\left(1\right)={\mathbf{IPMESH}}\left({\mathbf{NMESH}}\right)=1$;
• if D02TKF returned ${\mathbf{IFAIL}}={\mathbf{0}}$ or ${\mathbf{5}}$ then it will always be the case that ${\mathbf{IPMESH}}\left(\mathit{i}\right)=3$, for $\mathit{i}=2,3,\dots ,{\mathbf{NMESH}}-1$ and ${\mathbf{IPMESH}}\left(\mathit{i}\right)=1$ or $2$, for $\mathit{i}=3,4,\dots ,{\mathbf{NMESH}}-2$;
• if D02TKF returned ${\mathbf{IFAIL}}={\mathbf{4}}$ then it will always be the case that ${\mathbf{IPMESH}}\left(\mathit{i}\right)=1\text{​ or ​}2$, for $\mathit{i}=2,3,\dots ,{\mathbf{NMESH}}-1$.
If D02TZF returns the value ${\mathbf{IFAIL}}={\mathbf{0}}$, then examination of the mesh may provide assistance in determining a suitable starting mesh for D02TVF in any subsequent attempts to solve similar problems.
If the problem being treated by D02TKF is one of a series of related problems (for example, as part of a continuation process), then the values of IPMESH and MESH may be suitable as input parameters to D02TXF. Using the mesh points not involved in the extrapolation error test is usually appropriate. IPMESH and MESH should be passed unchanged to D02TXF but NMESH should be replaced by $\left({\mathbf{NMESH}}+1\right)/2$.
If D02TZF returns the value ${\mathbf{IFAIL}}={\mathbf{2}}$, nothing can be said regarding the quality of the mesh returned. However, it may be a useful starting mesh for D02TVF in any subsequent attempts to solve the same problem.
If D02TKF returns the value ${\mathbf{IFAIL}}={\mathbf{5}}$, this corresponds to the solver requiring more than MXMESH mesh points to satisfy the error requirements. If MXMESH can be increased and the preceding call to D02TKF was not part, or was the first part, of a continuation process then the values in MESH may provide a suitable mesh with which to initialize a subsequent attempt to solve the same problem. If it is not possible to provide more mesh points then relaxing the error requirements by setting ${\mathbf{TOLS}}\left({\mathbf{IJERMX}}\right)$ to ERMX might lead to a successful solution. It may be necessary to reset the other components of TOLS. Note that resetting the tolerances can lead to a different sequence of meshes being computed and hence to a different solution being computed.

## 9  Example

The following example is used to illustrate the use of fixed mesh points, simple continuation and numerical approximation of a Jacobian. See also D02TKF, D02TVF, D02TXF and D02TYF, for the illustration of other facilities.
Consider the Lagerstrom–Cole equation
 $y′′=y-yy′/ε$
with the boundary conditions
 $y0=α y1=β,$ (1)
where $\epsilon$ is small and positive. The nature of the solution depends markedly on the values of $\alpha ,\beta$. See Cole (1968).
We choose $\alpha =-\frac{1}{3},\beta =\frac{1}{3}$ for which the solution is known to have corner layers at $x=\frac{1}{3},\frac{2}{3}$. We choose an initial mesh of seven points $\left[0.0,0.15,0.3,0.5,0.7,0.85,1.0\right]$ and ensure that the points $x=0.3,0.7$ near the corner layers are fixed, that is the corresponding elements of the array IPMESH are set to $1$. First we compute the solution for $\epsilon =\text{1.0E−4}$ using in GUESS the initial approximation $y\left(x\right)=\alpha +\left(\beta -\alpha \right)x$ which satisfies the boundary conditions. Then we use simple continuation to compute the solution for $\epsilon =\text{1.0E−5}$. We use the suggested values for NMESH, IPMESH and MESH in the call to D02TXF prior to the continuation call, that is only every second point of the preceding mesh is used and the fixed mesh points are retained.
Although the analytic Jacobian for this system is easy to evaluate, for illustration the procedure FJAC uses central differences and calls to FFUN to compute a numerical approximation to the Jacobian.

### 9.1  Program Text

Program Text (d02tzfe.f90)

### 9.2  Program Data

Program Data (d02tzfe.d)

### 9.3  Program Results

Program Results (d02tzfe.r)

D02TZF (PDF version)
D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual