Mathematics and Music – with TI-Innovator

Hedwig’s Theme for Penny!

I recently visited my 5 nieces in Pittsburgh who are immersed
in the Harry Potter book series.
My oldest niece played Hedwig’s Theme on the piano for me.


I’ve been working on a session proposal for the 2018 T3 International Conference.

I decided to submit a proposal on creating music on the TI Innovator Hub.


As a demo, I wrote a program that plays the first few lines of Hedwig’s Theme.

Hedwig is Harry Potter’s dear owl.


Here is a video of the program being run on the TI-Nspire connected
to the Innovator Hub.


Ancient Greeks, in particular the Pythagoreans, are known as the first to investigate
musical scales in terms of simple ratios. They discovered that a lyre string that is
half the length of a given lyre string emits a musical note that is an octave higher
than that of the given lyre string.


I encoded the tune of Hedwig’s Theme with help from the
TI 10 Minutes of Code for the Innovator Hub using the TI-Nspire.

In particular, Unit 2: Skillbuilder 3 explains a bit of music theory to help you
get started (see image below).
I used a list to encode notes by their sound frequency, and another list to
encode the rhythm, i.e., the duration of each note.
The .tns file is available here.
The really cool thing about programming a song is that you can easily play it
in different keys or at different speeds
(by changing the parameters root_note and speed).
The irony of this code is that we are using 12th roots of 2, irrational numbers,
in order to encode musical notes based on Pythagoreans’ observations
of musical scales in terms of simple ratios.
These early Greek mathematicians were obsessed with the significance
of whole numbers and their ratios, i.e. rational numbers.


The Pythagoreans were so horrified by the discovery of irrational numbers
that according to legend, they drowned the man who first discovered
the existence of these “unspeakable” numbers.


Then they tried to keep the existence of irrational numbers an official secret
of their sect because irrational numbers threatened their mathematical
understanding of the world.


Please follow and like us:

One comment

Add a Comment

Your email address will not be published. Required fields are marked *