how to solve matrices with variables