method to inverse matrix