Pythagorean Theorem – BetterExplained https://betterexplained.com Math lessons that click Fri, 19 Aug 2022 19:18:03 +0000 en-US hourly 1 Pythagorean Theorem As Sweeping Area https://betterexplained.com/articles/pythagorean-sweep/ https://betterexplained.com/articles/pythagorean-sweep/#respond Thu, 20 Jun 2019 04:12:36 +0000 https://betterexplained.com/?p=12213 The Pythagorean Theorem is often taken as a fact about right triangles.

Let's try a broader interpretation: The Pythagorean Theorem explains how 2D area can be combined.

Here's what I mean. Suppose we have two lines lying around (the creatively named Line A and Line B). We can spin them to create area:

sweep-line

Ok, fun enough. Where's the mystery?

Well, what happens if we combine the line segments before spinning them?

sweep-combined-line

Whoa. The area swept out seems to change. Should simply moving the lines, not lengthening them, change the area?

Running The Numbers

Eyeballing the diagram above, it sure seems like the area grew. Let's work out the specifics.

As an example, suppose $a = 6$ and $b = 8$. When they're swept into circles ($\text{area} = \pi r^2$) we get:

\displaystyle{\text{Circle A} = \pi a^2 = \pi (6^2) = 36 \pi}

\displaystyle{\text{Circle B} = \pi b^2 = \pi (8^2) = 64 \pi  }

For a total of $36\pi + 64\pi = 100\pi$.

The combined segment has length $c = a + b = 14$, and when we spin it we get:

\displaystyle{\text{Circle C} = \pi c^2 = \pi (14^2) = 196 \pi }

Uh oh. That's way more area than before.

The Problem

What happened? Well, Circle A didn't change. But Circle B is much less than Ring B (just look at it!).

The issue: When Line B spins on its own, it can only reach 8 units out as it sweeps. When we attach Line B to Line A, it reaches out 6 + 8 = 14 units. Now the circular sweep covers more area, meaning Circle B is smaller than Ring B.

sweep-when-parallel

Mathematically, here's what happened.

\displaystyle{\underbrace{[a + b]^2}_{\text{Circle C}} = \underbrace{a^2}_{\text{Circle A}} + \underbrace{2ab + b^2}_{\text{Ring B}} > \underbrace{a^2}_{\text{Circle A}} + \underbrace{b^2}_{\text{Circle B}}}

Ignore $\pi$ for a moment since it's a common term. When expanding $c^2 = (a + b)^2 = a^2 + 2ab + b^2$, there's a new $2ab$ term that has to go somewhere. Because Circle A doesn't change, this extra area must appear in Ring B.

Making Things Line Up

It... sort of makes sense that the area changes, but I don't like it. Just moving things around shouldn't have this effect! Can the area ever be the same?

Sure, if we remove the $2ab$ term. The easy fix is to set $a=0$, but that's cheating and you know it.

Let's find a clever solution. Intuitively, the question is: How can Line A's length not help Line B as it spins?

Tilt it! As we rotate Line B, there's less benefit from Line A's length. Ladders are useless when lying on the floor, right?

sweep-when-parallel

When we go Full Perpendicular™, the $2ab$ term disappears and Circle B = Ring B. (In vector terms, the dot product is zero: $a \cdot b = 0$).

Ah -- that's the meaning of the Pythagorean Theorem. When line segments are perpendicular, the same area is swept whether the lines are combined or separated.

Checking The Math

It's not a bad idea to make sure the numbers line up.

Since the segments are now perpendicular, we know $c^2 = a^2 + b^2$, so:

\displaystyle{\text{Full distance} = c = \sqrt{a^2 + b^2}}

\displaystyle{\text{Width of ring} = \text{c - a} = \sqrt{a^2 + b^2} - a}

Now we can calculate:

\displaystyle{\text{Ring B} = \text{Circle C} - \text{Circle A} = \pi c^2 - \pi a^2 = \pi (a^2 + b^2) - \pi a^2 = \pi b^2 = \text{Circle B}}

Tada! The Ring and Circle sweep the same area.

In our example, we have Circle A = $36\pi$, Circle B = $64 \pi$, $c = \sqrt{36 + 64} = 10$. The ring width is $10 - 6 = 4$.

Summary

The Pythagorean Theorem is about more than triangles. When components are perpendicular, the area they make is independent of how they are arranged.

