NAG Library Routine Document
D02TXF
1 Purpose
D02TXF allows a solution to a nonlinear twopoint boundary value problem computed by
D02TLF to be used as an initial approximation in the solution of a related nonlinear twopoint boundary value problem in a continuation call to
D02TLF.
2 Specification
INTEGER 
MXMESH, NMESH, IPMESH(MXMESH), ICOMM(*), IFAIL 
REAL (KIND=nag_wp) 
MESH(MXMESH), RCOMM(*) 

3 Description
D02TXF and its associated routines (
D02TLF,
D02TVF,
D02TYF and
D02TZF) solve the twopoint boundary value problem for a nonlinear system of ordinary differential equations
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={\displaystyle \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
and the right boundary conditions at
$b$ as
where
$y=\left({y}_{1},{y}_{2},\dots ,{y}_{n}\right)$ and
First,
D02TVF must be called to specify the initial mesh, error requirements and other details. Then,
D02TLF 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.
If the boundary value problem being solved is one of a sequence of related problems, for example as part of some continuation process, then D02TXF should be used between calls to
D02TLF. This avoids the overhead of a complete initialization when the setup routine
D02TVF is used. D02TXF allows the solution values computed in the previous call to
D02TLF to be used as an initial approximation for the solution in the next call to
D02TLF.
You must specify the new initial mesh. The previous mesh can be obtained by a call to
D02TZF. It may be used unchanged as the new mesh, in which case any fixed points in the previous mesh remain as fixed points in the new mesh. Fixed and other points may be added or subtracted from the mesh by manipulation of the contents of the array argument
IPMESH. Initial values for the solution components on the new mesh are computed by interpolation on the values for the solution components on the previous mesh.
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
Keller H B (1992) Numerical Methods for Twopoint Boundaryvalue Problems Dover, New York
5 Arguments
 1: $\mathrm{MXMESH}$ – INTEGERInput

On entry: the maximum number of points allowed in the mesh.
Constraint:
this must be identical to the value supplied for the argument
MXMESH in the prior call to
D02TVF.
 2: $\mathrm{NMESH}$ – INTEGERInput

On entry: the number of points to be used in the new initial mesh. It is strongly recommended that if this routine is called that the suggested value (see below) for
NMESH is used. In this case the arrays
MESH and
IPMESH returned by
D02TZF can be passed to this routine without any modification.
Suggested value:
$\left({n}^{*}+1\right)/2$, where
${n}^{*}$ is the number of mesh points used in the previous mesh as returned in the argument
NMESH of
D02TZF.
Constraint:
$6\le {\mathbf{NMESH}}\le \left({\mathbf{MXMESH}}+1\right)/2$.
 3: $\mathrm{MESH}\left({\mathbf{MXMESH}}\right)$ – REAL (KIND=nag_wp) arrayInput

On entry: the
NMESH points to be used in the new initial mesh as specified by
IPMESH.
Suggested value:
the argument
MESH returned from a call to
D02TZF.
Constraint:
${\mathbf{MESH}}\left({i}_{\mathit{j}}\right)<{\mathbf{MESH}}\left({i}_{\mathit{j}+1}\right)$, for
$\mathit{j}=1,2,\dots ,{\mathbf{NMESH}}1$, the values of
${i}_{1},{i}_{2},\dots ,{i}_{{\mathbf{NMESH}}}$ are defined in
IPMESH.
${\mathbf{MESH}}\left({i}_{1}\right)$ must contain the left boundary point,
$a$, and
${\mathbf{MESH}}\left({i}_{{\mathbf{NMESH}}}\right)$ must contain the right boundary point,
$b$, as specified in the previous call to
D02TVF.
 4: $\mathrm{IPMESH}\left({\mathbf{MXMESH}}\right)$ – INTEGER arrayInput

On entry: specifies the points in
MESH to be used as the new initial mesh. Let
$\left\{{i}_{j}:j=1,2,\dots ,{\mathbf{NMESH}}\right\}$ be the set of array indices of
IPMESH such that
${\mathbf{IPMESH}}\left({i}_{j}\right)=1\text{ or}2$ and
$1={i}_{1}<{i}_{2}<\cdots <{i}_{{\mathbf{NMESH}}}$. Then
${\mathbf{MESH}}\left({i}_{j}\right)$ will be included in the new initial mesh.
If ${\mathbf{IPMESH}}\left({i}_{j}\right)=1$, ${\mathbf{MESH}}\left({i}_{j}\right)$ will be a fixed point in the new initial mesh.
If ${\mathbf{IPMESH}}\left(k\right)=3$ for any $k$, then ${\mathbf{MESH}}\left(k\right)$ will not be included in the new mesh.
Suggested value:
the argument
IPMESH returned in a call to
D02TZF.
Constraints:
 ${\mathbf{IPMESH}}\left(\mathit{k}\right)=1$, $2$ or $3$, for $\mathit{k}=1,2,\dots ,{i}_{{\mathbf{NMESH}}}$;
 ${\mathbf{IPMESH}}\left(1\right)={\mathbf{IPMESH}}\left({i}_{{\mathbf{NMESH}}}\right)=1$.
 5: $\mathrm{RCOMM}\left(*\right)$ – REAL (KIND=nag_wp) arrayCommunication Array

Note: the dimension of this array is dictated by the requirements of associated functions that must have been previously called. This array
must be the same array passed as argument
RCOMM in the previous call to
D02TLF.
On entry: this must be the same array as supplied to
D02TLF and
must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
 6: $\mathrm{ICOMM}\left(*\right)$ – INTEGER arrayCommunication Array

Note: the dimension of this array is dictated by the requirements of associated functions that must have been previously called. This array
must be the same array passed as argument
ICOMM in the previous call to
D02TLF.
On entry: this must be the same array as supplied to
D02TLF and
must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
 7: $\mathrm{IFAIL}$ – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ or}1$. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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, if you are not familiar with this argument, the recommended value is
