nag_ode_bvp_coll_nlin_solve (d02tlc) (PDF version)
d02 Chapter Contents
d02 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_ode_bvp_coll_nlin_solve (d02tlc)

## 1  Purpose

nag_ode_bvp_coll_nlin_solve (d02tlc) solves a general two-point boundary value problem for a nonlinear mixed order system of ordinary differential equations.

## 2  Specification

 #include #include
void  nag_ode_bvp_coll_nlin_solve (
 void (*ffun)(double x, const double y[], Integer neq, const Integer m[], double f[], Nag_Comm *comm),
 void (*fjac)(double x, const double y[], Integer neq, const Integer m[], double dfdy[], Nag_Comm *comm),
 void (*gafun)(const double ya[], Integer neq, const Integer m[], Integer nlbc, double ga[], Nag_Comm *comm),
 void (*gbfun)(const double yb[], Integer neq, const Integer m[], Integer nrbc, double gb[], Nag_Comm *comm),
 void (*gajac)(const double ya[], Integer neq, const Integer m[], Integer nlbc, double dgady[], Nag_Comm *comm),
 void (*gbjac)(const double yb[], Integer neq, const Integer m[], Integer nrbc, double dgbdy[], Nag_Comm *comm),
 void (*guess)(double x, Integer neq, const Integer m[], double y[], double dym[], Nag_Comm *comm),
double rcomm[], Integer icomm[], Nag_Comm *comm, NagError *fail)

## 3  Description

nag_ode_bvp_coll_nlin_solve (d02tlc) and its associated functions (nag_ode_bvp_coll_nlin_setup (d02tvc), nag_ode_bvp_coll_nlin_contin (d02txc), nag_ode_bvp_coll_nlin_interp (d02tyc) and nag_ode_bvp_coll_nlin_diag (d02tzc)) 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, nag_ode_bvp_coll_nlin_setup (d02tvc) 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 nag_ode_bvp_coll_nlin_setup (d02tvc).) Then, nag_ode_bvp_coll_nlin_solve (d02tlc) can be used to solve the boundary value problem. After successful computation, nag_ode_bvp_coll_nlin_diag (d02tzc) can be used to ascertain details about the final mesh and other details of the solution procedure, and nag_ode_bvp_coll_nlin_interp (d02tyc) can be used to compute the approximate solution anywhere on the interval $\left[a,b\right]$.
A description of the numerical technique used in nag_ode_bvp_coll_nlin_solve (d02tlc) is given in Section 3 in nag_ode_bvp_coll_nlin_setup (d02tvc).
nag_ode_bvp_coll_nlin_solve (d02tlc) 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. nag_ode_bvp_coll_nlin_contin (d02txc) should be used in between calls to nag_ode_bvp_coll_nlin_solve (d02tlc) in this context.
See Section 9 in nag_ode_bvp_coll_nlin_setup (d02tvc) for details of how to solve boundary value problems of a more general nature.
The functions 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

## 5  Arguments

1:    $\mathbf{ffun}$function, supplied by the userExternal Function
ffun must evaluate the functions ${f}_{i}$ for given values $x,z\left(y\left(x\right)\right)$.
The specification of ffun is:
 void ffun (double x, const double y[], Integer neq, const Integer m[], double f[], Nag_Comm *comm)
