Why average speed is not the arithmetic mean of speeds
If you drive 50 km at 50 km/h and then 50 km at 100 km/h, your average speed is not 75 km/h. The first leg takes one hour and the second takes half an hour, so you cover 100 km in 1.5 hours, giving an average of 66.7 km/h. Arithmetic averaging ignores the time spent at each speed.
The correct approach is to divide total distance by total time. For a multi-segment journey the time per segment is the segment distance divided by the segment speed. Summing all segment times and dividing total distance by that total time gives the true average speed.
Average speed = Total distance / Total time
The universal formula for average speed over any journey.
Segment time = Segment distance / Segment speed
Time for each leg, used to find total elapsed time in multi-segment mode.