# Time 10, Exercise 3: GPS as a clock, with a toy one-dimensional version c = 299792458 # speed of light in metres per second # Part 1: what does a clock error cost in distance? for label, t in (("1 microsecond", 1e-6), ("1 nanosecond", 1e-9), ("1 millisecond", 1e-3)): print(label, "of timing error =", round(c * t, 3), "m") # Part 2: signal travel time from a satellite directly overhead at 20,200 km. height = 20200e3 print("travel time from 20,200 km:", round(height / c, 4), "s") # Part 3: toy 1D GPS. Satellites A and B sit at 0 and 40,000 km on a line. # The receiver's cheap clock has an unknown error b, which adds to BOTH measured times. length = 40000e3 true_x = 12000e3 # the receiver is really 12,000 km from A bias = 0.003 # the receiver clock runs 3 ms fast (unknown to it) t_a = true_x / c + bias # what the receiver measures for A t_b = (length - true_x) / c + bias # what the receiver measures for B print("measured times:", round(t_a, 5), "s and", round(t_b, 5), "s") print("naive distance from A:", round(c * t_a / 1e3), "km (wrong)") # t_a + t_b = length / c + 2 * bias, so the bias can be solved for. found_bias = (t_a + t_b - length / c) / 2 found_x = c * (t_a - found_bias) print("solved clock error:", round(found_bias, 6), "s") print("solved position:", round(found_x / 1e3), "km from A") # Output when run: # 1 microsecond of timing error = 299.792 m # 1 nanosecond of timing error = 0.3 m # 1 millisecond of timing error = 299792.458 m # travel time from 20,200 km: 0.0674 s # measured times: 0.04303 s and 0.0964 s # naive distance from A: 12899 km (wrong) # solved clock error: 0.003 s # solved position: 12000 km from A # Reading the output: a receiver clock only 1 microsecond wrong would put you 300 m out, and # 3 ms wrong puts the naive answer about 900 km out (12,899 against 12,000). Using one extra # satellite lets the receiver solve for its own clock error as well as its position. Real # GPS works in three dimensions, so it needs four satellites: three for position, one for time.