Solving for the variable r