Solving equations for variable X