wrote matrix functions to cache inverse matrix