Solving for x and checking solutions.