Appendix: Assorted Thoughts

  • The Law of Cosines explicitly shows the $2ab$ term which assumed to be zero in the Pythagorean Theorem. The area of Ring B can even be "negative" if we tilt Line B to point inside.
  • We can combine area from multiple dimensions ($x^2 + y^2 + z^2 + ...$). As long as they are mutually perpendicular, the area swept by each dimension is the area swept by the total.
  • The Pythagorean Theorem is a relationship in the 2D area domain ($c^2 = a^2 + b^2$). We start here and convert this to a relationship in the 1D domain ($c = \sqrt{a^2 + b^2}$). The conversion happens so often we forget where it began.
  • More on sweeping area: https://www.cut-the-knot.org/Curriculum/Geometry/PythFromRing.shtml

Happy math.

]]>
https://betterexplained.com/articles/pythagorean-sweep/feed/ 0
Understanding Pythagorean Distance and the Gradient https://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/ https://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/#comments Fri, 04 Nov 2011 16:24:48 +0000 http://betterexplained.com/?p=1460 The Pythagorean Theorem shows how strange our concept of distance is. Using the rule $a^2 + b^2 = c^2$, we can trade some "a" to get more "b".

Starting with

\displaystyle{13^2 + 0^2 = 13^2}

means "A 13-inch pizza equals a 13-inch pizza". Sure. But we can trade an inch and get:

\displaystyle{12^2 + 5^2 = 13^2}

Huh? A 12-inch pizza and a 5-inch pizza equal a 13-inch pizza?

The math works (144 + 25 = 169) but, but... we gave up an inch and got a five-inch pizza!

Let's understand why the tradeoff happens, and how to use it.

Explanation 1: Shaving the Square

A key insight: Bigger numbers are harder to square.

Shaving the Square

Imagine laying tiles on a porch -- as your porch grows, the outer layer needs more tiles. Trimming a 13x13 porch to 12x12 frees up 25 tiles, which is enough to make a new 5x5 porch!

I call this "shaving the square". Trimming 1 unit from the outside of a large square has more "shavings" which can contribute to a smaller one (trimming an inch from a giant fro can make a sweater for an infant). As we continue to trim, the benefit diminishes because our starting point is smaller and smaller.

Explanation 2: Sliding the Chopstick

A second insight: Slide a little, pivot a lot.

Imagine a chopstick wedged in a corner: the length is fixed, and the ends of the chopstick must touch a wall. What're the options?

Well, laying on a single wall means 100% for one side (like saying $13^2 + 0^2 = 13^2$). Not that interesting.

By sliding the chopstick (from 13 to 12) we can swing it out by 5 on the other wall!

pythagorean theorem slide sides

You need to try it -- a small slide gives a giant pivot. As we keep sliding, the tradeoff (How much pivot do we get?) changes.

So What's the Tradeoff?

Time to see how the a/b tradeoff works. First, let's use grid coordinates: x & y (horizontal and vertical). Given a fixed distance (13 units, let's say), our options lay on the circle where $x^2 + y^2 = 13^2$:

pythagorean theorem X-Y tradeoff

A few points:

  • Each possibility is the same distance, but has a different ratio of x to y (100% x, 100% y, or a mix like (12,5))
  • We can only move to neighboring points on the circle (options at the same distance)
  • The tradeoff we face is how much "x" we get for "y" when moving to a neighbor. If we're at (0, 13) we could move to (5, 12). This trades 1 y for 5 x's.

This is the "chunky" tradeoff where we're using an entire unit at a time. What about .5 units? .01?

Enter the tangent! The tangent line shows the trajectory of our current path, the direction to our neighbor. We follow the tangent for a tiny, microscopic amount to get our next neighbor. The tangent is an approximation -- it's not pointing exactly at our nearest neighbor, but it's pretty close.

The tangent shows the tradeoff you are about to make.

What's the actual amount? Any point (x,y) has a slope of y/x, and a tangent line with slope -x/y, so the tradeoff is...getting confused yet?

