Created functions to invert a matrix and cache its value.