Solving equations for variables