NAG Library Routine Document
e02gcf (glin_linf)
1
Purpose
e02gcf calculates an ${l}_{\infty}$ solution to an overdetermined system of linear equations.
2
Specification
Fortran Interface
Subroutine e02gcf ( 
m, n, sda, lda, a, b, tol, relerr, x, resmax, irank, iter, ifail) 
Integer, Intent (In)  ::  m, n, sda, lda  Integer, Intent (Inout)  ::  ifail  Integer, Intent (Out)  ::  irank, iter  Real (Kind=nag_wp), Intent (In)  ::  tol  Real (Kind=nag_wp), Intent (Inout)  ::  a(lda,sda), b(m), relerr  Real (Kind=nag_wp), Intent (Out)  ::  x(n), resmax 

C Header Interface
#include <nagmk26.h>
void 
e02gcf_ (const Integer *m, const Integer *n, const Integer *sda, const Integer *lda, double a[], double b[], const double *tol, double *relerr, double x[], double *resmax, Integer *irank, Integer *iter, Integer *ifail) 

3
Description
Given a matrix
$A$ with
$m$ rows and
$n$ columns
$\left(m\ge n\right)$ and a vector
$b$ with
$m$ elements, the routine calculates an
${l}_{\infty}$ solution to the overdetermined system of equations
That is to say, it calculates a vector
$x$, with
$n$ elements, which minimizes the
${l}_{\infty}$ norm of the residuals (the absolutely largest residual)
where the residuals
${r}_{i}$ are given by
Here ${a}_{ij}$ is the element in row $i$ and column $j$ of $A$, ${b}_{i}$ is the $i$th element of $b$ and ${x}_{j}$ the $j$th element of $x$. The matrix $A$ need not be of full rank. The solution is not unique in this case, and may not be unique even if $A$ is of full rank.
Alternatively, in applications where a complete minimization of the
${l}_{\infty}$ norm is not necessary, you may obtain an approximate solution, usually in shorter time, by giving an appropriate value to the argument
relerr.
Typically in applications to data fitting, data consisting of
$m$ points with coordinates
$\left({t}_{i},{y}_{i}\right)$ is to be approximated in the
${l}_{\infty}$ norm by a linear combination of known functions
${\varphi}_{j}\left(t\right)$,
This is equivalent to finding an
${l}_{\infty}$ solution to the overdetermined system of equations
Thus if, for each value of $i$ and $j$ the element ${a}_{ij}$ of the matrix $A$ above is set equal to the value of ${\varphi}_{j}\left({t}_{i}\right)$ and ${b}_{i}$ is set equal to ${y}_{i}$, the solution vector $x$ will contain the required values of the ${\alpha}_{j}$. Note that the independent variable $t$ above can, instead, be a vector of several independent variables (this includes the case where each ${\varphi}_{i}$ is a function of a different variable, or set of variables).
The algorithm is a modification of the simplex method of linear programming applied to the dual formation of the
${l}_{\infty}$ problem (see
Barrodale and Phillips (1974) and
Barrodale and Phillips (1975)). The modifications are designed to improve the efficiency and stability of the simplex method for this particular application.
4
References
Barrodale I and Phillips C (1974) An improved algorithm for discrete Chebyshev linear approximation Proc. 4th Manitoba Conf. Numerical Mathematics 177–190 University of Manitoba, Canada
Barrodale I and Phillips C (1975) Solution of an overdetermined system of linear equations in the Chebyshev norm [F4] (Algorithm 495) ACM Trans. Math. Software 1(3) 264–270
5
Arguments
 1: $\mathbf{m}$ – IntegerInput

On entry: the number of equations, $m$ (the number of rows of the matrix $A$).
Constraint:
${\mathbf{m}}\ge {\mathbf{n}}$.
 2: $\mathbf{n}$ – IntegerInput

On entry: the number of unknowns, $n$ (the number of columns of the matrix $A$).
Constraint:
${\mathbf{n}}\ge 1$.
 3: $\mathbf{sda}$ – IntegerInput

On entry: the second dimension of the array
a as declared in the (sub)program from which
e02gcf is called.
Constraint:
${\mathbf{sda}}\ge {\mathbf{m}}+1$.
 4: $\mathbf{lda}$ – IntegerInput

On entry: the first dimension of the array
a as declared in the (sub)program from which
e02gcf is called.
Constraint:
${\mathbf{lda}}\ge {\mathbf{n}}+3$.
 5: $\mathbf{a}\left({\mathbf{lda}},{\mathbf{sda}}\right)$ – Real (Kind=nag_wp) arrayInput/Output

On entry:
${\mathbf{a}}\left(\mathit{j},\mathit{i}\right)$ must contain
${a}_{\mathit{i}\mathit{j}}$, the element in the
$\mathit{i}$th row and
$\mathit{j}$th column of the matrix
$A$, for
$\mathit{i}=1,2,\dots ,m$ and
$\mathit{j}=1,2,\dots ,n$, (that is, the
transpose of the matrix). The remaining elements need not be set. Preferably, the columns of the matrix
$A$ (rows of the argument
a) should be scaled before entry: see
Section 7.
On exit: contains the last simplex tableau.
 6: $\mathbf{b}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput/Output

