Solution of Linear Algebraic Equations
Solution of Linear Algebraic Equations
Solution of Linear Algebraic Equations
0 Introduction
A set of linear algebraic equations looks like this:
a11 x1 + a12 x2 + a13 x3 + + a1N xN = b1
a21 x1 + a22 x2 + a23 x3 + + a2N xN = b2
a31 x1 + a32 x2 + a33 x3 + + a3N xN = b3
(2.0.1)
Sample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X)
Copyright (C) 1986-1992 by Cambridge University Press. Programs Copyright (C) 1986-1992 by Numerical Recipes Software.
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
2.0 Introduction
23
Matrices
Equation (2.0.1) can be written in matrix form as
Ax=b
(2.0.2)
Here the raised dot denotes matrix multiplication, A is the matrix of coefficients, and
b is the right-hand side written as a column vector,
Sample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X)
Copyright (C) 1986-1992 by Cambridge University Press. Programs Copyright (C) 1986-1992 by Numerical Recipes Software.
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
Accumulated roundoff errors in the solution process can swamp the true
solution. This problem particularly emerges if N is too large. The
numerical procedure does not fail algorithmically. However, it returns a
set of xs that are wrong, as can be discovered by direct substitution back
into the original equations. The closer a set of equations is to being singular,
the more likely this is to happen, since increasingly close cancellations
will occur during the solution. In fact, the preceding item can be viewed
as the special case where the loss of significance is unfortunately total.
24
Chapter 2.
np
n
5
6
2
m
3
7
mp
3
18
10
38
34
30
37
33
25
29
36
32
28
20
24
31
27
23
19
15
2
14
26
22
1
9
17
13
21
8
4
16
12
1
11
39
35
40
Figure 2.0.1. A matrix of logical dimension m by n is stored in an array of physical dimension mp by np.
Locations marked by x contain extraneous information which may be left over from some previous use of
the physical array. Circled numbers show the actual ordering of the array in computer memory, not usually
relevant to the programmer. Note, however, that the logical array does not occupy consecutive memory
locations. To locate an (i,j) element correctly, a subroutine must be told mp and np, not just i and j.
Sample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X)
Copyright (C) 1986-1992 by Cambridge University Press. Programs Copyright (C) 1986-1992 by Numerical Recipes Software.
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
2.0 Introduction
25
Sample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X)
Copyright (C) 1986-1992 by Cambridge University Press. Programs Copyright (C) 1986-1992 by Numerical Recipes Software.
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
Here the subroutine has to be told both the logical size of the matrix that
you want to invert (here n = 4), and the physical size of the array in which it is
stored (here np = 10).
This seems like a trivial point, and we are sorry to belabor it. But it turns out that
most reported failures of standard linear equation and matrix manipulation packages
are due to user errors in passing inappropriate logical or physical dimensions!
26
Chapter 2.
where AT denotes the transpose of the matrix A. Equations (2.0.4) are called the
normal equations of the linear least-squares problem. There is a close connection
between singular value decomposition and the linear least-squares problem, and the
latter is also discussed in 2.6. You should be warned that direct solution of the
normal equations (2.0.4) is not generally the best way to find least-squares solutions.
Some other topics in this chapter include
Iterative improvement of a solution (2.5)
Various special forms: symmetric positive-definite (2.9), tridiagonal
(2.4), band diagonal (2.4), Toeplitz (2.8), Vandermonde (2.8), sparse
(2.7)
Strassens fast matrix inversion (2.11).
Sample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X)
Copyright (C) 1986-1992 by Cambridge University Press. Programs Copyright (C) 1986-1992 by Numerical Recipes Software.
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
(AT A) x = (AT b)
27
Sample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X)
Copyright (C) 1986-1992 by Cambridge University Press. Programs Copyright (C) 1986-1992 by Numerical Recipes Software.
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
Gill, P.E., Murray, W., and Wright, M.H. 1991, Numerical Linear Algebra and Optimization, vol. 1
(Redwood City, CA: Addison-Wesley).
Stoer, J., and Bulirsch, R. 1980, Introduction to Numerical Analysis (New York: Springer-Verlag),
Chapter 4.