Where can I get an introduction to the mathematics behind Hofstadter's Butterfly?

The book Physics by Computer has a unit on Hofstadter's Butterfly. The "presentation of the theoretical foundations can only be seen as a first introduction," according to the book's introduction, but it does have source code for computing the figure.

This web page about the book has many broken links, but you can find the Java source code for the book's Butterfly unit on the Wayback Machine.

I have ported the java code to HTML5 canvas/javascript here, where you can watch the figure fill in as q increases: Hofstadter butterfly, monochrome

I also recommend this pithy half-page summary of the math by Oliver Knill, that was linked to by the page that @Jitter posted a link to. It describes a function $f(x,y)$ for the Butterfly, using a Lyapunov exponent. Prerequisite: knowledge of matrices and determinants.


I created a Jupyter Notebook http://nbviewer.jupyter.org/github/empet/Mathematical-Physics/blob/master/Hofstadter-buterfly.ipynb, that presents how the Hofstadter butterfly is defined, as well as an interactive plot that shows on hover the corresponding rational magnetic flux and the energy.

enter image description here