d02 Chapter Contents
d02 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_ode_bvp_coll_nlin_interp (d02tyc)

## 1  Purpose

nag_ode_bvp_coll_nlin_interp (d02tyc) interpolates on the solution of a general two-point boundary value problem computed by nag_ode_bvp_coll_nlin_solve (d02tlc).

## 2  Specification

 #include #include
 void nag_ode_bvp_coll_nlin_interp (double x, double y[], Integer neq, Integer mmax, double rcomm[], const Integer icomm[], NagError *fail)

## 3  Description

nag_ode_bvp_coll_nlin_interp (d02tyc) and its associated functions (nag_ode_bvp_coll_nlin_solve (d02tlc)nag_ode_bvp_coll_nlin_setup (d02tvc)nag_ode_bvp_coll_nlin_contin (d02txc) 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. 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]$ using interpolation.
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).

## 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 Two-point Boundary-value Problems Dover, New York

## 5  Arguments

1:     xdoubleInput
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 nag_ode_bvp_coll_nlin_setup (d02tvc).
2:     y[${\mathbf{neq}}×{\mathbf{mmax}}$]doubleOutput
Note: 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)$ 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:     neqIntegerInput
On entry: the number of differential equations.
Constraint: ${\mathbf{neq}}$ must be the same value as supplied to nag_ode_bvp_coll_nlin_setup (d02tvc).
4:     mmaxIntegerInput
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 nag_ode_bvp_coll_nlin_setup (d02tvc).
5:     rcomm[$\mathit{dim}$]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_solve (d02tlc).
On entry: this must be the same array as supplied to nag_ode_bvp_coll_nlin_solve (d02tlc) and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated functions.
6:     icomm[$\mathit{dim}$]const 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_solve (d02tlc).
On entry: this must be the same array as supplied to nag_ode_bvp_coll_nlin_solve (d02tlc) and must remain unchanged between calls.
On exit: contains information about the solution for use on subsequent calls to associated functions.
7:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_CONVERGENCE_SOL
The solver function did not produce any results suitable for interpolation.
NE_INT_2
On entry, ${\mathbf{mmax}}=⟨\mathit{\text{value}}⟩$ and $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mmax}}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}}\left[i\right]\right)$.
NE_INT_CHANGED
On entry, ${\mathbf{neq}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{neq}}=⟨\mathit{\text{value}}⟩$ in nag_ode_bvp_coll_nlin_setup (d02tvc).
Constraint: ${\mathbf{neq}}={\mathbf{neq}}$ in nag_ode_bvp_coll_nlin_setup (d02tvc).
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.
NE_MISSING_CALL
The solver function does not appear to have been called.
NE_REAL
On entry, ${\mathbf{x}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{x}}\le ⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{x}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{x}}\ge ⟨\mathit{\text{value}}⟩$.
NW_NOT_CONVERGED
The solver function did not converge to a suitable solution.
A converged intermediate solution has been used.
Interpolated values should be treated with caution.
NW_TOO_MUCH_ACC_REQUESTED
The solver function did not satisfy the error requirements.
Interpolated values should be treated with caution.

## 7  Accuracy

If nag_ode_bvp_coll_nlin_interp (d02tyc) returns the value ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, the computed values of the solution components ${y}_{i}$ should be of similar accuracy to that specified by the argument tols of nag_ode_bvp_coll_nlin_setup (d02tvc). 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 nag_ode_bvp_coll_nlin_interp (d02tyc) are computed via differentiation of the piecewise polynomial approximation to ${y}_{i}$. See also Section 9.

## 8  Parallelism and Performance

nag_ode_bvp_coll_nlin_interp (d02tyc) is not threaded by NAG in any implementation.
nag_ode_bvp_coll_nlin_interp (d02tyc) 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.

If nag_ode_bvp_coll_nlin_interp (d02tyc) returns the value fail.code $={\mathbf{NW_NOT_CONVERGED}}$, then the accuracy of the interpolated values may be proportional to the quantity ermx as returned by nag_ode_bvp_coll_nlin_diag (d02tzc).
If nag_ode_bvp_coll_nlin_solve (d02tlc) returned a value for fail.code other than ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, then nothing can be said regarding either the quality or accuracy of the values computed by nag_ode_bvp_coll_nlin_interp (d02tyc).

## 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 nag_ode_bvp_coll_nlin_solve (d02tlc)nag_ode_bvp_coll_nlin_setup (d02tvc)nag_ode_bvp_coll_nlin_contin (d02txc) and nag_ode_bvp_coll_nlin_diag (d02tzc), 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
 $y′′=x-1/2y3/2$
with boundary conditions
 $y0= 1, ya= 0, a> 0.$
The coefficient ${x}^{-1/2}$ implies a singularity at the left-hand boundary $x=0$.
We use the initial approximation $y\left(x\right)=1-x/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 nag_ode_bvp_coll_nlin_solve (d02tlc)) 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.

### 10.1  Program Text

Program Text (d02tyce.c)

### 10.2  Program Data

Program Data (d02tyce.d)

### 10.3  Program Results

Program Results (d02tyce.r)