# NAG FL Interfaced02tlf (bvp_​coll_​nlin_​solve)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

d02tlf solves a general two-point boundary value problem for a nonlinear mixed order system of ordinary differential equations.

## 2Specification

Fortran Interface
 Subroutine d02tlf ( ffun, fjac,
 Integer, Intent (Inout) :: icomm(*), iuser(*), ifail Real (Kind=nag_wp), Intent (Inout) :: rcomm(*), ruser(*) External :: ffun, fjac, gafun, gbfun, gajac, gbjac, guess
#include <nag.h>
 void d02tlf_ (void (NAG_CALL *ffun)(const double *x, const double y[], const Integer *neq, const Integer m[], double f[], Integer iuser[], double ruser[]),void (NAG_CALL *fjac)(const double *x, const double y[], const Integer *neq, const Integer m[], double dfdy[], Integer iuser[], double ruser[]),void (NAG_CALL *gafun)(const double ya[], const Integer *neq, const Integer m[], const Integer *nlbc, double ga[], Integer iuser[], double ruser[]),void (NAG_CALL *gbfun)(const double yb[], const Integer *neq, const Integer m[], const Integer *nrbc, double gb[], Integer iuser[], double ruser[]),void (NAG_CALL *gajac)(const double ya[], const Integer *neq, const Integer m[], const Integer *nlbc, double dgady[], Integer iuser[], double ruser[]),void (NAG_CALL *gbjac)(const double yb[], const Integer *neq, const Integer m[], const Integer *nrbc, double dgbdy[], Integer iuser[], double ruser[]),void (NAG_CALL *guess)(const double *x, const Integer *neq, const Integer m[], double y[], double dym[], Integer iuser[], double ruser[]),double rcomm[], Integer icomm[], Integer iuser[], double ruser[], Integer *ifail)
The routine may be called by the names d02tlf or nagf_ode_bvp_coll_nlin_solve.

## 3Description

d02tlf and its associated routines (d02tvf, d02txf, d02tyf and d02tzf) solve the two-point boundary value problem for a nonlinear mixed order system of ordinary differential equations
 $y1(m1) (x) = f1 (x,y1,y1(1),…,y1(m1-1),y2,…,yn(mn-1)) y2(m2) (x) = f2 (x,y1,y1(1),…,y1(m1-1),y2,…,yn(mn-1)) ⋮ yn(mn) (x) = fn (x,y1,y1(1),…,y1(m1-1),y2,…,yn(mn-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
 $gi(z(y(a)))=0, i=1,2,…,p,$
and the right boundary conditions at $b$ as
 $g¯j(z(y(b)))=0, j=1,2,…,q,$
where $y=\left({y}_{1},{y}_{2},\dots ,{y}_{n}\right)$ and
 $z(y(x)) = (y1(x), y1(1) (x) ,…, y1(m1-1) (x) ,y2(x),…, yn(mn-1) (x) ) .$
First, d02tvf must be called to specify the initial mesh, error requirements and other details. Note that the error requirements apply only to the solution components ${y}_{1},{y}_{2},\dots ,{y}_{n}$ and that no error control is applied to derivatives of solution components. (If error control is required on derivatives then the system must be reduced in order by introducing the derivatives whose error is to be controlled as new variables. See Section 9 in d02tvf.) 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]$.
A description of the numerical technique used in d02tlf is given in Section 3 in d02tvf.
d02tlf can also be used in the solution of a series of problems, for example in performing continuation, when the mesh used to compute the solution of one problem is to be used as the initial mesh for the solution of the next related problem. d02txf should be used in between calls to d02tlf in this context.
See Section 9 in d02tvf for details of how to solve boundary value problems of a more general nature.
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).
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 Two-point Boundary-value Problems Dover, New York

## 5Arguments

1: $\mathbf{ffun}$Subroutine, supplied by the user. External Procedure
ffun must evaluate the functions ${f}_{i}$ for given values $x,z\left(y\left(x\right)\right)$.
The specification of ffun is:
Fortran Interface
 Subroutine ffun ( x, y, neq, m, f,
 Integer, Intent (In) :: neq, m(neq) Integer, Intent (Inout) :: iuser(*) Real (Kind=nag_wp), Intent (In) :: x, y(neq,$0:*$) Real (Kind=nag_wp), Intent (Inout) :: ruser(*) Real (Kind=nag_wp), Intent (Out) :: f(neq)
 void ffun (const double *x, const double y[], const Integer *neq, const Integer m[], double f[], Integer iuser[], double ruser[])
1: $\mathbf{x}$Real (Kind=nag_wp) Input
On entry: $x$, the independent variable.
2: $\mathbf{y}\left({\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{y}}\left(\mathit{i},\mathit{j}\right)$ contains ${y}_{\mathit{i}}^{\left(\mathit{j}\right)}\left(x\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(\mathit{i}\right)-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(x\right)={y}_{i}\left(x\right)$.
3: $\mathbf{neq}$Integer Input
On entry: the number of differential equations.
4: $\mathbf{m}\left({\mathbf{neq}}\right)$Integer array Input
On entry: ${\mathbf{m}}\left(\mathit{i}\right)$ contains ${m}_{\mathit{i}}$, the order of the $\mathit{i}$th differential equation, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
5: $\mathbf{f}\left({\mathbf{neq}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{f}}\left(\mathit{i}\right)$ must contain ${f}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
6: $\mathbf{iuser}\left(*\right)$Integer array User Workspace
7: $\mathbf{ruser}\left(*\right)$Real (Kind=nag_wp) array User Workspace
ffun is called with the arguments iuser and ruser as supplied to d02tlf. You should use the arrays iuser and ruser to supply information to ffun.
ffun must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tlf is called. Arguments denoted as Input must not be changed by this procedure.
Note: ffun should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tlf. If your code inadvertently does return any NaNs or infinities, d02tlf is likely to produce unexpected results.
2: $\mathbf{fjac}$Subroutine, supplied by the user. External Procedure
fjac must evaluate the partial derivatives of ${f}_{i}$ with respect to the elements of
$z\left(y\left(x\right)\right)=\left({y}_{1}\left(x\right),{y}_{1}^{1}\left(x\right),\dots ,{y}_{1}^{\left({m}_{1}-1\right)}\left(x\right),{y}_{2}\left(x\right),\dots ,{y}_{n}^{\left({m}_{n}-1\right)}\left(x\right)\right)$.
The specification of fjac is:
Fortran Interface
 Subroutine fjac ( x, y, neq, m, dfdy,
 Integer, Intent (In) :: neq, m(neq) Integer, Intent (Inout) :: iuser(*) Real (Kind=nag_wp), Intent (In) :: x, y(neq,$0:*$) Real (Kind=nag_wp), Intent (Inout) :: dfdy(neq,neq,$0:*$), ruser(*)
 void fjac (const double *x, const double y[], const Integer *neq, const Integer m[], double dfdy[], Integer iuser[], double ruser[])
1: $\mathbf{x}$Real (Kind=nag_wp) Input
On entry: $x$, the independent variable.
2: $\mathbf{y}\left({\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{y}}\left(\mathit{i},\mathit{j}\right)$ contains ${y}_{\mathit{i}}^{\left(\mathit{j}\right)}\left(x\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(\mathit{i}\right)-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(x\right)={y}_{i}\left(x\right)$.
3: $\mathbf{neq}$Integer Input
On entry: the number of differential equations.
4: $\mathbf{m}\left({\mathbf{neq}}\right)$Integer array Input
On entry: ${\mathbf{m}}\left(\mathit{i}\right)$ contains ${m}_{\mathit{i}}$, the order of the $\mathit{i}$th differential equation, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
5: $\mathbf{dfdy}\left({\mathbf{neq}},{\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input/Output
On entry: set to zero.
On exit: ${\mathbf{dfdy}}\left(\mathit{i},\mathit{j},\mathit{k}\right)$ must contain the partial derivative of ${f}_{\mathit{i}}$ with respect to ${y}_{\mathit{j}}^{\left(\mathit{k}\right)}$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$, $\mathit{j}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{k}=0,1,\dots ,{\mathbf{m}}\left(\mathit{j}\right)-1$. Only nonzero partial derivatives need be set.
6: $\mathbf{iuser}\left(*\right)$Integer array User Workspace
7: $\mathbf{ruser}\left(*\right)$Real (Kind=nag_wp) array User Workspace
fjac is called with the arguments iuser and ruser as supplied to d02tlf. You should use the arrays iuser and ruser to supply information to fjac.
fjac must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tlf is called. Arguments denoted as Input must not be changed by this procedure.
Note: fjac should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tlf. If your code inadvertently does return any NaNs or infinities, d02tlf is likely to produce unexpected results.
3: $\mathbf{gafun}$Subroutine, supplied by the user. External Procedure
gafun must evaluate the boundary conditions at the left-hand end of the range, that is functions ${g}_{i}\left(z\left(y\left(a\right)\right)\right)$ for given values of $z\left(y\left(a\right)\right)$.
The specification of gafun is:
Fortran Interface
 Subroutine gafun ( ya, neq, m, nlbc, ga,
 Integer, Intent (In) :: neq, m(neq), nlbc Integer, Intent (Inout) :: iuser(*) Real (Kind=nag_wp), Intent (In) :: ya(neq,$0:*$) Real (Kind=nag_wp), Intent (Inout) :: ruser(*) Real (Kind=nag_wp), Intent (Out) :: ga(nlbc)
 void gafun (const double ya[], const Integer *neq, const Integer m[], const Integer *nlbc, double ga[], Integer iuser[], double ruser[])
1: $\mathbf{ya}\left({\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{ya}}\left(\mathit{i},\mathit{j}\right)$ contains ${y}_{\mathit{i}}^{\left(\mathit{j}\right)}\left(a\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(\mathit{i}\right)-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(a\right)={y}_{i}\left(a\right)$.
2: $\mathbf{neq}$Integer Input
On entry: the number of differential equations.
3: $\mathbf{m}\left({\mathbf{neq}}\right)$Integer array Input
On entry: ${\mathbf{m}}\left(\mathit{i}\right)$ contains ${m}_{\mathit{i}}$, the order of the $\mathit{i}$th differential equation, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
4: $\mathbf{nlbc}$Integer Input
On entry: the number of boundary conditions at $a$.
5: $\mathbf{ga}\left({\mathbf{nlbc}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{ga}}\left(\mathit{i}\right)$ must contain ${g}_{\mathit{i}}\left(z\left(y\left(a\right)\right)\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nlbc}}$.
6: $\mathbf{iuser}\left(*\right)$Integer array User Workspace
7: $\mathbf{ruser}\left(*\right)$Real (Kind=nag_wp) array User Workspace
gafun is called with the arguments iuser and ruser as supplied to d02tlf. You should use the arrays iuser and ruser to supply information to gafun.
gafun must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tlf is called. Arguments denoted as Input must not be changed by this procedure.
Note: gafun should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tlf. If your code inadvertently does return any NaNs or infinities, d02tlf is likely to produce unexpected results.
4: $\mathbf{gbfun}$Subroutine, supplied by the user. External Procedure
gbfun must evaluate the boundary conditions at the right-hand end of the range, that is functions ${\overline{g}}_{i}\left(z\left(y\left(b\right)\right)\right)$ for given values of $z\left(y\left(b\right)\right)$.
The specification of gbfun is:
Fortran Interface
 Subroutine gbfun ( yb, neq, m, nrbc, gb,
 Integer, Intent (In) :: neq, m(neq), nrbc Integer, Intent (Inout) :: iuser(*) Real (Kind=nag_wp), Intent (In) :: yb(neq,$0:*$) Real (Kind=nag_wp), Intent (Inout) :: ruser(*) Real (Kind=nag_wp), Intent (Out) :: gb(nrbc)
 void gbfun (const double yb[], const Integer *neq, const Integer m[], const Integer *nrbc, double gb[], Integer iuser[], double ruser[])
1: $\mathbf{yb}\left({\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{yb}}\left(\mathit{i},\mathit{j}\right)$ contains ${y}_{\mathit{i}}^{\left(\mathit{j}\right)}\left(b\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(\mathit{i}\right)-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(b\right)={y}_{i}\left(b\right)$.
2: $\mathbf{neq}$Integer Input
On entry: the number of differential equations.
3: $\mathbf{m}\left({\mathbf{neq}}\right)$Integer array Input
On entry: ${\mathbf{m}}\left(\mathit{i}\right)$ contains ${m}_{\mathit{i}}$, the order of the $\mathit{i}$th differential equation, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
4: $\mathbf{nrbc}$Integer Input
On entry: the number of boundary conditions at $b$.
5: $\mathbf{gb}\left({\mathbf{nrbc}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{gb}}\left(\mathit{i}\right)$ must contain ${\overline{g}}_{\mathit{i}}\left(z\left(y\left(b\right)\right)\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nrbc}}$.
6: $\mathbf{iuser}\left(*\right)$Integer array User Workspace
7: $\mathbf{ruser}\left(*\right)$Real (Kind=nag_wp) array User Workspace
gbfun is called with the arguments iuser and ruser as supplied to d02tlf. You should use the arrays iuser and ruser to supply information to gbfun.
gbfun must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tlf is called. Arguments denoted as Input must not be changed by this procedure.
Note: gbfun should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tlf. If your code inadvertently does return any NaNs or infinities, d02tlf is likely to produce unexpected results.
5: $\mathbf{gajac}$Subroutine, supplied by the user. External Procedure
gajac must evaluate the partial derivatives of ${g}_{i}\left(z\left(y\left(a\right)\right)\right)$ with respect to the elements of $z\left(y\left(a\right)\right)=\left({y}_{1}\left(a\right),{y}_{1}^{1}\left(a\right),\dots ,{y}_{1}^{\left({m}_{1}-1\right)}\left(a\right),{y}_{2}\left(a\right),\dots ,{y}_{n}^{\left({m}_{n}-1\right)}\left(a\right)\right)$.
The specification of gajac is:
Fortran Interface
 Subroutine gajac ( ya, neq, m, nlbc,
 Integer, Intent (In) :: neq, m(neq), nlbc Integer, Intent (Inout) :: iuser(*) Real (Kind=nag_wp), Intent (In) :: ya(neq,$0:*$) Real (Kind=nag_wp), Intent (Inout) :: dgady(nlbc,neq,$0:*$), ruser(*)
 void gajac (const double ya[], const Integer *neq, const Integer m[], const Integer *nlbc, double dgady[], Integer iuser[], double ruser[])
1: $\mathbf{ya}\left({\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{ya}}\left(\mathit{i},\mathit{j}\right)$ contains ${y}_{\mathit{i}}^{\left(\mathit{j}\right)}\left(a\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(\mathit{i}\right)-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(a\right)={y}_{i}\left(a\right)$.
2: $\mathbf{neq}$Integer Input
On entry: the number of differential equations.
3: $\mathbf{m}\left({\mathbf{neq}}\right)$Integer array Input
On entry: ${\mathbf{m}}\left(\mathit{i}\right)$ contains ${m}_{\mathit{i}}$, the order of the $\mathit{i}$th differential equation, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
4: $\mathbf{nlbc}$Integer Input
On entry: the number of boundary conditions at $a$.
5: $\mathbf{dgady}\left({\mathbf{nlbc}},{\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input/Output
On entry: set to zero.
On exit: ${\mathbf{dgady}}\left(\mathit{i},\mathit{j},\mathit{k}\right)$ must contain the partial derivative of ${g}_{\mathit{i}}\left(z\left(y\left(a\right)\right)\right)$ with respect to ${y}_{\mathit{j}}^{\left(\mathit{k}\right)}\left(a\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nlbc}}$, $\mathit{j}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{k}=0,1,\dots ,{\mathbf{m}}\left(\mathit{j}\right)-1$. Only nonzero partial derivatives need be set.
6: $\mathbf{iuser}\left(*\right)$Integer array User Workspace
7: $\mathbf{ruser}\left(*\right)$Real (Kind=nag_wp) array User Workspace
gajac is called with the arguments iuser and ruser as supplied to d02tlf. You should use the arrays iuser and ruser to supply information to gajac.
gajac must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tlf is called. Arguments denoted as Input must not be changed by this procedure.
Note: gajac should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tlf. If your code inadvertently does return any NaNs or infinities, d02tlf is likely to produce unexpected results.
6: $\mathbf{gbjac}$Subroutine, supplied by the user. External Procedure
gbjac must evaluate the partial derivatives of ${\overline{g}}_{i}\left(z\left(y\left(b\right)\right)\right)$ with respect to the elements of $z\left(y\left(b\right)\right)=\left({y}_{1}\left(b\right),{y}_{1}^{1}\left(b\right),\dots ,{y}_{1}^{\left({m}_{1}-1\right)}\left(b\right),{y}_{2}\left(b\right),\dots ,{y}_{n}^{\left({m}_{n}-1\right)}\left(b\right)\right)$.
The specification of gbjac is:
Fortran Interface
 Subroutine gbjac ( yb, neq, m, nrbc,
 Integer, Intent (In) :: neq, m(neq), nrbc Integer, Intent (Inout) :: iuser(*) Real (Kind=nag_wp), Intent (In) :: yb(neq,$0:*$) Real (Kind=nag_wp), Intent (Inout) :: dgbdy(nrbc,neq,$0:*$), ruser(*)
 void gbjac (const double yb[], const Integer *neq, const Integer m[], const Integer *nrbc, double dgbdy[], Integer iuser[], double ruser[])
1: $\mathbf{yb}\left({\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{yb}}\left(\mathit{i},\mathit{j}\right)$ contains ${y}_{\mathit{i}}^{\left(\mathit{j}\right)}\left(b\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(\mathit{i}\right)-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(b\right)={y}_{i}\left(b\right)$.
2: $\mathbf{neq}$Integer Input
On entry: the number of differential equations.
3: $\mathbf{m}\left({\mathbf{neq}}\right)$Integer array Input
On entry: ${\mathbf{m}}\left(\mathit{i}\right)$ contains ${m}_{\mathit{i}}$, the order of the $\mathit{i}$th differential equation, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
4: $\mathbf{nrbc}$Integer Input
On entry: the number of boundary conditions at $b$.
5: $\mathbf{dgbdy}\left({\mathbf{nrbc}},{\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Input/Output
On entry: set to zero.
On exit: ${\mathbf{dgbdy}}\left(\mathit{i},\mathit{j},\mathit{k}\right)$ must contain the partial derivative of ${\overline{g}}_{\mathit{i}}\left(z\left(y\left(b\right)\right)\right)$ with respect to ${y}_{\mathit{j}}^{\left(\mathit{k}\right)}\left(b\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nrbc}}$, $\mathit{j}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{k}=0,1,\dots ,{\mathbf{m}}\left(\mathit{j}\right)-1$. Only nonzero partial derivatives need be set.
6: $\mathbf{iuser}\left(*\right)$Integer array User Workspace
7: $\mathbf{ruser}\left(*\right)$Real (Kind=nag_wp) array User Workspace
gbjac is called with the arguments iuser and ruser as supplied to d02tlf. You should use the arrays iuser and ruser to supply information to gbjac.
gbjac must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tlf is called. Arguments denoted as Input must not be changed by this procedure.
Note: gbjac should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tlf. If your code inadvertently does return any NaNs or infinities, d02tlf is likely to produce unexpected results.
7: $\mathbf{guess}$Subroutine, supplied by the user. External Procedure
guess must return initial approximations for the solution components ${y}_{\mathit{i}}^{\left(\mathit{j}\right)}$ and the derivatives ${y}_{\mathit{i}}^{\left({m}_{\mathit{i}}\right)}$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(\mathit{i}\right)-1$. Try to compute each derivative ${y}_{i}^{\left({m}_{i}\right)}$ such that it corresponds to your approximations to ${y}_{i}^{\left(\mathit{j}\right)}$, for $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(i\right)-1$. You should not call ffun to compute ${y}_{i}^{\left({m}_{i}\right)}$.
If d02tlf is being used in conjunction with d02txf as part of a continuation process, guess is not called by d02tlf after the call to d02txf.
The specification of guess is:
Fortran Interface
 Subroutine guess ( x, neq, m, y, dym,
 Integer, Intent (In) :: neq, m(neq) Integer, Intent (Inout) :: iuser(*) Real (Kind=nag_wp), Intent (In) :: x Real (Kind=nag_wp), Intent (Inout) :: y(neq,$0:*$), ruser(*) Real (Kind=nag_wp), Intent (Out) :: dym(neq)
 void guess (const double *x, const Integer *neq, const Integer m[], double y[], double dym[], Integer iuser[], double ruser[])
1: $\mathbf{x}$Real (Kind=nag_wp) Input
On entry: $x$, the independent variable; $x\in \left[a,b\right]$.
2: $\mathbf{neq}$Integer Input
On entry: the number of differential equations.
3: $\mathbf{m}\left({\mathbf{neq}}\right)$Integer array Input
On entry: ${\mathbf{m}}\left(\mathit{i}\right)$ contains ${m}_{\mathit{i}}$, the order of the $\mathit{i}$th differential equation, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
4: $\mathbf{y}\left({\mathbf{neq}},0:*\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{y}}\left(\mathit{i},\mathit{j}\right)$ must contain ${y}_{\mathit{i}}^{\left(\mathit{j}\right)}\left(x\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$ and $\mathit{j}=0,1,\dots ,{\mathbf{m}}\left(\mathit{i}\right)-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(x\right)={y}_{i}\left(x\right)$.
5: $\mathbf{dym}\left({\mathbf{neq}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{dym}}\left(\mathit{i}\right)$ must contain ${y}_{\mathit{i}}^{\left({m}_{\mathit{i}}\right)}\left(x\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
6: $\mathbf{iuser}\left(*\right)$Integer array User Workspace
7: $\mathbf{ruser}\left(*\right)$Real (Kind=nag_wp) array User Workspace
guess is called with the arguments iuser and ruser as supplied to d02tlf. You should use the arrays iuser and ruser to supply information to guess.
guess must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tlf is called. Arguments denoted as Input must not be changed by this procedure.
Note: guess should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tlf. If your code inadvertently does return any NaNs or infinities, d02tlf is likely to produce unexpected results.
8: $\mathbf{rcomm}\left(*\right)$Real (Kind=nag_wp) array Communication 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 d02tvf.
On entry: this must be the same array as supplied to d02tvf and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
9: $\mathbf{icomm}\left(*\right)$Integer array Communication 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 d02tvf.
On entry: this must be the same array as supplied to d02tvf and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated routines.
10: $\mathbf{iuser}\left(*\right)$Integer array User Workspace
11: $\mathbf{ruser}\left(*\right)$Real (Kind=nag_wp) array User Workspace
iuser and ruser are not used by d02tlf, but are passed directly to ffun, fjac, gafun, gbfun, gajac, gbjac and guess and may be used to pass information to these routines.
12: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $-1$ is recommended since useful values can be provided in some output arguments even when ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit. When the value $-\mathbf{1}$ 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).

## 6Error 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:
Note: in some cases d02tlf may return useful information.
${\mathbf{ifail}}=1$
Either the setup routine has not been called or the communication arrays have become corrupted. No solution will be computed.
${\mathbf{ifail}}=2$
Numerical singularity has been detected in the Jacobian used in the Newton iteration.
No results have been generated. Check the coding of the routines for calculating the Jacobians of system and boundary conditions.
${\mathbf{ifail}}=3$
All Newton iterations that have been attempted have failed to converge.
No results have been generated. Check the coding of the routines for calculating the Jacobians of system and boundary conditions.
Try to provide a better initial solution approximation.
${\mathbf{ifail}}=4$
A Newton iteration has failed to converge. The computation has not succeeded but results have been returned for an intermediate mesh on which convergence was achieved.
These results should be treated with extreme caution.
${\mathbf{ifail}}=5$
The expected number of sub-intervals required to continue the computation exceeds the maximum specified: $⟨\mathit{\text{value}}⟩$.
Results have been generated which may be useful.
Try increasing this number or relaxing the error requirements.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

The accuracy of the solution is determined by the argument tols in the prior call to d02tvf (see Sections 3 and 9 in d02tvf for details and advice). Note that error control is applied only to solution components (variables) and not to any derivatives of the solution. An estimate of the maximum error in the computed solution is available by calling d02tzf.

## 8Parallelism and Performance

d02tlf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
d02tlf 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 implementation-specific information.

If d02tlf returns with ${\mathbf{ifail}}={\mathbf{2}}$, ${\mathbf{3}}$, ${\mathbf{4}}$ or ${\mathbf{5}}$ and the call to d02tlf was a part of some continuation procedure for which successful calls to d02tlf have already been made, then it is possible that the adjustment(s) to the continuation parameter(s) between calls to d02tlf is (are) too large for the problem under consideration. More conservative adjustment(s) to the continuation parameter(s) might be appropriate.

## 10Example

The following example is used to illustrate the treatment of a high-order system, control of the error in a derivative of a component of the original system, and the use of continuation. See also d02tvf, d02txf, d02tyf and d02tzf, for the illustration of other facilities.
Consider the steady flow of an incompressible viscous fluid between two infinite coaxial rotating discs. See Ascher et al. (1979) and the references therein. The governing equations are
 $1R f′′′′ + ff′′′ + gg′ = 0 1R g′′ + fg′ - f′g = 0$
subject to the boundary conditions
 $f(0)=f′(0)= 0, g(0)=Ω0, f(1)=f′(1)= 0, g(1)=Ω1,$
where $R$ is the Reynolds number and ${\Omega }_{0},{\Omega }_{1}$ are the angular velocities of the disks.
We consider the case of counter-rotation and a symmetric solution, that is ${\Omega }_{0}=1,{\Omega }_{1}=-1$. This problem is more difficult to solve, the larger the value of $R$. For illustration, we use simple continuation to compute the solution for three different values of $R$ ($={10}^{6},{10}^{8},{10}^{10}$). However, this problem can be addressed directly for the largest value of $R$ considered here. Instead of the values suggested in Section 5 in d02txf for nmesh, ipmesh and mesh in the call to d02txf prior to a continuation call, we use every point of the final mesh for the solution of the first value of $R$, that is we must modify the contents of ipmesh. For illustrative purposes we wish to control the computed error in ${f}^{\prime }$ and so recast the equations as
 $y1′ = y2 y2′′′ = -R(y1y2′′+y3y3′) y3′′ = R(y2y3-y1y3′)$
subject to the boundary conditions
 $y1(0)=y2(0)= 0, y3(0)=Ω, y1(1)=y2(1)= 0, y3(1)=-Ω, Ω=1.$
For the symmetric boundary conditions considered, there exists an odd solution about $x=0.5$. Hence, to satisfy the boundary conditions, we use the following initial approximations to the solution in guess:
 $y1(x) = -x2(x-12) (x-1) 2 y2(x) = -x(x-1)(5⁢x2-5x+1) y3(x) = −8Ω (x-12) 3.$

### 10.1Program Text

Program Text (d02tlfe.f90)

### 10.2Program Data

Program Data (d02tlfe.d)

### 10.3Program Results

Program Results (d02tlfe.r)