Less mindless algebra, more intuition:

  • Circles have a tangent line perpendicular to the current point
  • If you're at (5,12) then tangent slope is some ratio of 5 and 12
  • Remember "shaving the square": you get a better deal in the direction of the smaller coordinate (increasing a large square is tough).
  • So, at (5, 12) you're "heavy on the y" and the trade will favor improving your x: it should be "trade 5 y's for 12 x's". And why not the other way? It doesn't make sense that the more y you have, the easier it is to get y! That'd spiral off into exponential growth, not a circle.
  • Lastly, we can't trade an entire chunk of 5 y's! The tangent is about our nearest neighbor. We have a trade of 12/5 or 2.4 to 1. Our next, tiny movement will be at this ratio (and then we'll be at a new point, with a new tangent).

General principle: Our neighbors are on a circle, which encourages balance. You get a better deal in the direction of the smaller coordinate: at (x,y) the tradeoff is y:x.

Optimizing The Tradeoff

Now we know the tradeoff for any point (x,y) -- let's optimize!

In a boring scenario, we get paid based on pure distance, so every point (or direction to move) is the same.

The exciting scenario: our (x,y) position is an input into some other function which gives us a return! Now we want to maximize that function.

Here's a scenario: Popeye throws cars for cash. He lines up spectators on fences running North and East. The spectators must look straight ahead (they're in neck braces, due to earlier events) but will pay Popeye if they see a car pass in front of them.

Popeye's show

Maximizing Even Payouts

Suppose each spectator offers \$1 if they see the car (Payout (x,y) = x + y). Where to throw?

First, assume Popeye has finite energy -- he can throw the car 13 meters. Now let's start somewhere: throwing the car pure North (0, 13):

\displaystyle{P(0,13) = 0 + 13 = 13}

Ok. What if he threw it slightly East? To (5, 12) let's say?

\displaystyle{P(5,12) = 5 + 12 = 17}

Clearly better. This should make sense: at (0,13) the tradeoff is great to get more East. We can give up 1 North and get a whopping 5 East, a "profit" of \$4 if we do the trade. We should keep trading as long as it's profitable -- as long as we're out of balance, the circle will reward us for boosting the smaller side. Following a 45 degree angle for 13 units is the ideal:

\displaystyle{P(13 \cdot \frac{1}{\sqrt{2}}, 13 \cdot \frac{1}{\sqrt{2}}) = P(13 \cdot .707, 13 \cdot .707) = 9.2 + 9.2 = 18.4}

Neat. A 45-degree throw hits 70.7% of the possible spectators for each side.

Psst. Confused about how a 45-degree through passes by 70.7% of the spectators on each side? No problem.

A 45-degree throw is along the diagonal of a square. A triangle with sides 1 and 1 has a hypotenuse of:

\displaystyle{\sqrt{1^2 + 1^2} = \sqrt{2} = 1.414}

And has sides $(1, 1, 1.414)$.

A hypotenuse of $\sqrt{2}$ isn't convenient: it's hard to know what fraction a side is of the whole. We divide the triangle by the length of the hypotenuse ($\sqrt{2}$), making the hypotenuse 1 and the other sides a percentage:

\displaystyle{\text{Triangle with sides} = (\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}, \frac{\sqrt{2}}{\sqrt{2}}) = (.707, .707, 1)}

Now we've discovered that a 45-degree throw, with sides $(1, 1, \sqrt{2})$, has the ratio $.707, .707, 1$. 70.7% of the distance along the hypotenuse shows up on each side.

General Technique: Finding the Best Direction

