How to solve a matrix