Page 30 - Applied Numerical Methods Using MATLAB
P. 30
BASIC OPERATIONS OF MATLAB 19
mentioned in item 2 of Remark 1.1, which says that, in order for the left inverse
to exist, the number of rows must not be less than the number of columns.
>>A1_li*A1 %No identity matrix, since A1_li isn’t the left inverse
ans = 1.2500 0.7500 -0.2500
-0.2500 0.5000 0.7500
1.5000 3.5000 2.5000
>>det(A1’*A1) %A1 is not left-invertible for A1’*A1 is singular
ans=0
(cf) Let us be nice to MATLAB as it is to us. From the standpoint of promoting mutual
understanding between us and MATLAB, we acknowledge that MATLAB tries to
show us apparently good results to please us like always, sometimes even pretending
not to be obsessed by the demon of ‘ill-condition’ in order not to make us feel uneasy.
How kind MATLAB is! But, we should be always careful not to be spoiled by its
benevolence and not to accept the computing results every inch as it is. In this case,
even though the matrix [A1’*A1] is singular and so not invertible, MATLAB tried
to invert it and that’s all. MATLAB must have felt something abnormal as can be
seen from the ominous warning message prior to the computing result. Who would
blame MATLAB for being so thoughtful and loyal to us? We might well be rather
touched by its sincerity and smartness.
In the above statements, we see the slash(/)/backslash(\) operators. These oper-
ators are used for right/left division, respectively; B/A is the same as B*inv(A) and
A\B is the same as inv(A)*B when A is invertible and the dimensions of A and B
are compatible. Noting that B/A is equivalent to (A’\B’)’, let us take a close look
at the function of the backslash(\) operator.
>>X=A1\A1 % an identity matrix?
X = 1.0000 0 -0.8462
0 1.0000 1.0769
0 0 0
(Q13) It seems that A1\A1 should have been an identity matrix, but it is not, contrary
to our expectation. Why?
(A13) We should know more about the various functions of the backslash(\), which
can be seen by typing ‘help slash’ into the MATLAB Command window. Let
Remark 1.2 answer this question in cooperation with the next case.
>>A1*X - A1 %zero if X is the solution to A1*X = A1?
ans = 1.0e-015 * 0 0 0
0 0 -0.4441
Remark 1.2. The Function of Backslash (\) Operator. Overall, for the command
‘A\B’, MATLAB finds a solution to the equation A*X=B. Let us denote the
row/column dimension of the matrix A by M and N.
1. If matrix A is square and upper/lower-triangular in the sense that all of
its elements below/above the diagonal are zero, then MATLAB finds the
solution by applying backward/forward substitution method (Section 2.2.1).