Solving equations with ratios