We stumbled upon the way to find the best return:

  • Pick any starting point / direction
  • Tweak it: if our return improves, keep the new choice (it's profitable)
  • Keep tweaking until our return is no longer profitable

In math slang, this is "finding the local maximum". In economics slang, it's finding the point of "zero marginal returns". Popeye calls it Squeezing the Spinach.

Maximizing Uneven Returns

Now suppose the Northern spectators offer \$2 (Eastern stay at \$1), so P(x,y) = x + 2*y. Should we throw it 100% North?

\displaystyle{ P(0, 13) = 0 + 2 \cdot 13 = 26 }

Not bad. But what about 45 degrees again?

\displaystyle{P(9.2, 9.2) = 9.2 + 2 \cdot 9.2 = 27.6 }

Interesting -- 45 degrees is still better! But... I think we went too far! Shouldn't we favor North since it pays more?

Yep. Let's remember how to Squeeze the Spinach (maximize our returns): start with North and change until it's not profitable:

  • The payout function means 1 North = 2 Easts (North pays \$2, so 1 unit North = 2 units East)
  • Trades are profitable if we can beat 1 North for 2 Easts (1 North for 3 Easts, for example, would profit \$1)

So... where are trades better than 1 North for 2 Easts? In the Northern section, where the circle rewards us by throwing Easts at us ("Please, please go East... I'll give you a bunch if you give up a little North").

Remember how circles are about x/y, x & y, x:y, etc.? Well, we have the numbers 1 and 2. (2,1) is in the East section. We want (1,2). Why? At (1,2) we have reached the perfect 1 North = 2 East tradeoff.

Following the direction (1,2) for 13 units is:

\displaystyle{P(13 \cdot \frac{1}{\sqrt{5}}, 13 \cdot \frac{2}{\sqrt{5}}) = P(5.81, 11.62) = 5.81 + 2 \cdot 11.62 = 29.05 }

Tada! Over 29 smackeroos because we maximized our return.

The Gradient Principle

We can supercharge this result:

To maximize return, go in each direction proportional to its payoff.

If North pays 2:1 compared to East, your trajectory should favor North by 2:1. In mathier terms:

  • Payoff(x,y) = ax + by
  • Best trajectory = (a, b) [in our case, (East, North) => (1, 2)]

And this works in multiple dimensions! Given 3 dimensions, go in a direction (Payoff(x), Payoff(y), Payoff(z)). Vector calculus fans, this is why the gradient is in the direction of greatest increase.

The gradient for $F(x,y,z)$ is

\displaystyle{(\frac{dF}{dx},\frac{dF}{dy},\frac{dF}{dz})}

And each partial derivative (dF/dx) is the payoff for moving in that direction.

But does it all balance? Suppose x pays 3, y pays 4, and z pays 5 (at the current position). The 2-dimensional tradeoff trajectories are:

\displaystyle{ (x, y) = (3,4) } \displaystyle{ (y, z) = (4, 5) } \displaystyle{ (x, z) = (3, 5) }

Now for the magic: the combined trajectory

\displaystyle{(x,y,z) = (3,4,5)}

satisfies all 3 requirements! On the x-z plane, x doesn't care about y -- as long as the ratio to z is (3 , ?, 5) you're getting the best tradeoff from the x-z perspective. The pairs are:

  • (3, ?, 5)
  • (?, 4, 5)
  • (3, 4, ?)

You don't need a sudoku master to see (3, 4, 5) satisfies all those proportions.

Still not convinced? Imagine the payoff for y was zero. We don't want to waste energy in our trajectory (3, ?, 5) in a useless direction. But that can't happen, because the y-z tradeoff will be (?, 0, 5) and the x-y tradeoff will be (3, 0, ?). The x-z tradeoff lets y-z and x-y "figure out" what y should be, which is 0.

Questions I Had That You Might Have Too

Q: I still don't get why this works at all. Somehow 50% in x and 50% in y leads to .7 + .7 = 1.4?

It's a deep question about why space behaves like this. I was going crazy staring at chopsticks on a wall.

Here's my answer: distance is distance. 13 units is 13 units. But in some situations we are "measuring our coordinates" (what are the values of x & y) and not the distance itself.

Cartesian coordinates (x-axis, y-axis) are very inefficient for diagonal motion (i.e., you are measuring the sides of the triangle, not the hypotenuse). When $.707^2 + .707^2 = 1$, it's a measure how how "inefficient" our x & y coordinates are being. We used 70% of each coordinate to represent an object that could have been 100% on one (i.e, if we used polar coordinates).

Q: I have an offshore investment with 200% return, and an onshore one with 5% return. I have \$1000 to spend -- should I split my money?

Heavens, no! Remember, this principle is about distance measurements on a grid with the idea that 50% in x and 50% in y covers "more ground" than 100% in x. In investing 1) money is not on a grid and 2) there's no distance bonus. Putting half your money in each is plain old 0.5 + 0.5 = 1.0. Giving up \$1 of the offshore investment gives you \$1 for the onshore one.

Put all your money in the best investment.

Q: So all this stuff is useless?

Heavens, no! Ask yourself: am I measuring distance on a coordinate system?

Many things are measured in terms of x-y coordinates (physical phenomena, etc.) and do have the Pythagorean distance tradeoff.

But not every graph is the same. Graphs that aren't about distance (like "Money vs. Time") do not get any boost from the Pythagorean theorem. This confused me for a long time: the Pythagorean Theorem works for coordinate distance!

Final Thoughts

The Pythagorean Theorem is so versatile -- it's not about triangles, it covers the nature of distance. I seem to find some new realization when I study it. Really grokking it will help you everywhere, from geometry to vector calculus.

Happy math.

]]>
https://betterexplained.com/articles/understanding-pythagorean-distance-and-the-gradient/feed/ 25
How To Measure Any Distance With The Pythagorean Theorem https://betterexplained.com/articles/measure-any-distance-with-the-pythagorean-theorem/ https://betterexplained.com/articles/measure-any-distance-with-the-pythagorean-theorem/#comments Mon, 05 Nov 2007 08:23:13 +0000 http://betterexplained.com/articles/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.

