Problem with calculating average. I came across the following question.

A man travels a distance of $20$ miles at $60$ miles/hr and then return over the same route at $40$ miles/hr. What is the average rate for the round trip in miles per hour

The way I see it is $(60+40)/2 = 50$ miles/hr. However, the book says the answer is $48$. Am I missing something here?
A clear explanation  would be appreciate on how the book came up with $48$ instead of $50$?
 A: Average rate is the average miles per hour.  Calculate the total miles traveled and divide by the total amount of time it took, and you'll see why you can't just average the numbers 60 and 40.
A: To see that your reasoning can’t be right, consider the extreme case in which he makes the outbound trip at $20$ mph and the return trip at $0$ mph. By your reasoning his average speed for the round trip would be $10$ mph, even though he never actually completes it! In fact you can see that in that case he takes an hour for the first leg and never completes the second at all. Had he actually averaged $10$ mph, he’d have covered the $20+20=40$ miles in $4$ hours, so the return trip would have taken $3$ hours, and his average speed on that leg would have been $20/3$, or $6$-$2/3$, mph.
The reason you can’t simply average the speeds is that since he covers the same distance in each direction, he spends more time travelling at the slower speed. Thus, it weighs more heavily in determining his overall average speed.
A: If the following is too general, don't worry about it. Suppose that we travel from $X$ to $Y$ and then back to $X$.  Suppose that on the trip from $X$ to $Y$ we average $a$ miles per hour, and on the trip back we average $b$ miles per hour. What is our average speed for the whole trip?
Let the distance from $X$ to $Y$ be $d$ miles. The trip from $X$ to $Y$ then took $\dfrac{d}{a}$ hours. The trip back took $\dfrac{d}{b}$ hours. So the total travel time was $\dfrac{d}{a}+\dfrac{d}{b}$.
The total distance covered on our there and back trip was $2d$. The average speed for the whole trip is the distance covered divided by the time it took. So our average speed is
$$\frac{2d}{\frac{d}{a}+\frac{d}{b}}.\tag{$1$}$$
Note that the $d$'s cancel. Our average speed is therefore
$$\frac{2}{\frac{1}{a}+\frac{1}{b}}\quad\text{or equivalently}\quad\frac{1}{\frac{\frac{1}{a}+\frac{1}{b}}{2}}.$$
For calculation purposes, it is easier to use the equivalent expression
$$\frac{2ab}{a+b}.$$
All of these are called the harmonic mean of $a$ and $b$. It has many uses. 
Here is a similar problem. We spend $d$ dollars on wine that costs $a$ dollars per bottle, and $d$ dollars on wine that costs $b$ dollars per bottle. What is our average cost per bottle? 
We got $\dfrac{d}{a}$ bottles  of the $a$-dollar wine, and $\dfrac{d}{b}$ bottles of the $b$-dollar wine. So the total number of bottles that we got is $\dfrac{d}{a}+\dfrac{d}{b}$. We spent a total of $2d$ dollars. So our average cost per bottle is 
$$\frac{2d}{\frac{d}{a}+\frac{d}{b}}.\tag{$2$}$$ 
Note that $(2)$ is exactly the same expression as $(1)$. We don't need to take a trip to use the harmonic mean. 
