Post · 4 min read· pp. 864–866

What Is A\A?

In a recent blog post What is A\AA\backslash A?, Cleve Moler asked what the MATLAB operation A\AA \backslash A returns. I will summarize what backslash does in general, for A\BA \backslash B and then consider the case B=AB = A.

A\BA \backslash B is a solution, in some appropriate sense, of the equation

AX=B,A∈Cm×nX∈Cn×pB∈Cm×p.(1)\notag AX = B, \quad A \in\mathbb{C}^{m\times n} \quad X \in\mathbb{C}^{n\times p} \quad B \in\mathbb{C}^{m\times p}. \qquad (1)

It suffices to consider the case p=1p = 1, because backslash treats the columns independently, and we write this as

Ax=b,A∈Cm×nx∈Cnb∈Cm.\notag Ax = b, \quad A \in\mathbb{C}^{m\times n} \quad x \in\mathbb{C}^{n} \quad b \in\mathbb{C}^{m}.

The MATLAB backslash operator handles several cases depending on the relative sizes of the row and column dimensions of AA and whether it is rank deficient.

Square Matrix: m=nm = n

When AA is square, backslash returns x=A−1bx = A^{-1}b, computed by LU factorization with partial pivoting (and of course without forming A−1A^{-1}). There is no special treatment for singular matrices, so for them division by zero may occur and the output may contain NaNs (in practice, what happens will usually depend on the rounding errors). For example:

text
>> A = [1 0; 0 0], b = [1 0]', x = A\b
A =
     1     0
     0     0
b =
     1
     0
Warning: Matrix is singular to working precision. 

x =
     1
   NaN

Backslash take advantage of various kinds of structure in AA; see MATLAB Guide (section 9.3) or doc mldivide in MATLAB.

Overdetermined System: m>nm > n

An overdetermined system has no solutions, in general. Backslash yields a least squares (LS) solution, which is unique if AA has full rank. If AA is rank-deficient then there are infinitely many LS solutions, and backslash returns a basic solution: one with at most rank(A)\mathrm{rank}(A) nonzeros. Such a solution is not, in general, unique.

Underdetermined System: m<nm < n

An underdetermined system has fewer equations than unknowns, so either there is no solution of there are infinitely many. In the latter case A\bA\backslash b produces a basic solution and in the former case a basic LS solution. Example:

text
>> A = [1 1 1; 1 1 0]; b = [3 2]'; x = A\b
x =
   2.0000e+00
            0
   1.0000e+00

Another basic solution is [0 2 1]T[0~2~1]^T, and the minimum 22-norm solution is [1 1 1]T[1~1~1]^T.

A\A

Now we turn to the special case A\AA\backslash A, which in terms of equation (1) is a solution to AX=AAX = A. If A=0A = 0 then X=IX = I is not a basic solution, so A\A≠IA\backslash A \ne I; in fact, 0\0=00\backslash 0 = 0 if m≠nm\ne n and it is matrix of NaNs if m=nm = n.

For an underdetermined system with full-rank AA, A\AA\backslash A is not necessarily the identity matrix:

text
>> A = [1 0 1; 0 1 0], X = A\A
A =
     1     0     1
     0     1     0
X =
     1     0     1
     0     1     0
     0     0     0

But for an overdetermined system with full-rank AA, A\AA\backslash A is the identity matrix:

text
>> A'\A'
ans =
   1.0000e+00            0
  -1.9185e-17   1.0000e+00

Minimum Frobenius Norm Solution

The MATLAB definition of A\bA\backslash b is a pragmatic one, as it computes a solution or LS solution to Ax=bAx = b in the most efficient way, using LU factorization (m=nm = n) or QR factorization (m≠n(m\ne n). Often, one wants the solution of minimum 22-norm, which can be expressed as A+bA^+b, where A+A^+ is the pseudoinverse of AA. In MATLAB, A+bA^+b can be computed by lsqminnorm(A,b) or pinv(A)*b, the former expression being preferred as it avoids the unnecessary computation of A+A^+ and it uses a complete orthogonal factorization instead of an SVD.

When the right-hand side is a matrix, BB, lsqminnorm(A,B) and pinv(A)*B give the solution of minimal Frobenius norm, which we write as A\\BA \backslash\backslash B. Then A\\A=A+AA\backslash\backslash A = A^+A, which is the orthogonal projector onto range(A∗)\mathrm{range}(A^*), and it is equal to the identity matrix when m≥nm\ge n and AA has full rank. For the matrix above:

text
>> A = [1 0 1; 0 1 0], X = lsqminnorm(A,A)
A =
     1     0     1
     0     1     0
X =
   5.0000e-01            0   5.0000e-01
            0   1.0000e+00            0
   5.0000e-01            0   5.0000e-01

This article is part of the “What Is” series, available from https://nhigham.com/index-of-what-is-articles/ and in PDF form from the GitHub repository https://github.com/higham/what-is.