It’s not about distance in the sense of walking diagonally across a room. It’s about any distance, like the “distance” between our movie preferences or colors.

If it can be measured, it can be compared with the Pythagorean Theorem. Let’s see why.

Understanding The Theorem

We agree the theorem works. In any right triangle:

pythagorean theorem

If a=3 and b=4, then c=5. Easy, right?

Well, a key observation is that a and b are at right angles (notice the little red box). Movement in one direction has no impact on the other.

It’s a bit like North/South vs. East/West. Moving North does not change your East/West direction, and vice-versa — the directions are independent (the geek term is orthogonal).

The Pythagorean Theorem lets you use find the shortest path distance between orthogonal directions. So it’s not really about right triangles — it’s about comparing “things” moving at right angles.

You: If I walk 3 blocks East and 4 blocks North, how far am I from my starting point?

Me: 5 blocks, as the crow flies. Be sure to bring adequate provisions for your journey.

You: Uh, ok.

So what is “c”?

Well, we could think of c as just a number, but that keeps us in boring triangle-land. I like to think of c as a combination of a and b.

But it’s not a simple combination like addition — after all, c doesn’t equal a + b. It’s more a combination of components — the Pythagorean theorem lets us combine orthogonal components in a manner similar to addition. And there’s the magic.

In our example, C is 5 blocks of “distance”. But it’s more than that: it contains a combination of 3 blocks East and 4 blocks North. Moving along C means you go East and North at the same time. Neat way to think about it, eh?

Chaining the Theorem

Let’s get crazy and chain the theorem together. Take a look at this:

chained pythagorean theorem

Cool, eh? We draw another triangle in red, using c as one of the sides. Since c and d are at right angles (orthogonal!), we get the Pythagorean relation: c2 + d2 = e2.

And when we replace c2 with a2 + b2 we get:

\displaystyle{a^2 + b^2 + d^2 = e^2}

And that’s something: We’ve written e in terms of 3 orthogonal components (a, b and d). Starting to see a pattern?

Put on your 3D Goggles

Think two triangles are strange? Try pulling one out of the paper. Instead of lining the triangles flat, tilt the red one up:

3d pythagorean theorem

It’s the same triangle, just facing a different way. But now we’re in 3d! If we call the sides x, y and z instead of a, b and d we get:

\displaystyle{x^2 + y^2 + z^2 = \text{distance}^2}

Very nice. In math we typically measure the x-coordinate [left/right distance], the y-coordinate [front-back distance], and the z-coordinate [up/down distance]. And now we can find the 3-d distance to a point given its coordinates!

Use Any Number of Dimensions

As you can guess, the Pythagorean Theorem generalizes to any number of dimensions. That is, you can chain a bunch of triangles together and tally up the “outside” sections:

pythagorean theorem multiple dimensions

You can imagine that each triangle is in its own dimension. If segments are at right angles, the theorem holds and the math works out.

How Distance Is Computed

The Pythagorean Theorem is the basis for computing distance between two points. Consider two triangles:

  • Triangle with sides (4,3) [blue]
  • Triangle with sides (8,5) [pink]

distance example

What’s the distance from the tip of the blue triangle [at coordinates (4,3)] to the tip of the red triangle [at coordinates (8,5)]? Well, we can create a virtual triangle between the endpoints by subtracting corresponding sides. The hypotenuse of the virtual triangle is the distance between points:

  • Distance: $(8-4, 5-3) = (4,2) = \sqrt{4^2 + 2^2} = \sqrt{20} = 4.47$

Cool, eh? In 3D, we can find the distance between points $(x_1,y_1,z_1)$ and $(x_2,y_2,z_2)$ using the same approach:

