D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD02UEF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D02UEF finds the solution of a linear constant coefficient boundary value problem by using the Chebyshev integration formulation on a Chebyshev Gauss–Lobatto grid.

## 2  Specification

 SUBROUTINE D02UEF ( N, A, B, M, C, BMAT, Y, BVEC, F, UC, RESID, IFAIL)
 INTEGER N, M, IFAIL REAL (KIND=nag_wp) A, B, C(N+1), BMAT(M,M+1), Y(M), BVEC(M), F(M+1), UC(N+1,M+1), RESID

## 3  Description

D02UEF solves the constant linear coefficient ordinary differential problem
 $∑ j=0 m fj+1 dju dxj = fx , x ∈ a,b$
subject to a set of $m$ linear constraints at points ${y}_{\mathit{i}}\in \left[a,b\right]$, for $\mathit{i}=1,2,\dots ,m$:
 $∑ j=0 m B i,j+1 dju dxj x=yi = βi ,$
where $1\le m\le 4$, $B$ is an $m×\left(m+1\right)$ matrix of constant coefficients and ${\beta }_{i}$ are constants. The points ${y}_{i}$ are usually either $a$ or $b$.
The function $f\left(x\right)$ is supplied as an array of Chebyshev coefficients ${c}_{j}$, $j=0,1,\dots ,n$ for the function discretized on $n+1$ Chebyshev Gauss–Lobatto points (as returned by D02UCF); the coefficients are normally obtained by a previous call to D02UAF. The solution and its derivatives (up to order $m$) are returned, in the form of their Chebyshev series representation, as arrays of Chebyshev coefficients; subsequent calls to D02UBF will return the corresponding function and derivative values at the Chebyshev Gauss–Lobatto discretization points on $\left[a,b\right]$. Function and derivative values can be obtained on any uniform grid over the same range $\left[a,b\right]$ by calling the interpolation routine D02UWF.

## 4  References

Clenshaw C W (1957) The numerical solution of linear differential equations in Chebyshev series Proc. Camb. Phil. Soc. 53 134–149
Coutsias E A, Hagstrom T and Torres D (1996) An efficient spectral method for ordinary differential equations with rational function coefficients Mathematics of Computation 65(214) 611–635
Greengard L (1991) Spectral integration and two-point boundary value problems SIAM J. Numer. Anal. 28(4) 1071–80
Lundbladh A, Hennigson D S and Johannson A V (1992) An efficient spectral integration method for the solution of the Navier–Stokes equations Technical report FFA–TN 1992–28 Aeronautical Research Institute of Sweden
Muite B K (2010) A numerical comparison of Chebyshev methods for solving fourth-order semilinear initial boundary value problems Journal of Computational and Applied Mathematics 234(2) 317–342

## 5  Parameters

