# Can one outperform Cramer's rule for the inversion of a 3 by 3 matrix

I know that for general matrices, Cramer's rule is far from ideal for the numerical computation of the matrix inverse. However, can it be outperformed in the case of a $3 \times 3$ matrix? One particular advantage is that the algorithm is non-branching. For example, the transpose of the inverse can be implemented as follows, assuming the matrix $\bf{a}$ is invertible and the matrices $\bf{a}$ and $\bf{b}$ are stored as contiguous arrays.

void inverse3(double* a, double* b) {
// cofactors
b = a*a - a*a;
b = a*a - a*a;
b = a*a - a*a;
b = a*a - a*a;
b = a*a - a*a;
b = a*a - a*a;
b = a*a - a*a;
b = a*a - a*a;
b = a*a - a*a;
// determinant
double det = b*a + b*a + b*a;
// inverse
b /= det;
b /= det;
b /= det;
b /= det;
b /= det;
b /= det;
b /= det;
b /= det;
b /= det;
}


Can this be improved in terms of efficiency or numerical robustness?

In terms of numerical robustness, yes, for sure. For instance, det could overflow in your code; a method based on a Givens QR factorization won't instead. I guess also that there could be significant cancellation in your cofactor computations.