\displaystyle{\text{distance}^2 = (x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}

And it doesn’t matter if one side is bigger than the other, since the difference is squared and will be positive (another great side-effect of the theorem).

How to Use Any Distance

The theorem isn’t limited to our narrow, spatial definition of distance. It can apply to any orthogonal dimensions: space, time, movie tastes, colors, temperatures. In fact, it can apply to any set of numbers (a,b,c,d,e). Let’s take a look.

Measuring User Preferences

Let’s say you do a survey to find movie preferences:

  1. How did you like Rambo? (1-10)
  2. How did you like Bambi? (1-10)
  3. How did you like Seinfeld? (1-10)

How do we compare people’s ratings? Find similar preferences? Pythagoras to the rescue!

If we represent ratings as a "point" (Rambo, Bambi, Seinfeld) we can represent our survey responses like this:

  • Tough Guy: (10, 1, 3)
  • Average Joe: (5, 5, 5)
  • Sensitive Guy: (1, 10, 7)

And using the theorem, we can see how different people are:

  • Tough Guy to Average Joe: $(10 – 5, 1 – 5, 3 – 5) = (5, -4, -2) = \sqrt{(5)^2 + (-4)^2 + (-2)^2} = \sqrt{45} = 6.7$
  • Tough Guy to Sensitive Guy: $(10 – 1, 1 – 10, 3 – 7) = (9, -9, -4) = \sqrt{(9)^2 + (-9)^2 + (-4)^2} = \sqrt{178} = 13.34$

We can compute the results using a2 + b2 + c2 = distance2 version of the theorem. As we suspected, there’s a large gap between the Tough and Sensitive Guy, with Average Joe in the middle. The theorem helps us quantify this distance and do interesting things like cluster similar results.

This technique can be used to rate Netflix movie preferences and other types of collaborative filtering where you attempt to make predictions based on preferences (i.e. Amazon recommendations). In geek speak, we represented preferences as a vector, and use the theorem to find the distance between them (and group similar items, perhaps).

Finding Color Distance

Measuring “distance” between colors is another useful application. Colors are represented as red/green/blue (RGB) values from 0(min) to 255 (max). For example

  • Black: (0, 0, 0) — no colors
  • White: (255, 255, 255) — maximum of each color
  • Red: (255, 0, 0) — pure red, no other colors

We can map out all colors in a “color space”, like so:

color cube

We can get distance between colors the usual way: get the distance from our (red, green, blue) value to black (0,0,0) [formally labeled delta e]. It appears humans can’t tell the difference between colors only 4 units apart; heck, even 30 units looks pretty close to me:

color distance

How similar do these look to you? The color distance gives us a quantifiable way to measure the distance between colors (try for yourself). You can even unscramble certain blurred images by cleverly applying color distance.

The Point: You can measure anything

If you can represent a set of characteristics with numbers, you can compare them with the theorem:

  • Temperatures during the week: (Mon, Tues, Wed, Thurs, Fri). Compare successive weeks to see how “different” they are (find the difference between 5-dimensional vectors).
  • Number of customers coming into a store hour-by-hour, day-by-day, or week-by-week
  • SpaceTime distance: (latitude, longitude, altitude, date). Useful if you’re making a time machine (or a video game that uses one)!
  • Differences between people: (Height, Weight, Age)
  • Differences between companies: (Revenue, Profit, Market Cap)

You can tweak the distance by weighing traits differently (i.e., multiplying the age difference by a certain factor). But the core idea is so important I’ll repeat it again: if you can quantify it, you can compare it using the the Pythagorean Theorem.

Your x, y and z axes can represent any quantity. And you aren’t limited to 3 dimensions. Sure, mathematicians would love to tell you about the other ways to measure distance (aka metric space), but the Pythagorean Theorem is the most famous and a great starting point.

So, What Just Happened Here?

There’s so much to learn when revisiting concepts we were “taught”. Math is beautiful, but the elegance is usually buried under mechanical proofs and a wall of equations. We don’t need more proofs; we need interesting, intuitive results.

For example, the Pythagorean Theorem:

  • Works for any shape, not just triangles (like circles)
  • Works for any equation with squares (like 1/2 m v2)
  • Generalizes to any number of dimensions (a2 + b2 + c2 + …)
  • Measures any type of distance (i.e. between colors or movie preferences)

Not too bad for a 2000-year old result, right? This is quite a brainful, so I’ll finish here for today (the previous article has more uses). Happy math.

]]>
https://betterexplained.com/articles/measure-any-distance-with-the-pythagorean-theorem/feed/ 118
Surprising Uses of the Pythagorean Theorem https://betterexplained.com/articles/surprising-uses-of-the-pythagorean-theorem/ https://betterexplained.com/articles/surprising-uses-of-the-pythagorean-theorem/#comments Wed, 24 Oct 2007 23:16:05 +0000 http://betterexplained.com/articles/a-surprising-look-at-the-pythagorean-theorem/ The Pythagorean theorem is a celebrity: if an equation can make it into the Simpsons, I'd say it's well-known.

