Solution for matrix inverse