This is a debate I keep getting into with all sorts of people. No matter how well I try explaining it people simply do not want to believe me they're thinking about distance all wrong.
After last weekend's trek around a very sunny city where I was forced to keep walking in the blistering noon sun, just because "It's closer!" and my sister is a naggy teenager and gets her way, I've decided to write this post wherein I explain once and for all the difference between intuitive distance and real-world distance.
First let's talk a little bit about how all of us think of optimizing our paths for distance.
You've probably noticed bits of grass so destroyed around the corners of walkways in parks that eventually the walkways are just expanded with rounded corners. Some architects are even so smart as to design them this way in the first place!
This is due to how right triangles work. The rule is basically that for any right triangle the length of the hypotenuse will necessarily be shorter than the sum of its catheti.
You can quickly check this is true with the first pythagorean triplet (3,4,5). Obviosly 5 is less than 3+4. Far from a rigorous proof, but the idea isn't stupid.
This is something that comes very intuitively to us. See a right triangle and choose to walk diagonally, it's simply shorter that way.
It's even more obvious when you think about it in terms of distance traveled versus displacement. The shortest path to take between two points will always be one that best fits displacement.
All of this comes crashing to a halt in large american cities. Those tend to be laid out in a grid, and prevent us from traveling over proper diagonals. Instead we follow diagonals to our best abilities alongside a grid.
Herman Minkowski stipulated in the 19th century that because of this constraint, the distance traveled diagonally is no different than the distance traveled on any other gridded path with the same displacement.
By looking at the sketch, I think we can all agree with Minkowski.
But taxicab geometry only works in the US and other cities laid out in a grid, I haven't really seen many of them. So maybe in Europe our intuition still works?
Everything becomes much more interesting once we start thinking of distance as a parameter of the function of cost.
Imagine you have to travel across a city. You can take a very short path through the streets. This path runs on smaller roads, which have a lot of crossroads, many red lights, people waiting to turn left and so on. Another path, a much longer one, runs mostly on larger roads where you have fewer stop lights and everyone waiting to turn left is ushered into their own lane.
Which path do you take?
It's probably obvious, but I've been in plenty of fights for taking the longer route.
The whole problem boils down to something computer scientists and probably most mathematicians call graph traversal and finding the shortest path through a graph.
Basically it goes like this: You have a set of nodes connected with edges. Each edge has a number assigned to it. Find the path from node A to node B with the smallest total sum of traversed edges.
That number is completely abstract, it can mean distance or can be a function of many parameters telling you how costly it is to travel alongside that edge; it essentially doesn't matter, whatever you want to optimize for, that's how you define the function.
When walking I like to account for amount of sunlight ... especially in the summer.
There are many ways to approach solving this problem, but the algorithm Dijkstra came up with seems to work the best in most cases.
To illustrate my point, look at the pretty picture I've drawn on my whiteboard. Imagine this is a map of a few streets - geometric distance accounts for our intuitive understanding of distance. The cost I've chosen to optimize for is time.
Point proven? Or at least shown? Can I just send this link every time I get into this discussion?
But the most interesting bit, I think, is how a lot of people think like this in a car. Why not on foot? Or on a bike? What makes those ways of traveling so much different that suddenly physical distance traveled is the only factor we think about? No matter how many things I have to climb over, I will fucking walk the shortest path!
PS: another interesting example is the Mythbusters Waterslide Wipeout episode, where they show a mail truck doing only right turns (in the US) saves fuel despite traveling a much greater physical distance.
- Fast Pathfinding via Symmetry Breaking (harablog.wordpress.com)
- Do complex numbers really exist? (math.stackexchange.com)
- Our brain fails to map high distances (news.bioscholar.com)
- Innate Euclidean geometry. (mindblog.dericbownds.net)
Here's how it works 👇
Then get thoughtful letters 💌 on mindsets, tactics, and technical skills for your career.
"Man, love your simple writing! Yours is the only email I open from marketers and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"
Ready to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz components your whole team can understand with React for Data Visualization
Curious about Serverless and the modern backend? Check out Serverless Handbook, modern backend for the frontend engineer.
Ready to learn how it all fits together and build a modern webapp from scratch? Learn how to launch a webapp and make your first 💰 on the side with ServerlessReact.Dev
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️