# Moore-Penrose pseudoinverse of a 3×3 matrix

Is there a "simple" formula for computing the Moore-Penrose pseudoinverse of a $3\times 3$ matrix? I mean something like the formula for the inverse (for non-singular matrices), which involves the matrix of minors, etc.

I need that for a computer program, and I feel that using LAPACK's SVD is a bit of an overkill.

You are probably thinking of the formula \begin{align} \mathbf{A}^{-1} &= \frac{\text{adj } \mathbf{A}} {\det \mathbf{A} } \\ &= \frac{\left( \text{cof } \mathbf{A}\right)^{\mathrm{T}}} {\det \mathbf{A} } \\ \end{align} The matrix $\text{adj } \mathbf{A}$ is the adjugate of $\mathbf{A}$ and is the transpose of $\mathbf{C}$, the matrix of cofactors of $\mathbf{A}$.
For a nonsingular $\mathbf{A}\in\mathbb{R}^{3 x 3}$, $$\mathbf{A} = \left[ \begin{array}{ccc} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{array} \right],$$ the matrix of cofactors is composed of the determinants $$\mathbf{C} = \left[ \begin{array}{ccc} % + \left| \begin{array}{cc} a_{22} & a_{23} \\ a_{32} & a_{33} \end{array} \right| & - \left| \begin{array}{cc} a_{21} & a_{23} \\ a_{31} & a_{33} \end{array} \right| & + \left| \begin{array}{cc} a_{21} & a_{22} \\ a_{31} & a_{32} \end{array} \right| \\ % - \left| \begin{array}{cc} a_{12} & a_{13} \\ a_{32} & a_{33} \end{array} \right| & + \left| \begin{array}{cc} a_{11} & a_{13} \\ a_{31} & a_{33} \end{array} \right| & - \left| \begin{array}{cc} a_{11} & a_{12} \\ a_{31} & a_{32} \end{array} \right| \\ % + \left| \begin{array}{cc} a_{12} & a_{13} \\ a_{22} & a_{23} \end{array} \right| & - \left| \begin{array}{cc} a_{11} & a_{13} \\ a_{21} & a_{23} \end{array} \right| & + \left| \begin{array}{cc} a_{11} & a_{12} \\ a_{21} & a_{22} \end{array} \right| \\ \end{array} \right].$$
Because you specified that $\mathbf{A}$ is nonsingular, the matrix inverse exists and is the same as the Moore-Penrose pseudoinverse: $$\mathbf{A}^{-1} = \mathbf{A}^{\dagger}.$$
Example Pencil and paper exercise of confirmation: $$\mathbf{A} = \left[ \begin{array}{ccc} 1 & 0 & 1 \\ 0 & 1 & 1 \\ 1 & 0 & 0 \end{array} \right],$$ The determinant is $\det \mathbf{A} = 1$, and the matrix of cofactors is $$\mathbf{C} = \left[ \begin{array}{rrr} 0 & 1 & -1 \\ 0 & -1 & 0 \\ -1 & -1 & 1 \end{array} \right]$$ The inverse matrix is $$\mathbf{A}^{-1} = \frac{\left( \text{cof } \mathbf{A}\right)^{\mathrm{T}}} {\det \mathbf{A} } = \frac{\mathbf{C}^\mathrm{T}} {-1} = \left[ \begin{array}{rrr} 0 & 0 & 1 \\ -1 & \phantom{-}1 & 1 \\ 1 & 0 & -1 \end{array} \right].$$
• If the problem is 'take a generic matrix and test for singularity,' the best choice is to compute the singular value spectrum. If you have $\sigma_{k}=0$, then your matrix is singular and of rank $k-1$. In practise though you will have to look at small singular values with magnitude close to machine noise and decide if they are real or arithmetic errors. The pseudoinverse has iterative prescriptions, and the direct construction $\mathbf{A}^{\dagger} = \mathbf{V}\Sigma^{\dagger}\mathbf{U}^{*}$ from the SVD. – dantopa Mar 6 '17 at 0:51