1:    $\mathbf{x}$doubleInput
On entry: $x$, the independent variable.
2:    $\mathbf{y}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array y is ${\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{Y}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{y}}\left[j×{\mathbf{neq}}+i-1\right]$.
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}-1\right]-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(x\right)={y}_{i}\left(x\right)$.
3:    $\mathbf{neq}$IntegerInput
On entry: the number of differential equations.
4:    $\mathbf{m}\left[{\mathbf{neq}}\right]$const IntegerInput
On entry: ${\mathbf{m}}\left[\mathit{i}-1\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]$doubleOutput
On exit: ${\mathbf{f}}\left[\mathit{i}-1\right]$ must contain ${f}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
6:    $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to ffun.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_ode_bvp_coll_nlin_solve (d02tlc) you may allocate memory and initialize these pointers with various quantities for use by ffun when called from nag_ode_bvp_coll_nlin_solve (d02tlc) (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
2:    $\mathbf{fjac}$function, supplied by the userExternal Function
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:
 void fjac (double x, const double y[], Integer neq, const Integer m[], double dfdy[], Nag_Comm *comm)
1:    $\mathbf{x}$doubleInput
On entry: $x$, the independent variable.
2:    $\mathbf{y}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array y is ${\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{Y}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{y}}\left[j×{\mathbf{neq}}+i-1\right]$.
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}-1\right]-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(x\right)={y}_{i}\left(x\right)$.
3:    $\mathbf{neq}$IntegerInput
On entry: the number of differential equations.
4:    $\mathbf{m}\left[{\mathbf{neq}}\right]$const IntegerInput
On entry: ${\mathbf{m}}\left[\mathit{i}-1\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[\mathit{dim}\right]$doubleInput/Output
Note: the dimension, dim, of the array dfdy is ${\mathbf{neq}}×{\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{DFDY}}\left(i,j,k\right)$ appears in this document, it refers to the array element ${\mathbf{dfdy}}\left[k×{\mathbf{neq}}×{\mathbf{neq}}+\left(j-1\right)×{\mathbf{neq}}+i-1\right]$.
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}-1\right]-1$. Only nonzero partial derivatives need be set.
6:    $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to fjac.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_ode_bvp_coll_nlin_solve (d02tlc) you may allocate memory and initialize these pointers with various quantities for use by fjac when called from nag_ode_bvp_coll_nlin_solve (d02tlc) (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
3:    $\mathbf{gafun}$function, supplied by the userExternal Function
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:
 void gafun (const double ya[], Integer neq, const Integer m[], Integer nlbc, double ga[], Nag_Comm *comm)
1:    $\mathbf{ya}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array ya is ${\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{YA}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{ya}}\left[j×{\mathbf{neq}}+i-1\right]$.
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}-1\right]-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(a\right)={y}_{i}\left(a\right)$.
2:    $\mathbf{neq}$IntegerInput
On entry: the number of differential equations.
3:    $\mathbf{m}\left[{\mathbf{neq}}\right]$const IntegerInput
On entry: ${\mathbf{m}}\left[\mathit{i}-1\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}$IntegerInput
On entry: the number of boundary conditions at $a$.
5:    $\mathbf{ga}\left[{\mathbf{nlbc}}\right]$doubleOutput
On exit: ${\mathbf{ga}}\left[\mathit{i}-1\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{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to gafun.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_ode_bvp_coll_nlin_solve (d02tlc) you may allocate memory and initialize these pointers with various quantities for use by gafun when called from nag_ode_bvp_coll_nlin_solve (d02tlc) (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
4:    $\mathbf{gbfun}$function, supplied by the userExternal Function
gbfun must evaluate the boundary conditions at the right-hand end of the range, that is functions ${\stackrel{-}{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:
 void gbfun (const double yb[], Integer neq, const Integer m[], Integer nrbc, double gb[], Nag_Comm *comm)
1:    $\mathbf{yb}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array yb is ${\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{YB}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{yb}}\left[j×{\mathbf{neq}}+i-1\right]$.
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}-1\right]-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(b\right)={y}_{i}\left(b\right)$.
2:    $\mathbf{neq}$IntegerInput
On entry: the number of differential equations.
3:    $\mathbf{m}\left[{\mathbf{neq}}\right]$const IntegerInput
On entry: ${\mathbf{m}}\left[\mathit{i}-1\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}$IntegerInput
On entry: the number of boundary conditions at $b$.
5:    $\mathbf{gb}\left[{\mathbf{nrbc}}\right]$doubleOutput
On exit: ${\mathbf{gb}}\left[\mathit{i}-1\right]$ must contain ${\stackrel{-}{g}}_{\mathit{i}}\left(z\left(y\left(b\right)\right)\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nrbc}}$.
6:    $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to gbfun.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_ode_bvp_coll_nlin_solve (d02tlc) you may allocate memory and initialize these pointers with various quantities for use by gbfun when called from nag_ode_bvp_coll_nlin_solve (d02tlc) (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
5:    $\mathbf{gajac}$function, supplied by the userExternal Function
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:
 void gajac (const double ya[], Integer neq, const Integer m[], Integer nlbc, double dgady[], Nag_Comm *comm)
1:    $\mathbf{ya}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array ya is ${\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{YA}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{ya}}\left[j×{\mathbf{neq}}+i-1\right]$.
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}-1\right]-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(a\right)={y}_{i}\left(a\right)$.
2:    $\mathbf{neq}$IntegerInput
On entry: the number of differential equations.
3:    $\mathbf{m}\left[{\mathbf{neq}}\right]$const IntegerInput
On entry: ${\mathbf{m}}\left[\mathit{i}-1\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}$IntegerInput
On entry: the number of boundary conditions at $a$.
5:    $\mathbf{dgady}\left[\mathit{dim}\right]$doubleInput/Output
Note: the dimension, dim, of the array dgady is ${\mathbf{nlbc}}×{\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{DGADY}}\left(i,j,k\right)$ appears in this document, it refers to the array element ${\mathbf{dgady}}\left[k×{\mathbf{nlbc}}×{\mathbf{neq}}+\left(j-1\right)×{\mathbf{nlbc}}+i-1\right]$.
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}-1\right]-1$. Only nonzero partial derivatives need be set.
6:    $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to gajac.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_ode_bvp_coll_nlin_solve (d02tlc) you may allocate memory and initialize these pointers with various quantities for use by gajac when called from nag_ode_bvp_coll_nlin_solve (d02tlc) (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
6:    $\mathbf{gbjac}$function, supplied by the userExternal Function
gbjac must evaluate the partial derivatives of ${\stackrel{-}{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:
 void gbjac (const double yb[], Integer neq, const Integer m[], Integer nrbc, double dgbdy[], Nag_Comm *comm)
1:    $\mathbf{yb}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array yb is ${\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{YB}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{yb}}\left[j×{\mathbf{neq}}+i-1\right]$.
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}-1\right]-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(b\right)={y}_{i}\left(b\right)$.
2:    $\mathbf{neq}$IntegerInput
On entry: the number of differential equations.
3:    $\mathbf{m}\left[{\mathbf{neq}}\right]$const IntegerInput
On entry: ${\mathbf{m}}\left[\mathit{i}-1\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}$IntegerInput
On entry: the number of boundary conditions at $b$.
5:    $\mathbf{dgbdy}\left[\mathit{dim}\right]$doubleInput/Output
Note: the dimension, dim, of the array dgbdy is ${\mathbf{nrbc}}×{\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{DGBDY}}\left(i,j,k\right)$ appears in this document, it refers to the array element ${\mathbf{dgbdy}}\left[\left(k-1\right)×{\mathbf{nrbc}}×{\mathbf{neq}}+\left(j-1\right)×{\mathbf{nrbc}}+i-1\right]$.
On entry: set to zero.
On exit: ${\mathbf{DGBDY}}\left(\mathit{i},\mathit{j},\mathit{k}\right)$ must contain the partial derivative of ${\stackrel{-}{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}-1\right]-1$. Only nonzero partial derivatives need be set.
6:    $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to gbjac.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_ode_bvp_coll_nlin_solve (d02tlc) you may allocate memory and initialize these pointers with various quantities for use by gbjac when called from nag_ode_bvp_coll_nlin_solve (d02tlc) (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
7:    $\mathbf{guess}$function, supplied by the userExternal Function
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}-1\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-1\right]-1$. You should not call ffun to compute ${y}_{i}^{\left({m}_{i}\right)}$.
If nag_ode_bvp_coll_nlin_solve (d02tlc) is being used in conjunction with nag_ode_bvp_coll_nlin_contin (d02txc) as part of a continuation process, then guess is not called by nag_ode_bvp_coll_nlin_solve (d02tlc) after the call to nag_ode_bvp_coll_nlin_contin (d02txc).
The specification of guess is:
 void guess (double x, Integer neq, const Integer m[], double y[], double dym[], Nag_Comm *comm)
