Skip to content

Dan Q

  • Blog
    • Articles
    • Everything
    • Notes
    • Reposts (shares)
    • Checkins (geo*)
    • Videos
    • Reviews
    • Comics
    • Tags
    • Stats
    • Subscribe
    • Blogroll
  • About
    • Polyamory
    • Volunteering
    • Colophon
    • A Eulogy for Peter George Huntley
  • Contact
    • Contact Me
    • Postcards From The Internet!
    • Instant Messengers
    • GPG Key
  • Projects
    • Free Deed Poll
    • KeePass for Opera
    • mOTP for Ruby
    • PicInHTML
    • Rails SSL Auth
    • Dozens of other projects…

Tag: logo

How I Learned the Pythagorean Theorem

The younger child and I were talking about maths on the school run this morning, and today’s topic was geometry. I was pleased to discover that he’s already got a reasonable comprehension of the Pythagorean Theorem1: I was telling him that I was about his age when I first came across it, but in my case I first had a practical, rather than theoretical, impetus to learn it.

It was the 1980s, and I was teaching myself Dr. Logo, Digital Research‘s implementation of the Logo programming language (possibly from this book). One day, I was writing a program to draw an indoor scene, including a window through which a mountain would be visible. My aim was to produce something like this:

Turtle-graphics illustration of a yellow window made of four rectangular quarters, with a triangular mountain peak visible through it with its peak at the centre of the window.
All of these graphics were made using my own 2019 implementation of Logo, TRRTL.COM: click on any graphic to continue drawing!

My window was 300 “steps”2 tall by 200 steps wide and bisected in both directions when I came to make my first attempt at the mountain.

And so, naively, starting from the lower-left, I thought I’d need some code like this:

RIGHT 45
FORWARD 100
RIGHT 90
FORWARD 100  

But what I ended up with was this:

An attempt to draw the mountain results in it being too short: its peak doesn't reach half-way, and it ends before the far side of the window.
Hypotenuse? More like need-another-try-potenuse.

I instantly realised my mistake: of course the sides of the mountain would need to be longer so that the peak would reach the mid-point of the window and the far side would hit its far corner. But how much longer ought it to be.

I intuited that the number I’d be looking for must be greater than 100 but less than 250: these were, logically, the bounds I was working within. 100 would be correct if my line were horizontal (a “flat” mountain?), and 250 was long enough to go the “long way” to the centrepoint of the window (100 along, and 150 up). So I took a guess at 150 and… it was pretty close… but still wrong:

This time the mountain "overshoots" slightly: its peak is too far over and it stretches beyond the window frame.
I remember being confused and frustrated that the result was so close but still wrong. The reason, of course, is that the relationship between the lengths of the sides of a triangle don’t scale in a 1:1 way, but this was the first time I found myself having to think about why.

So I found my mother and asked her what I was doing wrong. I’m sure it must have delighted her to dust-off some rarely-accessed knowledge from her own school years and teach me about Pythagoras’!

The correct answer, of course, is given by:

100 2 + 100 2
I so rarely get to use MathML that I had to look up the syntax.

The answer, therefore, is… 141.421 (to three decimal places). So I rounded to 141 and my diagram worked!3

What made this maths lesson from my mother so memorable was that it fed a tangible goal. I had something I wanted to achieve, and I learned the maths that I needed to get there. And now it’s impermeably etched onto my brain.

I learned the quadratic equation formula and how to perform algebraic integration by rote, and I guarantee that it’s less well-established in my long-term memory than, say, the sine and cosine rules or how to solve a simultaneous equation because I’ve more-often needed to do those things outside of the classroom!

So I guess the lesson is that I should be trying to keep an eye out for practical applications of maths that I can share with my kids. Real problems that are interesting to solve, to help build the memorable grounding that latter supports the more-challenging and intangible abstract maths that they may wish to pursue later.

Both kids are sharp young mathematicians, and the younger one seems especially to enjoy it, so feeding that passion feels well-worthwhile. Perhaps I should show them TRRTL.COM so they can try their hand at Logo!

Footnotes

1 You know the one: the square of the triangle’s hypotenuse is equal to the sum of the squares of the other two sides. You could conceivably know it by some other mnemonic, but the essence is that if you know the lengths of two sides of any right-angled triangle, you can derive the length of the third with some moderately-simple arithmetic.

