Solving a system of equations