Simplifying equations and solving for variables