Solving the inverse matrix