Mathematics |
Rectangular matrices do not have inverses or determinants. At least one of the equations AX = I and XA = I does not have a solution. A partial replacement for the inverse is provided by the Moore-Penrose pseudoinverse, which is computed by the pinv
function.
is the 2-by-2 identity, but the matrix
is not the 3-by-3 identity. However, P
acts like an identity on a portion of the space in the sense that P
is symmetric, P*C
is equal to C
and X*P
is equal to X
.
Solving a Rank-Deficient System
If A
is m-by-n with m > n and full rank n, then each of the three statements
theoretically computes the same least squares solution x
, although the backslash operator does it faster.
However, if A
does not have full rank, the solution to the least squares problem is not unique. There are many vectors x
that minimize
The solution computed by x = A\b
is a basic solution; it has at most r nonzero components, where r is the rank of A
. The solution computed by x = pinv(A)*b
is the minimal norm solution because it minimizes norm(x)
. An attempt to compute a solution with x = inv(A'*A)*A'*b
fails because A'*A
is singular.
Here is an example that illustrates the various solutions.
does not have full rank. Its second column is the average of the first and third columns. If
is the second column, then an obvious solution to A*x = b
is x = [0 1 0]'
. But none of the approaches computes that x
. The backslash operator gives
This solution has two nonzero components. The pseudoinverse approach gives
There is no warning about rank deficiency. But norm(y) = 0.5774
is less than norm(x) = 0.7071
. Finally
Overview | Cholesky, LU, and QR Factorizations |
© 1994-2005 The MathWorks, Inc.