On entry: ${\mathbf{b}}\left(\mathit{i}\right)$ must contain ${b}_{\mathit{i}}$, the $\mathit{i}$th element of the vector $b$, for $\mathit{i}=1,2,\dots ,m$.
On exit: the
$\mathit{i}$th residual
${\mathit{r}}_{\mathit{i}}$ corresponding to the solution vector
$x$, for
$\mathit{i}=1,2,\dots ,m$. Note however that these residuals may contain few significant figures, especially when
resmax is within one or two orders of magnitude of
tol. Indeed if
${\mathbf{resmax}}\le {\mathbf{tol}}$, the elements
${\mathbf{b}}\left(i\right)$ may all be set to zero. It is therefore often advisable to compute the residuals directly.
 7: $\mathbf{tol}$ – Real (Kind=nag_wp)Input

On entry: a threshold below which numbers are regarded as zero. The recommended threshold value is
$10.0\times \epsilon $, where
$\epsilon $ is the
machine precision. If
${\mathbf{tol}}\le 0.0$ on entry, the recommended value is used within the routine. If premature termination occurs, a larger value for
tol may result in a valid solution.
Suggested value:
$0.0$.
 8: $\mathbf{relerr}$ – Real (Kind=nag_wp)Input/Output

On entry: must be set to a bound on the relative error acceptable in the maximum residual at the solution.
If
${\mathbf{relerr}}\le 0.0$, the
${l}_{\infty}$ solution is computed, and
relerr is set to
$0.0$ on exit.
If
${\mathbf{relerr}}>0.0$, the routine obtains instead an approximate solution for which the largest residual is less than
$1.0+{\mathbf{relerr}}$ times that of the
${l}_{\infty}$ solution; on exit,
relerr contains a smaller value such that the above bound still applies. (The usual result of this option, say with
${\mathbf{relerr}}=0.1$, is a saving in the number of simplex iterations).
On exit: is altered as described above.
 9: $\mathbf{x}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayOutput

On exit: if
${\mathbf{ifail}}={\mathbf{0}}$ or
${\mathbf{1}}$,
${\mathbf{x}}\left(\mathit{j}\right)$ contains the
$\mathit{j}$th element of the solution vector
$x$, for
$\mathit{j}=1,2,\dots ,n$. Whether this is an
${l}_{\infty}$ solution or an approximation to one, depends on the value of
relerr on entry.
 10: $\mathbf{resmax}$ – Real (Kind=nag_wp)Output

On exit: if
${\mathbf{ifail}}={\mathbf{0}}$ or
${\mathbf{1}}$,
resmax contains the absolute value of the largest residual(s) for the solution vector
$x$. (See
b.)
 11: $\mathbf{irank}$ – IntegerOutput

On exit: if
${\mathbf{ifail}}={\mathbf{0}}$ or
${\mathbf{1}}$,
irank contains the computed rank of the matrix
$A$.
 12: $\mathbf{iter}$ – IntegerOutput

On exit: if
${\mathbf{ifail}}={\mathbf{0}}$ or
${\mathbf{1}}$,
iter contains the number of iterations taken by the simplex method.
 13: $\mathbf{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: e02gcf 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$

An optimal solution has been obtained, but may not be unique.
 ${\mathbf{ifail}}=2$

Premature termination due to rounding errors. Try using larger value of
tol:
${\mathbf{tol}}=\u2329\mathit{\text{value}}\u232a$.
 ${\mathbf{ifail}}=3$

On entry, ${\mathbf{lda}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{lda}}\ge {\mathbf{n}}+3$.
On entry, ${\mathbf{m}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{m}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}\ge 1$.
On entry, ${\mathbf{sda}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{m}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{sda}}\ge {\mathbf{m}}+1$.
 ${\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
Experience suggests that the computational accuracy of the solution $x$ is comparable with the accuracy that could be obtained by applying Gaussian elimination with partial pivoting to the $n+1$ equations which have residuals of largest absolute value. The accuracy therefore varies with the conditioning of the problem, but has been found generally very satisfactory in practice.
8
Parallelism and Performance
e02gcf is not threaded in any implementation.
The effects of $m$ and $n$ on the time and on the number of iterations in the simplex method vary from problem to problem, but typically the number of iterations is a small multiple of $n$ and the total time is approximately proportional to $m{n}^{2}$.
It is recommended that, before the routine is entered, the columns of the matrix
$A$ are scaled so that the largest element in each column is of the order of unity. This should improve the conditioning of the matrix, and also enable the argument
tol to perform its correct function. The solution
$x$ obtained will then, of course, relate to the scaled form of the matrix. Thus if the scaling is such that, for each
$j=1,2,\dots ,n$, the elements of the
$j$th column are multiplied by the constant
${k}_{j}$, the element
${x}_{j}$ of the solution vector
$x$ must be multiplied by
${k}_{j}$ if it is desired to recover the solution corresponding to the original matrix
$A$.
10
Example
This example approximates a set of data by a curve of the form
where
$K$,
$L$ and
$M$ are unknown. Given values
${y}_{i}$ at
$5$ points
${t}_{i}$ we may form the overdetermined set of equations for
$K$,
$L$ and
$M$
e02gcf is used to solve these in the ${l}_{\infty}$ sense.
10.1
Program Text
Program Text (e02gcfe.f90)
10.2
Program Data
Program Data (e02gcfe.d)
10.3
Program Results
Program Results (e02gcfe.r)