Reduce computational costs by utilizing cache when calculating the inverse of a matrix