I fly a lot. Talks, meetings, whatever. I usually prefer an aisle seat, because then the rude guy who smells funny and spreads over 1.8 seats only irritates me on one side, and I’m not wedged up against the window.

However, sometimes I do like to grab a window seat, especially if I’m flying near sunset, or over a particularly interesting landscape (flying over southern Utah near sunset will change your life). But even then, the landscape blows past, and eventually you wind up flying over eastern Colorado, and there’s nothing to see but flat, flat land, extending all the way to the horizon.

And as I gaze over the amber waves of grain to the line that divides land and sky, I sometimes wonder how far away that line is. The horizon is a semi-mythical distance, used in poetry as a metaphor for a philosophical division of some kind. But in fact it’s a real thing, and the distance to it can be determined. All it takes is a little knowledge of geometry, and a diagram to show you the way.

Follow along with me here. We’re going to find the lost horizon.

So you’re standing on the Earth. Let’s assume the Earth is a perfect sphere, because that makes things a lot easier. What does our situation look like? Well, it looks something like this:

In this diagram, the circle is the surface of the Earth, which has a radius of R. The Earth’s radius varies with latitude, but I’ll just use 6365 kilometers as a decent average. The dude standing on the Earth is a human of height h (not to scale, huge duh there). The line-of-sight to the horizon is the red line, labeled d. Finding the value of d is the goal here. Note that the radius of the Earth is a constant, but that d will vary as h goes up or down.

The key thing here is that at the visible horizon, the angle between your line-of-sight and the radius line of the Earth is a right angle (marked in the diagram). That means we have a right triangle, and – reach back into the dim, dusty memory of high school – that means we can use the Pythagorean Theorem to get d. The square of the hypotenuse is equal to the sum of the squares of the other two sides. One side is d, the other is R, and the hypotenuse is the Earth’s radius plus your height above the surface, R+h. This gives us the following algebraic formula:

d2 + R2 = (R+h)2

OK. Now what? Well, let’s expand that last term using FOIL:

(R+h)2 = R2 + h2 + 2Rh

Substitute that back into the first equation to get

d2 + R2 = R2 + 2Rh + h2

Hey, we have a factor of R2 on both sides, so they cancel! That leaves us with:

d2 = h2 + 2Rh

Now, take the square root of both sides, and voila! You get d.

So now we have an equation that tells us how far away the horizon is depending on where we are above the surface. We can use this to put in different values for h, our height, and see how far away the edge of the Earth is. I put this into an Excel spreadsheet, and the numbers are below.

In the table, the first column is your height in meters above the Earth’s surface (really the height of your eyes) and the second column is the horizon distance in kilometers. Columns three and four are the same, but in feet and miles for you Amurcans.

Height (meters) Distance (km) Height(feet) Distance (miles) 0 0.0 0.0 0.0 1 3.6 3.3 2.1 2 5.1 6.6 3.0 3 6.2 9.8 3.7 4 7.1 13.1 4.3 5 8.0 16.4 4.8 6 8.7 19.7 5.2 7 9.4 23.0 5.7 8 10.1 26.2 6.1 9 10.7 29.5 6.4 10 11.3 32.8 6.8 20 16.0 65.6 9.6 30 19.5 98.4 11.7 40 22.6 131.2 13.5 50 25.2 164.0 15.1 60 27.6 196.8 16.6 70 29.9 229.6 17.9 80 31.9 262.4 19.2 90 33.9 295.2 20.3 100 35.7 328.0 21.4 1000 112.8 3280.0 67.7 2000 159.6 6560.0 95.7 5000 252.3 16,400.0 151.4 10,000 356.9 32,800.0 214.2 12,000 391.0 39,360.0 234.6 100,000 1,132.7 328,000.0 679.6 500,000 2,572.0 1,640,000.0 1543.2 1,000,000,000 1,006,344.9 3,280,000,000.0 603,806.9

Sanity check: if you are 0 meters off the surface of the Earth (lying down really really flat), the horizon is 0 kilometers away. That makes sense – you’re tangent to the surface! So the first line sounds right.

Now imagine you are standing on a beach, looking out over the ocean to the horizon. Most people aren’t two meters tall, and your eyes are several centimeters below the top of your head. But let’s just say your eyes are two meters off the ground (maybe you’re standing on a small sand dune). In that case, your horizon is 5.1 km (3 miles) away. That also sounds about right to me.

But now let’s say you are in your hotel overlooking the beach, and on your floor your eyes are 20 meters off the ground. The horizon is then 16 km away, much farther than before. Good: the higher you are, the farther away the horizon should be.

What if you’re a lot higher up, like in an airplane? At a cruising altitude of 39,000 feet (12,000 meters; typical for a cross-country flight) the horizon is 391 km (235 miles) away! That’s a surprisingly long way; in general that means you could be looking across one or more states in the US. This commonly fools me; seeing something even a little bit out from directly underneath the plane means it’s miles away.

What if you go up even higher? The Space Shuttle can reach a maximum height of about 500 km (actually a little more, but close enough). That’s 500,000 meters, or the second-to-last line of the table. For them, the horizon is almost 2600 km away! That means they can see almost the entire US by looking from one side of the Shuttle to the other. Cool.

And what if you’re really far away? From an infinite distance, you should see the horizon as being one Earth radius farther away than your height (draw a diagram if you want). In reality that’s impossible, so in the last line I put our poor observer floating in space one million kilometers away (more than twice the distance to the Moon). The horizon is then 1,006,344 km away, which is just about (but not quite) the Earth’s radius plus the observer’s distance over the surface. They are seeing almost – but not quite – half the Earth all at once.

So there you go. The next time you’re on a beach, or the next time you’re flying, take a look out to the horizon. Like the end of a rainbow, it’s impossible to reach. But it’s not impossible – it’s not even all that hard – to know how far away it is.