Page 121 - Applied Numerical Methods Using MATLAB
P. 121
110 SYSTEM OF LINEAR EQUATIONS
Table P2.6.1 Comparison of Several Methods for Computing the LS Solution
QR LS: Eq. (2.1.10) pinv(A)*b A\b
||Ax i − b|| 2.8788e-016 2.8788e-016
# of flops 25 89 196 92
(c) For another underdetermined system of linear equations
x 1
12 3 21
A 2 x = b 3 , x 2 = (P2.6.3)
24 6 21
x 3
find the solutions by using Eq. (2.1.7), the commands pinv(), and back-
slash (\). Does any of them satisfy Eq. (P2.6.3) closely? Are the equations
redundant or inconsistent?
(d) For an overdetermined system of linear equations
1 2 5.2
x 1
A 4 x = b 4 , 2 3 = 7.8 (P2.6.4)
x 2
4 −1 2.2
find the LS (least-squares) solution (2.1.10), that can be obtained from
the following statements. Fill in the corresponding blanks of Table P2.6.1
with the results.
>>A4 = [1 2; 2 3; 4 -1]; b4 = [5.2 7.8 2.2]’;
>> x_ls = (A4’*A4)\A4’*b4, x_pi = pinv(A4)*b4, x_bs = A4\b4
(e) We can use QR decomposition to solve a system of linear equations as
Eq. (P2.3.1), where the coefficient matrix A is square and nonsingular or
rectangular with the row dimension greater than the column dimension.
The procedure is explained as follows:
−1
−1
Ax = QRx = b, Rx = Q b = Q b, x = R Q b (P2.6.5)
Note that Q Q = I; Q = Q −1 (orthogonality) and the premultiplica-
tion of R −1 can be performed by backward substitution, because R is
an upper-triangular matrix. You are supposed not to count the num-
ber of floating-point operations needed for obtaining the LU and QR
decompositions, assuming that they are available.
(i) Apply the QR decomposition, the LU decomposition, Gauss elimi-
nation, and the backslash (\) operator to solve the system of linear