This function creates an inverse matrix and then caches it for future use.