This is a combination of two geometric sequences, one for when the ball is falling and another for when the ball is climbing.
Since 1/2 is the common ratio, the sum of the geometric sequences will be:
s=a/(1-r) as n goes to infinity, that is why the sum is missing (1-r^n) as it becomes one as n approaches infinity.
So the sum for the falling ball is:
s=10/(1-1/2)=20
And the sum for the climbing ball is:
s=5/(1-1/2)=10
So the total distance the ball travels in total magnitude is 20+10=30 meters