Page 120 - Applied Numerical Methods Using MATLAB
P. 120
PROBLEMS 109
computational burden. Give the name “lu_trid()” to the modified routine
and use it to get the LU decomposition of the tridiagonal matrix
2 −1 0 0
−1 2 −1 0
A = (P2.5.1)
0 −1
2 −1
0 0 −1 2
You may type the following statements into the MATLAB command window:
>>A=[2-100;-12-10; 0 -12-1;00-12];
>>[L,U] = lu_trid(A)
>>L*U-A%=0(No error)?
2.6 LS Solution by Backslash Operator and QR Decomposition
The backslash (‘A\b’) operator and the matrix left division
(‘mldivide(A,b)’) function turn out to be the most efficient means for solv-
ing a system of linear equations as Eq. (P2.3.1). They are also capable of
dealing with the under/over-determined cases. Let’s see how they handle the
under/over-determined cases.
(a) For an underdetermined system of linear equations
x 1
1 2 3 14
A 1 x = b 1 , x 2 = (P2.6.1)
4 5 6 32
x 3
find the minimum-norm solution (2.1.7) and the solutions that can be
obtained by typing the following statements in the MATLAB command
window:
>>A1 = [1 2 3; 4 5 6]; b1 = [14 32]’;
>>x_mn = A1’*(A1*A1’)^-1*b1, x_pi = pinv(A1)*b1, x_bs = A1\b1
Are the three solutions the same?
(b) For another underdetermined system of linear equations
x 1
1 2 3 14
A 2 x = b 2 , x 2 = (P2.6.2)
2 4 6 28
x 3
find the solutions by using Eq. (2.1.7), the commands pinv(), and back-
slash (\). If you are not pleased with the result obtained from Eq. (2.1.7),
you can remove one of the two rows from the coefficient matrix A 2 and
try again. Identify the minimum solution(s). Are the equations redundant
or inconsistent?