Solves a system of equations