Time, Speed, and Distance
Converting speed units, combining speeds for objects moving toward or away from each other, and finding average speed on a round trip.
What you'll learn
- Convert speed between km/h and m/s
- Compute relative speed for two objects moving in the same direction or in opposite directions
- Compute the average speed for a round trip covering equal distances at two different speeds
Prerequisites
Explanation
The core relationship is speed = distance / time, which rearranges to distance = speed × time, or time = distance / speed depending on what a problem asks for. The one habit that prevents the most careless errors here is keeping units consistent before doing any arithmetic.
Unit conversion. Speed is usually given in km/h but distances or times in a problem sometimes use meters and seconds. Since 1 km = 1000 m and 1 hour = 3600 s, converting km/h to m/s means multiplying by 1000/3600, which simplifies to 5/18. Converting back, m/s to km/h, multiplies by 18/5. So 90 km/h = 90 × 5/18 = 25 m/s, and 25 m/s = 25 × 18/5 = 90 km/h — a quick sanity check both ways.
Relative speed describes how fast the gap between two moving objects changes:
- Same direction: relative speed = |speed₁ − speed₂| (the faster one only gains on the slower one at the difference between their speeds).
- Opposite directions: relative speed = speed₁ + speed₂ (they close the gap at the combined rate of both speeds).
Worked example. Two cyclists start from the same point, riding in opposite directions at 15 km/h and 20 km/h. After 3 hours, how far apart are they? Relative speed = 15 + 20 = 35 km/h (opposite directions add). Distance apart = 35 × 3 = 105 km.
Average speed for a round trip. A very common trap: if you travel a distance at speed s₁ and return the same distance at speed s₂, the average speed for the whole trip is not the simple average (s₁+s₂)/2. Because you spend more time traveling at the slower speed, that slower speed should — and does — pull the average down more than a straight average would suggest. The correct formula, when the two distances are equal, is the harmonic mean:
Average speed = 2 × s₁ × s₂ / (s₁ + s₂)
Worked example. A car travels from City A to City B at 60 km/h and returns at 40 km/h. Naive average: (60+40)/2 = 50 km/h — but that's wrong. Correct average speed = 2×60×40/(60+40) = 4800/100 = 48 km/h, noticeably lower than 50, because the return leg at 40 km/h simply takes more time and therefore weighs more heavily in the overall average. The harmonic-mean formula only applies when the two distances covered are equal — if the problem instead gives equal times at each speed, the simple arithmetic average is correct instead.
Same-direction vs opposite-direction relative speed
Same direction: two objects moving the same way close or open their gap at the difference of their speeds (subtract). Opposite directions: two objects moving toward or away from each other close or open their gap at the sum of their speeds (add).
Example
Converting km/h to m/s uses the factor 5/18 (equivalently, 1000 meters per 3600 seconds).
function kmphToMps(speedKmph) {
return Math.round(speedKmph * (5 / 18) * 100) / 100;
}
// Example: kmphToMps(90) -> 25Guided exercise
Guided exercise
Write relativeSpeed(speed1, speed2, direction) where direction is either 'same' or 'opposite'. Return the relative speed: the absolute difference of the two speeds for 'same' direction, or their sum for 'opposite' directions.
Checks: Computes same-direction relative speed · Computes opposite-direction relative speed · plus 1 hidden check
Code editor. Press Escape then Tab to leave the editor if keyboard focus becomes trapped. Press Control+Shift+M inside the editor to toggle Tab-key focus trapping.
Stuck? Get a hint.
Independent exercise
Independent exercise
Write averageRoundTripSpeed(speed1, speed2) that returns the average speed, rounded to 2 decimal places, for a round trip covering equal distance at speed1 one way and speed2 the return way, using the harmonic mean formula 2 * speed1 * speed2 / (speed1 + speed2).
Checks: Computes the harmonic mean for two different speeds · Computes the harmonic mean for another pair of speeds · plus 1 hidden check
Code editor. Press Escape then Tab to leave the editor if keyboard focus becomes trapped. Press Control+Shift+M inside the editor to toggle Tab-key focus trapping.
Stuck? Get a hint.
Common mistakes
- Mixing km/h and m/s in the same calculation without converting one of them first, using the 5/18 or 18/5 conversion factor.
- Assuming average speed for a round trip is the simple arithmetic mean of the two speeds, when distances (not times) are equal -- the correct average is the harmonic mean and is always somewhat lower.
- Adding two speeds for objects moving in the same direction instead of subtracting -- addition is only correct for objects moving toward or away from each other.
Knowledge check
Takeaway
Speed problems demand consistent units and the right combining rule -- subtract for same-direction relative speed, add for opposite directions, and use the harmonic mean for equal-distance average speed.
Summary
Speed equals distance divided by time, with km/h and m/s converted via the 5/18 factor. Relative speed subtracts for objects moving the same direction and adds for opposite directions. Average speed over a round trip of equal distances uses the harmonic mean, 2s1s2/(s1+s2), which is always less than the simple average of the two speeds.
Your notes
Notes save automatically.
Finished this lesson?
Mark it complete to track your progress and schedule a future review.
AI tutor
The optional AI tutor isn't enabled in this deployment. All lessons, exercises, quizzes, and search work fully without it.