solving 3 equations with 3 unknowns