The Math Behind GPS: Trilateration and Coordinate Geometry

Your phone knows where you are to within 3 meters. Here's the exact math it uses — circles, coordinate algebra, and a trick with satellite clocks that's accurate to 20 nanoseconds.

By Petrus Sheya

July 2, 2026 · 6 min read

You're blindfolded in a city. A friend calls and says: "I'm at the Eiffel Tower. You're exactly 3 km from me."

You still don't know where you are. You could be anywhere on a circle of radius 3 km centered on the tower.

Then a second friend calls from Notre Dame: "You're exactly 4 km from me." Now you're at one of two points, the two places where those circles cross.

Then a third call, from the Louvre. One distance. Two circles already ruled out most options. This third circle passes through exactly one of those two intersection points.

That's GPS. Three satellites. Three distances. One location.


One satellite: you're on a circle

When a GPS satellite sends you a signal, your phone measures how long that signal took to arrive. Multiply by the speed of light and you have a distance, rr, from that satellite to you.

But that single distance doesn't pin you down. You could be anywhere at exactly that distance from the satellite — which traces out a perfect circle (or sphere in 3D, but we'll get to that).

One distance measurement from a single satellite places you anywhere on this circle — drag the slider to see the ring of possibilities.

3.0 kmSATELLITEyou could be here
Known3.0 km
Possible positions
Circumference18.8 km

Every point on that circle is an equally valid answer. You'd need more information to narrow it down.


Two satellites: you're at one of two points

Add a second satellite. Now you have a second circle. The two circles overlap at exactly two points (assuming they intersect at all).

Two points sounds much better than infinitely many, but it's still ambiguous. One of those two intersection points is usually underground or wildly implausible, so in practice you can often guess which one is right. But "probably" isn't good enough for navigation.

We need a third.


Three satellites: exactly one point

A third satellite gives a third circle. And here's the key geometric fact: three circles in general position intersect at exactly one point.

Drag the receiver anywhere — all three distance circles always intersect at exactly one point.

SAT ASAT BSAT CYOU
d(SAT A)4.19
d(SAT B)3.40
d(SAT C)3.44
Position(5.50, 5.20)

Drag the receiver anywhere on the map. All three circles always pass through exactly that one point — because we defined each radius as the distance from that satellite to you. This is what GPS does in reverse: it measures three distances and finds the one point where all three circles meet.

This technique is called trilateration. It's different from triangulation, which uses angles. GPS uses distances.


The math: solving the intersection

Here's where coordinate algebra comes in. Let the three satellites be at positions (x1,y1)(x_1, y_1), (x2,y2)(x_2, y_2), (x3,y3)(x_3, y_3), with measured distances r1r_1, r2r_2, r3r_3.

Each satellite gives us one circle equation:

(xx1)2+(yy1)2=r12(x - x_1)^2 + (y - y_1)^2 = r_1^2 (xx2)2+(yy2)2=r22(x - x_2)^2 + (y - y_2)^2 = r_2^2 (xx3)2+(yy3)2=r32(x - x_3)^2 + (y - y_3)^2 = r_3^2

Each of these is non-linear — they have x2x^2 and y2y^2 terms, which makes them hard to solve directly. But here's a trick: subtract the first equation from the second.

The x2x^2 and y2y^2 terms cancel, leaving something linear in xx and yy:

2(x2x1)x+2(y2y1)y=r12r22+x22x12+y22y122(x_2 - x_1)\,x + 2(y_2 - y_1)\,y = r_1^2 - r_2^2 + x_2^2 - x_1^2 + y_2^2 - y_1^2

Do the same with the first and third equations. Now you have two linear equations in two unknowns. That's just a 2×2 system, solvable in a few algebraic steps.

We write it in matrix form and use Cramer's rule:

[2(x2x1)2(y2y1)2(x3x1)2(y3y1)][xy]=[C1C2]\begin{bmatrix} 2(x_2-x_1) & 2(y_2-y_1) \\ 2(x_3-x_1) & 2(y_3-y_1) \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} C_1 \\ C_2 \end{bmatrix}

