Jim Dennis edited this page May 9, 2016 · 4 revisions

Welcome to the PythyTurtle wiki!

Example 1: Three-to-one ratio:

Example 2: one-to-one ratio:

I started PythyTurtle program for a couple of reasons. I have been working my way through the FreeCodeCamp self-paced tutorials. Around "Challenge 136" the challenge it to create a portfolio of web designs. This is an idea I have for something with a mixture of graphics and code as well as text. I have also been, occasionally, playing with the Khan Academy Computer Programming materials like this slice of pizza. Also I came across the Python Turtle/Tk package a few months ago, right there in Python's copious standard libraries.

So I decided to play with this Turtle/Tk package and draw a non-trivial image. The images here are results of the function I from from the %save (history) of that interactive iPython session.

Additionally I sometimes mentor others in Python programming. Beyond the code (which is actually pretty trivial) this repository can give examples of using GitHub, tracking and resolving bugs and enhancement requests, maintaining a project wiki, and so on.

Sometimes I even teach people about this proof by construction and this program will be a handy tool for generating multiple images to show how the technique is independent of the (right) triangle's proportions. (I'd be delighted if some future version ends up being incorporated into any curricula, online or in the classroom).

The fact that it's in Python is just a starting point. I plan to port this to one of the JavaScript turtle graphics libraries such as Turtle Wax and implement a Single Page Application that functions as a tutorial for walking a student through the proof (including, the necessary compass and straightedge construction techniques).

Why the Pythagorean Theorem

When I learned about the Pythagorean theorem we were never walked through any proof of the Pythagorean Theorem. We did lots of proofs in Geometry; but never this one.

Shortly after getting out of high school I ended up as a construction worker (electrician and crane operator). Somewhere along the line I'd heard that it was possible to prove the this theorem using only compass and straightedge construction and I decided to take that as a challenge. (This was about a decade before Wikipedia or Google existed ... so it wasn't as easy to just look something like that up).

compass & straightedge

For a few days I kept a pad of paper, a protractor and a ruler with me at work and did brainstorming during breakfast, lunch, coffee breaks and dinner. (My co-workers thought I was nuts; but that was far from the sole quirk they could point to for evidence of that).

Eventually I came up with something like these images.

The one square with the thick black border was close and it came to me in a flash of inspiration that it led directly to the adjacent half of the square (shown here with the thick red border). Once you complate that (red-bordered) squared the image is complete and the proof is merely a matter of reasoning. Taking away all the triangles from each (enclosing) square only leased the shaded (smaller) squares ... the pink ones on the one side (labeled "a" and "b") and the lavender ("c") on the other. Because the two enclosing squares are of identical size and all of the triangles are identical (by virtue of their construction) then the remaining shaded and labeled squares in the one half must be equal, in area, to the remainder of the other half.

In other words these images are graphical equations. Each side's area is the sum of four (identical) triangles and one or two squares.

It turns out that I had re-invented Pythagoras' own proof (or something very similar to it). That's something I didn't find out until much later.

Note: These images are NOT "proof" of the theorem.

The proof is in their construction and the reasoning about the results of that construction. It's important to know, and to be able to show, that these (enclosing) squares and triangle don't just "look" like they're the same size. The are guaranteed to be the same size by the means of construction ... by using specific techniques to extend existing line segments, draw arcs with a compass, find intersections of those arcs (points), draw lines through pairs of points, and to build perpenducular lines from a given line at an arbitary point (or other intersection).

These images are just a representation of what result that possible to derive from a series of such operations, starting with just one of these right triangles.

I'm posting two different images, generated by this program, using different proportions of height and width for the initial triangle. pythy_turtle.py only takes two arguments, a height and width. All of the rest of this image, and the labels, are derived by motions of the turtle that are relative to those two numbers. They're added to one another, doubled or cut in half. There are no other calculations performed my my code in generating these images. All the lines are horizontal or vertical except for the six blue lines for the hypotenuse of each triangle. (Two are shared along the diagonal of their enclosing rectangles). (Again, the code doesn't constitute a proof nor a proper construction of the proof; it's just a way to generate the image to illustrate what such a proof looks like, with coloring and labels to facilitate explanation).

One Note about Graphics Associated with the Pythagorean Theorem:

Here's the sort of image I've typically seen posted on the walls of classroom, and in texts and web pages referring to the Pythagorean Theorem:

I despise that image! Even was I was young I could see that this image doesn't prove anything nor even help one understand the theorem.

At best this image simply illustrates the concept of a Pythagorean Triple. That is to say a set of integers which happen to to be a solution to the Pythagorean Theorem.

But those are special cases where certain heights and widths resolve to integer hypotenuse lengths.

The image doesn't show us how that happens, we take it for granted that the units shown are of uniform size and it doesn't convey how the theorem generalizes to all triangles.

The principle underlying this theorem helped build the pyramids, and various other ancient structures and allowed Eratosthenes to estimate the size of the earth (possibly to within 1% of the value now known to be true ... depending on how accurate our historical records are with respect to the length of the ancient Greek "stadia" or the "pous" on which it was based).

(If you see this image used in discussion of the Pythagorean Theorem rip it down ... or just ask whoever is responsible for it to clarify the distinctions between a proof and an illustration of some Pythagorean triple).

xkcd Cartoon: Compass and Straightedge "Using only a compass and straightedge it's impossible to construct ..."

© James T. Dennis

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.