Cache function using solve for inverse matrix multiplication