Harmonic mean is $\frac{1}{\frac{\frac{1}{a}+\frac{1}{b}}{2}}=\frac{1}{\frac{\frac{b+a}{ab}}{2}}=\frac{2}{(b+a)(ab)}\neq \frac{2ab}{b+a}$
But the book says that the RHS is actually the harmonic mean where am I wrong? Because first the book specifies the harmonic mean with $\frac{1}{A(\frac{1}{a},\frac{1}{b})}$ where $A$ is the arithmetic mean but then the formulas don't match where is the error?
You made a mistake in step $3$.
$$\dfrac{1}{\frac{a+b}{\frac{ab}{2}}}=\dfrac{2ab}{a+b}=\text{HM}\{a, b\}=\dfrac{1}{\text{AM}\{1/a, 1/b\}}$$