calculate the speed of a wave