[Math] Inverse of a 3 x 3 Covariance Matrix (Or Any Positive Definite [PD] Matrix)

inversematrices

I have 2 pixels with size 1×3 called $A$ and $B$ and I have to compute the following equation:

$$
A^T *(\Sigma+ I_3*\lambda)^{-1}*B
$$

where $\Sigma$ is the covariance matrix (3×3) between vectors $A$ and $B$.

$I_3$ is the 3×3 identity matrix.

$\lambda$ is a constant (therefore, the matrix is not singular).

At the moment, i'm computing the inverse of the $\Sigma +I_3*\lambda$ using the Gauss-Jordan elimination.

I wanna know if there is a trick to compute this equation without computing the inverse. I'm also limited in memory so the Gauss-Jordan elimination is not a really good solution. I also tried to compute straight the inverse using the rule of Sarrus but the result was not enought accurate.

My aim is to resolve this equation with the highest speed and the minimum memory space.

EDIT:

Anyone knows a fast and good way to inverse a 3×3 symmetric matrix ?

EDIT 2:

I'm thinking about making a Cholesky decomposition of my matrix but after that, I don't understand how to compute the inverse of $(\Sigma +I_3*\lambda)$ from Cholesky matrix.

Best Answer

Since the matrix is symmetric, its inverse is also symmetricת we'll use that and solve.

Let this be the matrix:

[m11  m12  m13]  
[m12  m22  m23]  
[m13  m23  m33]  

Its determinant is:

D = m11 * (m33 * m22 - m23^2) - m21 * (m33 * m12 - m23 * m13) + m13 * (m23 * m12 - m22 * m13)

Assuming it is non zero.

The members of the inverse:

a11 = m33 * m22 - m23^2  
a12 = m13 * m23 - m33 * m12  
a13 = m12 * m23 - m13 * m22  

a22 = m33 * m11 - m13^2  
a23 = m12 * m13 - m11 * m23

a33 = m11 * m22 - m12^2

Divide them all by the determinant which is now given by:

D = (m11 * a11) + (m12 * a12) + (m13 * a13)

Pay attention my only assumption here is about the Matrix being symmetric and invertible. So it is more general then only working on PD (Positive Definite) / Covariance matrices.