Solving for the variable w