1:    $\mathbf{x}$doubleInput
On entry: $x$, the independent variable; $x\in \left[a,b\right]$.
2:    $\mathbf{neq}$IntegerInput
On entry: the number of differential equations.
3:    $\mathbf{m}\left[{\mathbf{neq}}\right]$const IntegerInput
On entry: ${\mathbf{m}}\left[\mathit{i}-1\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[\mathit{dim}\right]$doubleOutput
Note: the dimension, dim, of the array y is ${\mathbf{neq}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
Where ${\mathbf{Y}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{y}}\left[j×{\mathbf{neq}}+i-1\right]$.
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}-1\right]-1$.
Note:  ${y}_{i}^{\left(0\right)}\left(x\right)={y}_{i}\left(x\right)$.
5:    $\mathbf{dym}\left[{\mathbf{neq}}\right]$doubleOutput
On exit: ${\mathbf{dym}}\left[\mathit{i}-1\right]$ must contain ${y}_{\mathit{i}}^{\left({m}_{\mathit{i}}\right)}\left(x\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{neq}}$.
6:    $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to guess.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_ode_bvp_coll_nlin_solve (d02tlc) you may allocate memory and initialize these pointers with various quantities for use by guess when called from nag_ode_bvp_coll_nlin_solve (d02tlc) (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
8:    $\mathbf{rcomm}\left[\mathit{dim}\right]$doubleCommunication Array
Note: the dimension, $\mathit{dim}$, 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 nag_ode_bvp_coll_nlin_setup (d02tvc).
On entry: this must be the same array as supplied to nag_ode_bvp_coll_nlin_setup (d02tvc) and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated functions.
9:    $\mathbf{icomm}\left[\mathit{dim}\right]$IntegerCommunication Array
Note: the dimension, $\mathit{dim}$, 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 nag_ode_bvp_coll_nlin_setup (d02tvc).
On entry: this must be the same array as supplied to nag_ode_bvp_coll_nlin_setup (d02tvc) and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated functions.
10:  $\mathbf{comm}$Nag_Comm *
The NAG communication argument (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
11:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_CONVERGENCE_SOL
All Newton iterations that have been attempted have failed to converge.
No results have been generated. Check the coding of the functions for calculating the Jacobians of system and boundary conditions.
Try to provide a better initial solution approximation.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_MISSING_CALL
Either the setup function has not been called or the communication arrays have become corrupted. No solution will be computed.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_SING_JAC
Numerical singularity has been detected in the Jacobian used in the Newton iteration.
No results have been generated. Check the coding of the functions for calculating the Jacobians of system and boundary conditions.
NW_MAX_SUBINT
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.
NW_NOT_CONVERGED
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.

## 7  Accuracy

The accuracy of the solution is determined by the argument tols in the prior call to nag_ode_bvp_coll_nlin_setup (d02tvc) (see Sections 3 and 9 in nag_ode_bvp_coll_nlin_setup (d02tvc) 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 nag_ode_bvp_coll_nlin_diag (d02tzc).

## 8  Parallelism and Performance

nag_ode_bvp_coll_nlin_solve (d02tlc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_ode_bvp_coll_nlin_solve (d02tlc) 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9  Further Comments

If nag_ode_bvp_coll_nlin_solve (d02tlc) returns with ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_CONVERGENCE_SOL, NE_SING_JAC, NW_MAX_SUBINT or NW_NOT_CONVERGED and the call to nag_ode_bvp_coll_nlin_solve (d02tlc) was a part of some continuation procedure for which successful calls to nag_ode_bvp_coll_nlin_solve (d02tlc) have already been made, then it is possible that the adjustment(s) to the continuation parameter(s) between calls to nag_ode_bvp_coll_nlin_solve (d02tlc) is (are) too large for the problem under consideration. More conservative adjustment(s) to the continuation parameter(s) might be appropriate.

## 10  Example

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 nag_ode_bvp_coll_nlin_setup (d02tvc), nag_ode_bvp_coll_nlin_contin (d02txc), nag_ode_bvp_coll_nlin_interp (d02tyc) and nag_ode_bvp_coll_nlin_diag (d02tzc), 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
 $f0=f′0= 0, g0=Ω0, f1=f′1= 0, g1=Ω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 nag_ode_bvp_coll_nlin_contin (d02txc) for nmesh, ipmesh and mesh in the call to nag_ode_bvp_coll_nlin_contin (d02txc) 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′′′ = -Ry1y2′′+y3y3′ y3′′ = Ry2y3-y1y3′$
subject to the boundary conditions
 $y10=y20= 0, y30=Ω, y11=y21= 0, y31=-Ω, Ω=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:
 $y1x = -x2x-12 x-1 2 y2x = -xx-15⁢x2-5x+1 y3x = -8Ω x-12 3.$

### 10.1  Program Text

Program Text (d02tlce.c)

### 10.2  Program Data

Program Data (d02tlce.d)

### 10.3  Program Results

Program Results (d02tlce.r)