\displaystyle{a^2 + b^2 = c^2}

But most of us think the formula only applies to triangles and geometry. Think again. The Pythagorean Theorem can be used with any shape and for any formula that squares a number.

Read on to see how this 2500-year-old idea can help us understand computer science, physics, even the value of Web 2.0 social networks.

Understanding How Area Works

I love seeing old topics in a new light and discovering the depth there. For example, I realize I didn't have a deep grasp of area until writing this article. Yes, we can rattle off equations, but do we really understand the nature of area? This fact may surprise you:

The area of any shape can be computed from any line segment squared. In a square, our "line segment" is usually a side, and the area is that side squared (side 5, area 25). In a circle, the line segment is often the radius, and the area is pi * r^2 (radius 5, area 25 pi). Easy enough.

We can pick any line segment and figure out area from it: every line segment has an "area factor" in this universal equation:

\displaystyle{\text{Area} = \text{Factor} \cdot (\text{line segment})^2}

Shape Line Segment Area Area Factor
Square
Surprising Uses of the Pythagorean Theorem
Side [s] s2 1
Square
Surprising Uses of the Pythagorean Theorem
Perimeter [p] 1/16 p2 1/16
Square
Surprising Uses of the Pythagorean Theorem
Diagonal [d] 1/2 d2 1/2
Circle
Surprising Uses of the Pythagorean Theorem
Radius [r] pi r2 pi (3.14159...)

For example, look at the diagonal of a square ("d"). A regular side is $\frac{d}{\sqrt{2}}$, so the area becomes $\frac{1}{2} d^2$. Our "area constant" is 1/2 in this case, if we want to use the diagonal as our line segment to be squared.

Now, use the entire perimeter ("p") as the line segment. A side is $\frac{p}{4}$, so the area is $\frac{p^2}{16}$. The area factor is 1/16 if we want to use $p^2$.

Can we pick any line segment?

You bet. There is always some relationship between the "traditional" line segment (the side of a square), and the one you pick (the perimeter, which happens to be 4 times a side). Since we can convert between the "traditional" and "new" segment, it doesn't matter which one we use -- there'll just be a different area factor when we multiply it out.

Can we pick any shape?

Sort of. A given area formula works for all similar shapes, where "similar" means "zoomed versions of each other". For example:

  • All squares are similar (area always $s^2$)
  • All circles are similar, too (area always $\pi r^2$)
  • Triangles are not similar: Some are fat and others skinny -- every "type" of triangle has its own area factor based on the line segment you are using. Change the shape of the triangle and the equation changes.

Yes, every triangle follows the rule "area = 1/2 base * height". But the relationship between base and height depends on the type of triangle (base = 2 * height, base = 3 * height, etc.), so even then the area factor will be different.

Why do we need similar shapes to keep the same area equation? Intuitively, when you zoom (scale) a shape, you're changing the absolute size but not the relative ratios within the shape. A square, no matter how zoomed, has a perimeter = 4 * side.

Because the "area factor" is based on ratios inside the shape, any shapes with the same "ratios" will follow the same formula. It's a bit like saying everyone's armspan is about equal to their height. No matter if you're a NBA basketball player or child, the equation holds because it's all relative. (This intuitive argument may not satisfy a mathematical mind -- in that case, take up your concerns with Euclid).

I hope these high-level concepts make sense:

  • Area can be be found from any line segment squared, not just the "side" or "radius"
  • Each line segment has a different "area factor"
  • The same area equation works for similar shapes

Intuitive Look at The Pythagorean Theorem

