NAG Library Routine Document
D02TYF
1 Purpose
D02TYF interpolates on the solution of a general twopoint boundary value problem computed by
D02TLF.
2 Specification
INTEGER 
NEQ, MMAX, ICOMM(*), IFAIL 
REAL (KIND=nag_wp) 
X, Y(NEQ,MMAX), RCOMM(*) 

3 Description
D02TYF and its associated routines (
D02TLF,
D02TVF,
D02TXF and
D02TZF) solve the twopoint boundary value problem for a nonlinear mixed order 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 and other details of the solution procedure, and 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
Grossman C (1992) Enclosures of the solution of the Thomas–Fermi equation by monotone discretization J. Comput. Phys. 98 26–32
Keller H B (1992) Numerical Methods for Twopoint Boundaryvalue Problems Dover, New York
5 Arguments
 1: $\mathrm{X}$ – REAL (KIND=nag_wp)Input

On entry: $x$, the independent variable.
Constraint:
$a\le {\mathbf{X}}\le b$, i.e., not outside the range of the original mesh specified in the initialization call to
D02TVF.
 2: $\mathrm{Y}\left({\mathbf{NEQ}},{\mathbf{MMAX}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit:
${\mathbf{Y}}\left(\mathit{i},\mathit{j}\right)$ contains an approximation to
${y}_{\mathit{i}}^{\left(\mathit{j}\right)}\left(x\right)$, for
$\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$ and
$\mathit{j}=0,1,\dots ,{m}_{\mathit{i}}1$. The remaining elements of
Y (where
${m}_{i}<{\mathbf{MMAX}}$) are initialized to
$0.0$.
 3: $\mathrm{NEQ}$ – INTEGERInput

On entry: the number of differential equations.
Constraint:
${\mathbf{NEQ}}$ must be the same value as supplied to
D02TVF.
 4: $\mathrm{MMAX}$ – INTEGERInput

On entry: the maximal order of the differential equations,
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({m}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$.
Constraint:
${\mathbf{MMAX}}$ must contain the maximum value of the components of the argument
M as supplied to
D02TVF.
 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, because for this routine the values of the output arguments 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}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Note: D02TYF 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, ${\mathbf{MMAX}}=\u2329\mathit{\text{value}}\u232a$ and $\mathrm{max}\phantom{\rule{0.25em}{0ex}}{\mathbf{M}}\left(i\right)=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{MMAX}}=\mathrm{max}\phantom{\rule{0.25em}{0ex}}{\mathbf{M}}\left(i\right)$.
On entry,
${\mathbf{NEQ}}=\u2329\mathit{\text{value}}\u232a$ and
${\mathbf{NEQ}}=\u2329\mathit{\text{value}}\u232a$ in
D02TVF.
Constraint:
${\mathbf{NEQ}}={\mathbf{NEQ}}$ in
D02TVF.
On entry, ${\mathbf{X}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{X}}\le \u2329\mathit{\text{value}}\u232a$.
On entry, ${\mathbf{X}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{X}}\ge \u2329\mathit{\text{value}}\u232a$.
The solver routine did not produce any results suitable for interpolation.
The solver routine does not appear to have been called.
 ${\mathbf{IFAIL}}=2$

The solver routine did not converge to a suitable solution.
A converged intermediate solution has been used.
Interpolated values should be treated with caution.
The solver routine did not satisfy the error requirements.
Interpolated values should be treated with caution.
 ${\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
If D02TYF returns the value
${\mathbf{IFAIL}}={\mathbf{0}}$, the computed values of the solution components
${y}_{i}$ should be of similar accuracy to that specified by the argument
TOLS of
D02TVF. Note that during the solution process the error in the derivatives
${y}_{i}^{\left(\mathit{j}\right)}$, for
$\mathit{j}=1,2,\dots ,{m}_{i}1$, has not been controlled and that the derivative values returned by D02TYF are computed via differentiation of the piecewise polynomial approximation to
${y}_{i}$. See also
Section 9.
8 Parallelism and Performance
D02TYF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
If D02TYF returns the value
${\mathbf{IFAIL}}={\mathbf{2}}$ in this routine and
${\mathbf{IFAIL}}={\mathbf{5}}$ in
D02TLF,
then the accuracy of the interpolated values may be proportional to the quantity
ERMX as returned by
D02TZF.
If
D02TLF returned a value for
IFAIL
other than
${\mathbf{IFAIL}}={\mathbf{0}}$, then nothing can be said regarding either the quality or accuracy of the values computed by D02TYF.
10 Example
The following example is used to illustrate that a system with singular coefficients can be treated without modification of the system definition. See also
D02TLF,
D02TVF,
D02TXF and
D02TZF, for the illustration of other facilities.
Consider the Thomas–Fermi equation used in the investigation of potentials and charge densities of ionized atoms. See
Grossman (1992), for example, and the references therein. The equation is
with boundary conditions
The coefficient
${x}^{1/2}$ implies a singularity at the lefthand boundary
$x=0$.
We use the initial approximation
$y\left(x\right)=1x/a$, which satisfies the boundary conditions, on a uniform mesh of six points. For illustration we choose
$a=1$, as in
Grossman (1992). Note that in
FFUN and
FJAC (see
D02TLF) we have taken the precaution of setting the function value and Jacobian value to
$0.0$ in case a value of
$y$ becomes negative, although starting from our initial solution profile this proves unnecessary during the solution phase. Of course the true solution
$y\left(x\right)$ is positive for all
$x<a$.
10.1 Program Text
Program Text (d02tyfe.f90)
10.2 Program Data
Program Data (d02tyfe.d)
10.3 Program Results
Program Results (d02tyfe.r)