NAG C Library Chapter Introduction f04 - Simultaneous Linear Equations
NAG C Library Chapter Introduction f04 - Simultaneous Linear Equations
Contents
1 Scope of the Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4 Decision Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
[NP3645/7] f04.1
Introduction – f04 NAG C Library Manual
f04.2 [NP3645/7]
f04 – Simultaneous Linear Equations Introduction – f04
Roughly speaking, errors or uncertainties in A or b may be amplified in the solution by a factor ðAÞ.
Thus, for example, if the data in A and b are only accurate to 5 digits and ðAÞ 103 , then the solution
cannot be guaranteed to have more than 2 correct digits. If ðAÞ 105 , the solution may have no
meaningful digits.
To be more precise, suppose that
Ax ¼ b and ðA þ AÞðx þ xÞ ¼ b þ b:
Here A and b represent perturbations to the matrices A and b which cause a perturbation x in the
solution. We can define measures of the relative sizes of the perturbations in A, b and x as
kAk kbk kxk
A ¼ ; b ¼ and x ¼ respectively:
kAk kbk kxk
Then
ðAÞ
x ð þ b Þ
1 ðAÞA A
provided that ðAÞA < 1. Often ðAÞA 1 and then the bound effectively simplifies to
x ðAÞðA þ b Þ:
Hence, if we know ðAÞ, A and b , we can compute a bound on the relative errors in the solution. Note
that A , b and x are defined in terms of the norms of A, b and x. If A, b or x contains elements of
widely differing magnitude, then A , b and x will be dominated by the errors in the larger elements, and
x will give no information about the relative accuracy of smaller elements of x.
Another way to obtain useful information about the accuracy of a solution is to solve two sets of equations,
one with the given coefficients, which are assumed to be known with certainty to p figures, and one with
the coefficients rounded to (p 1) figures, and to count the number of figures to which the two solutions
agree. In ill-conditioned problems this can be surprisingly small and even zero.
Chapter f07 contains functions for estimating condition numbers and for returning error bounds.
[NP3645/7] f04.3
Introduction – f04 NAG C Library Manual
The SVD may also be used to find solutions to the homogeneous system of equations Ax ¼ 0, where A is
m by n. Such solutions exist if and only if rankðAÞ < n, and are given by
X
n
x¼ i pi
i¼rþ1
where the i are arbitrary numbers and the pi are the columns of P which correspond to negligible
elements of D.
^ þ x, where x
The general solution to the rank-deficient least-squares problem is given by x ^ is the minimal
length least-squares solution and x is any solution of the homogeneous system of equations Ax ¼ 0.
f04.4 [NP3645/7]
f04 – Simultaneous Linear Equations Introduction – f04
It is therefore impossible to give an infallible rule, but generally the rank can be taken to be the number of
singular values which are neither zero nor very small compared with other singular values. For example, if
there is a sharp decrease in singular values from numbers of order unity to numbers of order 107, then the
latter will almost certainly be zero in a machine in which 7 significant decimal figures is the maximum
accuracy. Similarly for a least-squares problem in which the data is known to about four significant figures
and the largest singular value is of order unity then a singular value of order 104 or less should almost
certainly be regarded as zero.
It should be emphasised that rank determination and least-squares solutions can be sensitive to the scaling
of the matrix. If at all possible the units of measurement should be chosen so that the elements of the
matrix have data errors of approximately equal magnitude.
[NP3645/7] f04.5
Introduction – f04 NAG C Library Manual
Black Box functions solve the equations Axi ¼ bi , for i ¼ 1; 2; . . . ; p, in a single call with the matrix A
and the right-hand sides bi being supplied as data. These are the simplest functions to use and are suitable
when all the right-hand sides are known in advance and do not occupy too much storage.
General purpose functions, in general, require a previous call to a function in Chapter f01 or Chapter f03 to
factorize the matrix A. This factorization can then be used repeatedly to solve the equations for one or
more right-hand sides which may be generated in the course of the computation. The Black Box functions
simply call a factorization function and then a general purpose function to solve the equations.
4 Decision Tree
If at any stage the answer to a question is ‘Don’t know’ this should be read as ‘No’.
The name of the function (if any) that should be used to factorize the matrix A is given in brackets after
the name of the function for solving the equations.
Tree 1: Black Box functions for unique solution of Ax = b
no
f04adc
f04.6 [NP3645/7]
f04 – Simultaneous Linear Equations Introduction – f04
Is A a symmetric
Is A a variable band
Is A a real matrix? yes positive-definite yes matrix? yes f04mcc (f01mcc)
matrix?
no
f04agc (f03aec)
no
f04ajc (f03afc)
no
Is A a Hermitian
positive-definite yes f04awc (f01bnc)
matrix?
no
f04akc (f03ahc)
5 Index
Black Box functions, Ax ¼ b
Complex matrix, ............................................................ nag_complex_lin_eqn_mult_rhs (f04adc)
Real matrix,
Single right-hand side, ...................................................................... nag_real_lin_eqn (f04arc)
General Purpose functions, Ax ¼ b
Complex Hermitian positive-definite matrix, ............ nag_hermitian_lin_eqn_mult_rhs (f04awc)
Complex matrix, .......................................................... nag_complex_lu_solve_mult_rhs (f04akc)
Real band symmetric positive-definite matrix,
variable bandwidth, ............................................ nag_real_cholesky_skyline_solve (f04mcc)
Real matrix, ........................................................................ nag_real_lu_solve_mult_rhs (f04ajc)
Real symmetric positive-definite matrix, ............. nag_real_cholesky_solve_mult_rhs (f04agc)
7 References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press,
Baltimore
Lawson C L and Hanson R J (1974) Solving Least-squares Problems Prentice–Hall
Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–
Verlag