We can all agree the Pythagorean Theorem is true (here's 75 proofs). But most proofs offer a mechanical understanding: re-arrange the shapes, and voila, the equation holds. But is it really clear, intuitively, that it must be a2 + b2 = c2 and not 2a2 + b2 = c2? No? Well, let's build some intuition.

There's one killer concept we need: Any right triangle can be split into two similar right triangles.

pythagorean theorem proof by similarity

Cool, huh? Drawing a perpendicular line through the point splits a right triangle into two smaller ones. Geometry lovers, try the proof yourself: use angle-angle-angle similarity.

This diagram also makes something very clear:

  • Area (Big) = Area (Medium) + Area (Small)

Makes sense, right? The smaller triangles were cut from the big one, so the areas must add up. And the kicker: because the triangles are similar, they have the same area equation.

Let's call the long side c (5), the middle side b (4), and the small side a (3). Our area equation for these triangles is:

\displaystyle{\text{Area} = F * \text{hypotenuse}^2}

where F is some area factor (6/25 or .24 in this case; the exact number doesn't matter). Now let's play with the equation:

\displaystyle{\text{Area (Big)} = \text{Area (Medium)} + \text{Area (Small)}}

\displaystyle{F c^2 = F b^2 + F a^2}

Divide by F on both sides and you get:

\displaystyle{c^2 = b^2 + a^2}

Which is our famous theorem! You knew it was true, but now you know why:

  • A triangle can be split into two smaller, similar ones
  • Since the areas must add up, the squared hypotenuses (which determine area) must add up as well.

This takes a bit of time to see, but I hope the result is clear. How could the small triangles not add to the larger one?

Actually, it turns out the Pythagorean Theorem depends on the assumptions of Euclidean geometry and doesn't work on spheres or globes, for example. But we'll save that discussion for another time.

Useful Application: Try Any Shape

We used triangles in our diagram, the simplest 2-D shape. But the line segment can belong to any shape. Take circles, for example:

pythagorean theorem circle

Now what happens when we add them together?

circle areas

You guessed it: Circle of radius 5 = Circle of radius 4 + Circle of radius 3.

Pretty wild, eh? We can multiply the Pythagorean Theorem by our area factor (pi, in this case) and come up with a relationship for any shape.

Remember, the line segment can be any portion of the shape. We could have picked the circle's radius, diameter, or circumference -- there would be a different area factor, but the 3-4-5 relationship would still hold.

So, whether you're adding up pizzas or Richard Nixon masks, the Pythagorean theorem helps you relate the areas of any similar shapes. Now that's something they didn't teach you in grade school.

Useful Application: Conservation of Squares

The Pythagorean Theorem applies to any equation that has a square. The triangle-splitting means you can split any amount (c2) into two smaller amounts (a2 + b2) based on the sides of a right triangle. In reality, the "length" of a side can be distance, energy, work, time, or even people in a social network:

Social Networks.

Metcalfe's Law (if you believe it) says the value of a network is about n2 (the number of relationships). In terms of value,

  • Network of 50M = Network of 40M + Network of 30M.

Pretty amazing -- the 2nd and 3rd networks have 70M people total, but they aren't a coherent whole. The network with 50 million people is as valuable as the others combined.

Computer Science

Some programs with n inputs take n2 time to run (bubble sort, for example). In terms of processing time:

  • 50 inputs = 40 inputs + 30 inputs

Pretty interesting. 70 elements spread among two groups can be sorted as fast as 50 items in one group. (Yeah, there may be constant overhead/start up time, just work with me here).

Given this relationship, it makes sense to partition elements into separate groups and then sort the subgroups. Indeed, that's the approach used in quicksort, one of the best general-purpose sorting methods. The Pythagorean theorem helps show how sorting 50 combined elements can be as slow as sorting 30 and 40 separate ones.

Surface Area

The surface area of a sphere is 4 pi r2. So, in terms of surface area of spheres:

  • Area of radius 50 = area of radius 40 + area of radius 30

We don't often have spheres lying around, but boat hulls may have the same relationship (they're like deformed spheres, right?). Assuming the boats are similarly shaped, the paint needed to coat one 50 foot yacht could instead paint a 40 and 30-footer. Yowza.

Physics

If you remember your old physics classes, the kinetic energy of an object with mass m and velocity v is 1/2 m v2. In terms of energy,

  • Energy at 500 mph = Energy at 400 mph + Energy at 300 mph

With the energy used to accelerate one bullet to 500 mph, we could accelerate two others to 400 and 300 mph.

Try Any Number

You can use any set of numbers that make a right triangle. For example, enter a total amount (50) and one subportion (30), and the remainder will appear below:

Suppose you want to see if a large pizza (16 inches) is bigger than two mediums (12 inches). Plug in 16 for C, and 12 for A. It looks like the large pizza can be split into a 12-inch and 10.5-inch pizza, so two-mediums are in fact bigger.

Enjoy Your New Insight

Throughout our school life we think the Pythagorean Theorem is about triangles and geometry. It's not.

When you see a right triangle, realize the sides can represent the lengths of any portion of a shape, and the sides can represent variables in any equation that has a square. Maybe it's just me, but I find this pretty surprising.

There's much, much more to this beautiful theorem, such as measuring any distance. Enjoy.

]]>
https://betterexplained.com/articles/surprising-uses-of-the-pythagorean-theorem/feed/ 173