2 Just one way that Logo is/was a cute programming language was its use of “steps” – as in, turtle-steps – to measure distances. You might approximate them as pixels, but a “step” has meaning even for lines that don’t map linearly to pixels because they’re at wonky angles, for example.

3 I’d later become unstuck by rounding, while trying to make a more-complex diagram with a zig-zag pattern running along a ribbon: a small rounding error became compounded over a long time and lead to me being a couple of pixels off where I intended. But that’s another story.

13 November 2025

Article posted at 11:52 UTC on 13 November 2025.

No comments

Awtomattig

If Automattic had been founded in Wales instead of the USA:

The Automattic logo, but adapted to Welsh "automatig" and with the extra T re-added. The head of the "I" is a dragon.

The Automattic logo, but adapted to Welsh "automatig" and with the extra T re-added. The head of the "I" is a dragon.

×
5 June 2024

Note posted at 17:36 UTC on 5 June 2024.

No comments

TRRTL – Logo on Coffee

tl;dr: TRRTL.COM is my reimplementation of a Logo on-screen turtle as a CoffeeScript-backed web application

For many children growing up in the 1970s and 1980s, their first exposure to computer programming may have come in the form of Logo, a general-purpose educational programming language best-known for its “turtle graphics” capabilities. By issuing commands to an on-screen – or, if they were really lucky, robotic – cursor known as a turtle, the student could draw lines and curves all over the screen (or in the case of robotic turtles: a large sheet of paper on the floor).

Hardware turtle and microcomputer.
Back in the day, screens were monochrome and turtles were wired. What a way to live.

While our eldest and I were experimenting with programming (because, well…) a small robotic toy of hers, inspired by a book, it occurred to me that this was an experience that she might miss out on. That’s fine, of course: she doesn’t have to find the same joy in playing with Logo on an Amstrad CPC or a BBC Micro that I did… but I’d like her to be able to have the option. In fact, I figured, there’s probably a whole generation of folks who played with Logo in their childhood but haven’t really had the opportunity to use something as an adult that gives the same kind of satisfaction. And that’s the kind of thing I can fix.

Annabel practicing some elementary programming activities.
Don’t interrupt a programmer when she’s “in the flow”.

TRRTL.COM is my attempt to produce a modern, web-based (progressive, offline-first) re-imagining of Logo. It uses CoffeeScript as its base language because it provides all of the power of JavaScript but supports a syntax that’s more-similar to that of traditional Logo implementations (with e.g. optional semicolons and unparenthesised parameters).

A snail in TRRTL.COM.
Turtles can be surprisingly fast. Snails, less-so.

If you’ve not used Logo before, give it a go. Try typing simple commands like forward 100 (steps), right 90 (degrees), and so on and you’ll find it’s a bit like an etch-a-sketch. Click the “help” icon in the corner for more commands (and shorter forms of them) as well as instructions on writing longer programs and sharing your work with the world.

Concentric ringed rainbow star in TRRTL.COM.
Users can share their creations with the world, and then optionally expand upon them. Click the image to carry on where I left off, here.

And of course the whole thing is open source in the most permissive way imaginable, so if you’re of an inclination to do your own experiments with <canvas>, Progressive Web Apps, and the like, you’re welcome to borrow from me. Or if anybody wants to tag-team on making a version that uses the Web Bluetooth API to talk to a robotic turtle or to use WebRTC to make LAN “multiplayer” turtle art, I’m totally game for that.

My volunteering and academic workload for the rest of this year is likely to reduce the amount of random/weird stuff I put online, so it might get boring here for a while. Hope this tides you over in the meantime.

Hardware turtle and microcomputer.

×

Annabel practicing some elementary programming activities.

×
15 February 2019

Article posted at 16:03 UTC on 15 February 2019.

No comments
  • © Dan Q 1998-2025
  • Creative CommonsAttributionNon-Commercial except where stated (how to use)
  • powered by BloqClassicPressHTML5CSS3
  • privacy
  • Read articles, checkins, notes, reposts, and more...
  • @dan@danq.me
  • contact
  • subscribe