The idea: distances to known points pin you down
Each GPS satellite knows exactly where it is and what time it is, and it keeps sending both. A receiver that knows how long a signal took to arrive knows how far away that satellite is: distance = travel time × the speed of light c. One distance puts the receiver somewhere on a circle around the satellite (a sphere in real 3D). Two circles cross at two points. A third circle picks one of them. Finding a point from distances is trilateration. It measures no angles, so it is not triangulation.
The canvas uses a flat 24 km × 16 km toy world, so everything is a circle you can see. The receiver (black dot) is at (10, 6) km. The solver does not know that: it only has the satellite positions and the measured ranges in the table.
Pseudoranges: the receiver's clock is wrong
Satellites carry atomic clocks. A phone or a car receiver has a cheap quartz clock that can be off by milliseconds. The receiver reads the arrival time on its own clock, so if that clock is b ahead, every travel time looks b too long. Every measured range is then too long by the same amount c·b. Such a range is a pseudorange:
Light goes 299.8 m in one microsecond. So a clock only 1 µs off, a millionth of a second, moves every range by about 300 m (Demo 2: the three crossings near the receiver no longer coincide; two circles that cross at a shallow angle push them up to 1.8 km apart). At 10 µs it is 3 km, and the circles overlap widely instead of meeting.
One more satellite than dimensions
Nobody can fix the receiver's clock in advance, so GPS does not try. It treats b as one more unknown. In 3D that makes four unknowns, x, y, z and b, so a receiver needs at least four satellites. In the flat world of the canvas it is three unknowns (x, y, b) and three satellites are enough (Demo 3). A nice side effect: once b is known, the cheap receiver knows the time almost as well as the satellites' atomic clocks.
What happens if the receiver ignores b? Then no point fits ranges that are all 3 km too long. The best compromise lands about 5.2 km from the truth, and the residual stays near 2 km (Demo 4).
Solving it: guess, linearize, repeat
The equations have square roots in them, so there is no simple formula. The receiver uses Gauss–Newton:
- Start from a guess: here the middle of the map (12, 8) km and b = 0.
- Predict each range from the guess and compute the residual: measured ρ minus predicted.
- Near the guess, a small move Δ changes satellite i's predicted range by (minus the unit vector towards it)·Δ, plus the change in c·b. That gives one row per satellite of a matrix H: (−uₓ, −u_y, 1).
- Solve the small least-squares system HᵀH·Δ = Hᵀ·residuals, move the guess by Δ, and repeat until the step is tiny (here under 1 m).
From 2.8 km away it converges in 3 steps: the residual falls from 3.8 km to 265 m, then 3.7 m, then zero. A 4th step moves less than 1 m, so the solver stops (Demo 3). Real receivers start from their last fix, so one or two steps are usually enough. With four or more satellites there are more equations than unknowns, and the same step gives the least-squares answer: the point whose ranges fit best overall.
Geometry: dilution of precision
Real ranges carry errors of a few metres (satellite orbit and clock, the ionosphere, signals bouncing off buildings). The canvas uses errors of up to ±300 m so you can see them. How much they move the answer depends on where the satellites are. Each range is really a band, not a thin circle. Bands that cross at a wide angle overlap in a small patch; bands that cross at a narrow angle overlap in a long sliver.
The number for this is the dilution of precision. From the same H matrix, Q = (HᵀH)⁻¹; then HDOP = √(Q₁₁ + Q₂₂) for the horizontal position and TDOP = √Q₃₃ for the clock. Position error ≈ DOP × range error, roughly.
| Demo | Satellites | HDOP | Clock found | Position error |
|---|---|---|---|---|
| 5 | 4, spread around the receiver | 1.03 | 0.957 µs (true 1) | 343 m |
| 6 | 4, bunched on one side | 4.33 | 9.209 µs (true 1) | 2790 m |
With all satellites on one side, moving the receiver towards them shortens every range by about the same amount, which looks just like a clock error. The solver cannot tell the two apart, so the clock estimate and the position are both far off. This is why GPS height is worse than horizontal position: all satellites are above you, none below.
See also NTP for setting a clock over a network instead of from satellites, Cellular Reuse and Handover for how signal strength falls with distance, and Linear Regression and Least Squares for the least-squares fit inside every Gauss–Newton step. Newton's Method shows the same guess-and-linearize idea in one dimension.
What the page leaves out
- Real 3D geometry: satellites 20 200 km up on six orbit planes, spheres instead of circles, and the Earth's rotation during the signal's flight (the Sagnac correction).
- How the time of flight is measured: the C/A code, correlation, and the navigation message with the orbit (ephemeris) and satellite clock corrections.
- Relativity: satellite clocks run about 38 µs per day fast and are corrected for it (see Special Relativity).
- Ionosphere and troposphere delay models, dual-frequency receivers, differential GPS and RTK carrier phase (centimetres), weighting the satellites by their error, and filtering over time (Kalman Filter).