How To Measure Any Distance With The Pythagorean Theorem

We’ve underestimated the Pythagorean theorem all along. It’s not about triangles; it can apply to any shape. It’s not about a, b and c; it applies to any formula with a squared term.

This is a companion discussion topic for the original entry at

[…] There’s much, much more to this beautiful theorem, such as measuring any distance. Enjoy. Posted October 24, 2007, under Math Tags: area, circle, hypotenuse, intuitive, Math, pythagorean, theorem, triangle Related Posts: […]

Very, very cool post.

I manage a data warehouse and get called in to analyze product data periodically – I see where I might be able to use this to some great effect.

I really need to go back to school and get a degree in statistics – if only school paid as well as data warehousing!

Thanks Bob, glad you liked it. Yes, there are tons of applications – if you have a warehouse full of product data, I’m sure there’s some interesting trends/groupings you’ll be able to pull up :slight_smile:

This post pointed me to a possible issue in the new version of my political simulation game I’m currently developing: I use ideological axes to rate political parties’ positions, and I currently determine their similarity by taking the average difference for each axis. Of course, I need to average the squares of the differences!

Wow, this is very cool. I remember being taught this theorem in 4th grade math, but I never revisited it.

Now that I’m working on some things that could really benefit from collaborative filtering, I’m very happy to have come across this post!

This is just one of any number of distance functions. You might want to look up the others :

Especially manhattan distance is useful. But it is by no means the only one. You describe euclidean distance, you also have manhattan distance, hamming distance, jaccard distance, accoustic metrics, …

Just as oele wrote there are more types of metrics. I’m not saying you should include any of that in this article but some of the things you say are simply not true, due to the fact that there are other metrics. Here’s where it goes wrong :“Measures any type of distance”. You should change this statement or remove it.

Apart from that, a very nice article!

I’m shocked that so many people didn’t know this. This is truly elementary material, and if articles like this need to be written for coders, the education system must be in a very sorry state.

Excellent, I knew all about Pythagoras theorem but I never thought about repeated applications and alternative uses.

Thanks, Andy.

@Wouter, Jesper: Thanks, I hope you have luck in applying it to your area :slight_smile:

@oele: Thanks for the info – that may be a subject of a follow-up article.

@Josef: Thanks for the tip. I can rephrase to mean “provides one way to measure distance”. The key point is that the Pythagorean Theorem can generalize to N dimensions (it isn’t the only such theorem that does so).

@Ddd: Everyone has to start somewhere. And there’s always ways to look at “old” results in a new light.

@Andrew: Glad you liked it!

Ddd said, “I’m shocked that so many people didn’t know this. This is truly elementary material, and if articles like this need to be written for coders, the education system must be in a very sorry state.”

To start a dialog, I think you are confusion a computer science education with that of what coders do now a days. There are many programmers who have not had formal mathematical or computer science education. Therefore, there will be some that don’t have this “basic” skills as you call it.

So the computer science education (at least in some schools) has nothing to do with some people not knowing basic vector algebra. In other words, coders come in different flavours.

Thanks Jose, my thoughts exactly. Everyone starts in a different place: some people are designers who do programming on the side, others are programmers who do design on the side.

For some reason, math topics seem to encourage people to show off how much they know (and this attitude is partially why math isn’t a well-loved subject).

Me, I just like to write about what I find interesting, hoping other people enjoy it too.

Great post. I have used the multi-dimensional distance calculation to estimate similarity between all sorts of things, using different measures. The only thing to be careful about is scaling. The distances (dis-similarities) need to be re-weighted (or normalized), if scales are off.

It yields really interesting results.

vectors and matrices are good tools for studying the evolution of human behavior, see

@Matt: Thanks, glad you liked the post. You’re right, the multi-dimensional distance is a good starting point but needs to be tweaked/scaled appropriately.

@Karl: Thanks for the tip – there’s so many interesting uses.

[…] Math is beautiful This was just a very interesting read. I’ve always believed that math is more interesting than people give it credit for. Falling math standards are more due to bad teaching than the difficulty of the subject. […]

I was in a math class a few years ago where we proved the Pythagorean theorem multiple times in multiple ways. It was incredible to see how it works and why it works. I love the fact that math can be both incredibly complex and extremely simple all at the same moment.

I literally stumbled onto this post using StumbleUpon and think this is very cool. Like Bob I also work in Datawarehousing and on reading this post realised this concept could easily be applied to RFM (Recency, Frequency, Monetary) measures to identify groups for targeted marketing campaigns. Thanks.

Great article ! Thanks to share your knowledge.