Created functions to calculate the inverse of a matrix and cache the results.