A sort of mathematical quine

Julian Havil writes what I think of as serious recreational mathematics. His books are recreational in the sense that they tell a story rather than cover a subject. They are lighter reading than a text book, but require more advanced mathematics than books by Martin Gardner.

Havil’s latest book is Curves for the Mathematically Curious. At the end of the book, Havil presents something like a quine created by Jeff Tupper. A quine is a computer program that when executed produces its own source code. Here we have a mathematical inequality that creates an image of itself.

For 0 ≤ x < 106 and Ny < N + 17, fill in a square with coordinates (x, y) if and only if

{1\over 2} < \left\lfloor \mathrm{mod}\left(\left\lfloor {y \over 17} \right\rfloor 2^{-17 \lfloor x \rfloor - \mathrm{mod}(\lfloor y\rfloor, 17)},2\right)\right\rfloor

Jeff Tupper published a value of N such that the resulting image is

Jeff Tupper's quine

Any image of size 106 by 17 can be produced by using the right value of N. Havil uses a value of N that produces the title of his new book. Two images, actually. The title of his book is a little long for 106 pixels, so he splits it into two images. The values of N that produce Tupper’s original image and Havil’s two images have 544 digits. Havil explains how to compute N from a desired image.

Posts that cite Julian Havil’s books

2 thoughts on “A sort of mathematical quine

Comments are closed.