1:     N – INTEGERInput
On entry: $n$, where the number of grid points is $n+1$.
Constraint: ${\mathbf{N}}\ge 8$ and N is even.
2:     A – REAL (KIND=nag_wp)Input
On entry: $a$, the lower bound of domain $\left[a,b\right]$.
Constraint: ${\mathbf{A}}<{\mathbf{B}}$.
3:     B – REAL (KIND=nag_wp)Input
On entry: $b$, the upper bound of domain $\left[a,b\right]$.
Constraint: ${\mathbf{B}}>{\mathbf{A}}$.
4:     M – INTEGERInput
On entry: the order, $m$, of the boundary value problem to be solved.
Constraint: $1\le {\mathbf{M}}\le 4$.
5:     C(${\mathbf{N}}+1$) – REAL (KIND=nag_wp) arrayInput
On entry: the Chebyshev coefficients ${c}_{j}$, $j=0,1,\dots ,n$, for the right hand side of the boundary value problem. Usually these are obtained by a previous call of D02UAF.
6:     BMAT(M,${\mathbf{M}}+1$) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{BMAT}}\left(\mathit{i},\mathit{j}+1\right)$ must contain the coefficients ${B}_{\mathit{i},\mathit{j}+1}$, for $\mathit{i}=1,2,\dots ,m$ and $\mathit{j}=0,1,\dots ,m$, in the problem formulation of Section 3.
On exit: the coefficients have been scaled to form an equivalent problem defined on the domain $\left[-1,1\right]$.
7:     Y(M) – REAL (KIND=nag_wp) arrayInput
On entry: the points, ${y}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,m$, where the boundary conditions are discretized.
8:     BVEC(M) – REAL (KIND=nag_wp) arrayInput
On entry: the values, ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,m$, in the formulation of the boundary conditions given in Section 3.
9:     F(${\mathbf{M}}+1$) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the coefficients, ${f}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,m+1$, in the formulation of the linear boundary value problem given in Section 3. The highest order term, ${\mathbf{F}}\left({\mathbf{M}}+1\right)$, needs to be nonzero to have a well posed problem.
On exit: the coefficients have been scaled to form an equivalent problem defined on the domain $\left[-1,1\right]$.
10:   UC(${\mathbf{N}}+1$,${\mathbf{M}}+1$) – REAL (KIND=nag_wp) arrayOutput
On exit: the Chebyshev coefficients in the Chebyshev series representations of the solution and derivatives of the solution to the boundary value problem. The $n+1$ elements ${\mathbf{UC}}\left(1:{\mathbf{N}}+1,1\right)$ contain the coefficients representing the solution $U\left({x}_{\mathit{i}}\right)$, for $\mathit{i}=0,1,\dots ,n$. ${\mathbf{UC}}\left(1:{\mathbf{N}}+1,\mathit{j}+1\right)$ contains the coefficients representing the $\mathit{j}$th derivative of $U$, for $\mathit{j}=1,2,\dots ,m$.
11:   RESID – REAL (KIND=nag_wp)Output
On exit: the maximum residual resulting from substituting the solution vectors returned in UC into both linear equations of Section 3 representing the linear boundary value problem and associated boundary conditions. That is
 $max max i=1,m ∑ j=0 m B i,j+1 dju dxj x=yi - βi , max i=1, n+1 ∑ j=0 m f j+1 dju dxj x=xi - fx .$
12:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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}}={\mathbf{0}}$ or $-{\mathbf{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$
On entry, ${\mathbf{N}}<8$ or N is odd.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{A}}\ge {\mathbf{B}}$.
${\mathbf{IFAIL}}=3$
 On entry, ${\mathbf{F}}\left({\mathbf{M}}+1\right)=0$.
${\mathbf{IFAIL}}=6$
 On entry, ${\mathbf{M}}\ne 1$, $2$, $3$ or $4$.
${\mathbf{IFAIL}}=7$
Internal error unpacking a matrix, seek expert advice.
${\mathbf{IFAIL}}=8$
Singular system when factoring a matrix, check your system is well posed, contact NAG.
${\mathbf{IFAIL}}=9$
Warning, iterative refinement failed to converge within the maximum number of iterations (50).
${\mathbf{IFAIL}}=10$
Warning, iterative refinement converged but did not achieve a residual close to machine precision.
${\mathbf{IFAIL}}=-999$
Internal memory allocation failed.

## 7  Accuracy

The accuracy should be close to machine precision for well conditioned boundary value problems.

The number of operations is of the order $n\mathrm{log}n$ and the memory requirements are $\mathit{O}\left(n\right)$; thus the computation remains efficient and practical for very fine discretizations (very large values of $n$). Collocation methods will be faster for small problems, but the method of D02UEF should be faster for larger discretizations.

## 9  Example

This example solves the third-order problem $4{U}_{xxx}+3{U}_{xx}+2{U}_{x}+U=2\mathrm{sin}x-2\mathrm{cos}x$ on $\left[-\pi /2,\pi /2\right]$ subject to the boundary conditions $U\left[-\pi /2\right]=0$, $3{U}_{xx}\left[-\pi /2\right]+2{U}_{x}\left[-\pi /2\right]+U\left[-\pi /2\right]=2$, and $3{U}_{xx}\left[\pi /2\right]+2{U}_{x}\left[\pi /2\right]+U\left[\pi /2\right]=-2$ using the Chebyshev integration formulation on a Chebyshev Gauss–Lobatto grid of order $16$.

### 9.1  Program Text

Program Text (d02uefe.f90)

### 9.2  Program Data

Program Data (d02uefe.d)

### 9.3  Program Results

Program Results (d02uefe.r)