$0$.
When the value $\mathbf{1}\text{ or}\mathbf{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}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
 ${\mathbf{IFAIL}}=1$

An element of
IPMESH was set to
$1$ before
NMESH elements containing
$1$ or
$2$ were detected.
Expected
$\u2329\mathit{\text{value}}\u232a$ elements of
IPMESH to be
$1$ or
$2$, but
$\u2329\mathit{\text{value}}\u232a$ such elements found.
${\mathbf{IPMESH}}\left(i\right)\ne 1$, $1$, $2$ or $3$ for some $i$.
On entry, ${\mathbf{IPMESH}}\left(1\right)=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{IPMESH}}\left(1\right)=1$.
On entry,
${\mathbf{MXMESH}}=\u2329\mathit{\text{value}}\u232a$ and
${\mathbf{MXMESH}}=\u2329\mathit{\text{value}}\u232a$ in
D02TVF.
Constraint:
${\mathbf{MXMESH}}={\mathbf{MXMESH}}$ in
D02TVF.
On entry, ${\mathbf{NMESH}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{NMESH}}\ge 6$.
On entry, ${\mathbf{NMESH}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{MXMESH}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{NMESH}}\le \left({\mathbf{MXMESH}}+1\right)/2$.
The entries in
MESH are not strictly increasing.
The first element of array
MESH does not coincide with the left hand end of the range previously specified.
First element of
MESH:
$\u2329\mathit{\text{value}}\u232a$; left hand of the range:
$\u2329\mathit{\text{value}}\u232a$.
The last point of the new mesh does not coincide with the right hand end of the range previously specified.
Last point of the new mesh: $\u2329\mathit{\text{value}}\u232a$; right hand end of the range: $\u2329\mathit{\text{value}}\u232a$.
The solver routine did not produce any results suitable for remeshing.
The solver routine does not appear to have been called.
You have set the element of
IPMESH corresponding to the last element of
MESH to be included in the new mesh as
$\u2329\mathit{\text{value}}\u232a$, which is not
$1$.
 ${\mathbf{IFAIL}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{IFAIL}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{IFAIL}}=999$
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7 Accuracy
Not applicable.
8 Parallelism and Performance
D02TXF is not threaded in any implementation.
For problems where sharp changes of behaviour are expected over short intervals it may be advisable to:
– 
cluster the mesh points where sharp changes in behaviour are expected; 
– 
maintain fixed points in the mesh using the argument IPMESH to ensure that the remeshing process does not inadvertently remove mesh points from areas of known interest. 
In the absence of any other information about the expected behaviour of the solution, using the values suggested in
Section 5 for
NMESH,
IPMESH and
MESH is strongly recommended.
10 Example
This example illustrates the use of continuation, solution on an infinite range, and solution of a system of two differential equations of orders
$3$ and
$2$. See also
D02TLF,
D02TVF,
D02TYF and
D02TZF, for the illustration of other facilities.
Consider the problem of swirling flow over an infinite stationary disk with a magnetic field along the axis of rotation. See
Ascher et al. (1988) and the references therein. After transforming from a cylindrical coordinate system
$\left(r,\theta ,z\right)$, in which the
$\theta $ component of the corresponding velocity field behaves like
${r}^{n}$, the governing equations are
with boundary conditions
where
$s$ is the magnetic field strength, and
$\gamma $ is the Rossby number.
Some solutions of interest are for
$\gamma =1$, small
$n$ and
$s\to 0$. An added complication is the infinite range, which we approximate by
$\left[0,L\right]$. We choose
$n=0.2$ and first solve for
$L=60.0,s=0.24$ using the initial approximations
$f\left(x\right)={x}^{2}{e}^{x}$ and
$g\left(x\right)=1.0{e}^{x}$, which satisfy the boundary conditions, on a uniform mesh of
$21$ points. Simple continuation on the parameters
$L$ and
$s$ using the values
$L=120.0,s=0.144$ and then
$L=240.0,s=0.0864$ is used to compute further solutions. We use the suggested values for
NMESH,
IPMESH and
MESH in the call to D02TXF prior to a continuation call, that is only every second point of the preceding mesh is used.
The equations are first mapped onto
$\left[0,1\right]$ to yield
10.1 Program Text
Program Text (d02txfe.f90)
10.2 Program Data
Program Data (d02txfe.d)
10.3 Program Results
Program Results (d02txfe.r)