solves a systems of three equations