Harmonic mean

import numpy as np
import matplotlib.pyplot as plt
# Harmonic series

a = 0
d = 1
t = np.arange(1., 10., 1)

plt.plot(t, 1./(a+t*d), '-')
plt.xlabel('k')
plt.ylabel('harmonic series')
plt.show()
../_images/4fe59960468135ba539eedef5bdb9aba4fa625c4449cf9fe18a9d1fc022e0eee.png

Harmonic mean#

A car travels at 80 km/h for the half of the trip (goes to some place) and 100 km/h for the second half (comes back home). What’s his average speed? 2/(1/80+1/100) = 89 km/h (averaging over periods of time not distances)

v1 = 80
v2 = 100
hm = 1./2 * (1./v1 + 1./v2)
print(1./ hm)
88.88888888888889