Inverting a matrix

Inverted the matrix and cached