where C1=r12r22+x22x12+y22y12C_1 = r_1^2 - r_2^2 + x_2^2 - x_1^2 + y_2^2 - y_1^2 and similarly for C2C_2.

Solving gives you (x,y)(x, y) — your exact position.

The non-linear problem became linear the moment we subtracted equations. That's the core algebraic insight the whole system rests on.


The clock problem

GPS seems simple so far. But there's a catch that almost breaks the whole idea.

Your phone measures the travel time of the satellite signal. To do that, it needs to know exactly when the signal was sent. The satellite has an atomic clock, accurate to about 20 nanoseconds. That's fine.

But your phone has a cheap quartz clock. Quartz clocks drift by microseconds per second, sometimes more. And because the signal travels at the speed of light, c3×108c \approx 3 \times 10^8 m/s, even a tiny timing error causes a huge range error.

Δr=cΔt\Delta r = c \cdot \Delta t

At 11 microsecond of error: Δr=3×108×106=300\Delta r = 3 \times 10^8 \times 10^{-6} = 300 meters. At 100100 microseconds: 3030 kilometers.

Light travels 300 m per microsecond. A tiny clock error shifts Satellite A's circle — and the GPS fix drifts with it.

SAT ASAT BSAT CTRUE
Range error (SAT A)0.0 km
Position error0 m
Real GPS clock~20 ns

Slide the clock error up. Watch Satellite A's circle shift outward. The other two circles don't move — their measurements are still correct. But the three-circle intersection drifts away from the true position.

This is why GPS needs atomic clocks. But it also means your phone needs a way to correct its own clock error — and it does.


The fourth satellite solves the clock

Here's the elegant fix: add a fourth satellite. Now you have four distance measurements and four unknowns: xx, yy, zz (your 3D position), and Δt\Delta t (your receiver's clock error).

Four equations. Four unknowns. Solvable.

The receiver solves all four simultaneously, effectively calibrating its own clock against the satellite network on every fix. The atomic clocks stay on the satellites. Your phone gets atomic-clock-level accuracy for free, every time it calculates a position.

That's why civilian GPS is accurate to 3-10 meters, not 300 meters. The fourth satellite isn't just for redundancy — it's doing the clock correction.


From circles to spheres

Everything we've done so far was in 2D. In reality, satellites orbit at about 20,200 km altitude, and the Earth is a sphere. Each distance measurement gives you a sphere, not a circle.

Two spheres intersect in a circle. Three spheres intersect in two points. Four spheres intersect in exactly one point — which is why, in 3D, you need four satellites for a complete fix.

GPS satellites orbit continuously. Watch how many are visible above the horizon at any moment — a 3D fix requires at least 4.

horizonbelow horizonEARTHGPS 1GPS 2GPS 3GPS 4GPS 5GPS 6YOU
Visible satellites2 / 6
StatusNO FIX

Hit play and watch the satellites orbit. The ones above the horizon send signals down to the receiver. Below about four visible simultaneously, the fix degrades. That's why GPS struggles in cities with tall buildings blocking the sky, or in deep valleys — not because of any electronic failure, but because of geometry.


The short version

GPS solves a system of simultaneous distance equations. Each satellite contributes one equation: a circle (or sphere) of possible positions. Three circles meet at one point in 2D. Four spheres do the same in 3D. The math reduces to a linear system once you subtract equations pairwise to cancel the quadratic terms. The fourth satellite isn't just for redundancy — it solves for the receiver's clock error simultaneously with position.

The technology in your pocket is computing the intersection of four spheres, 5 to 20 times per second, accurate to within a few meters. And all of it rests on the same coordinate algebra you learned to solve in school.


All visualizations are interactive React components running entirely in your browser. The trilateration solver uses exact algebraic intersection. The orbit animation uses requestAnimationFrame with angular velocity integration. No libraries beyond React.