Rich Interactivity of New ebook, Incredible Numbers, Created with the Wolfram Language

Touch Press recently announced its newest title, Incredible Numbers, by Ian Stewart. The rich interactive explorations in the ebook were prototyped in the Wolfram Language by Phil Ramsden, who is a Teaching Fellow at Imperial College London and a Mathematica trainer. We asked him to relate his experience here.

Ian Stewart’s mathematical imagination is boundless. There are few areas of the subject that haven’t been illuminated, for a general readership, by his gift for clear and vivid exposition. So when Ian, Touch Press, and Profile Books decided to create something interactive, they needed a development and prototyping environment in which you can do pretty much anything; a mere specialist application wasn’t going to cut it. That’s where the Wolfram Language came in and, happily for me, where I did too.

The Wolfram Language provides an environment in which you can do pretty much anything, and do it quickly. The reason that the Wolfram Language is such a “game-changer” is that where interactive content is concerned, it takes us into a world where an idea (such as one of Ian’s) can become a working prototype in no time.

Or at least in real time: sitting in Ian’s office at the University of Warwick, we were often able to try things out live, there and then, as part of the conversation. In other cases, what we wanted was something more ambitious, which involved a longer and more systematic process of development. In those cases, the Wolfram Language was deployed via CDF, allowing us to share our code easily with Ian. It’s the ultimate “low threshold, high ceiling” development tool.

Almost every interactive element of Incredible Numbers was prototyped in the Wolfram Language, though for a smooth, seamless look and feel, most were re-implemented natively for the iPad by Touch Press’ engineers.

You’ll find, for example, in the section on Nature, a lovely exploration of the reason the golden ratio and the Fibonacci series keep cropping up in the natural world. The exploration focuses on the arrangements of seeds in the head of a sunflower. Those seeds can be thought of as being threaded on a certain spiral, with a fixed angle between each seed and the next. The best outcome for the plant has the seeds distributed as evenly as possible, which—it turns out—is achieved when the angle between the seeds is related to the golden ratio. (See Incredible Numbers for more details.) Here’s one of the CDF prototypes of the interactive exploration:

To view the full content of this page, please enable JavaScript in your browser.

A good angle to look at is 137.508°, which is 360 degrees multiplied by (2 minus the golden ratio). Do you see how the seeds become optimally spaced at this angle, and how easily this optimality is destroyed by small changes in the angle?

Here’s the code for the prototype:

Yes, it really is five lines of code, and that really is, I think, as amazing as it appears.

I should declare an interest: I don’t work for Wolfram, but I do sometimes work as a Wolfram trainer, and I’ve been a user of Mathematica since Version 1 point something. So I’m not exactly an unbiased commentator. But let me say it anyway: the dynamic functionality that Mathematica’s had since Version 6, and that now forms the core of the Wolfram Language, was unique when I first saw it (and was blown away by it), and remains so. Since then, there have been several practitioners of the sincerest form of flattery, but none of them have been as general, as robust, or as powerful.

It’s not part of Ian’s app, but I think I have to show, as a way of making this point, the first piece of Wolfram Language dynamic code I ever wrote, within half an hour of first being shown the technology. Here it is:

And this is what it does (try increasing the value of λ, and then, when you think you’ve got “chaos,” observe the effect of small changes in the starting value x0):

To view the full content of this page, please enable JavaScript in your browser.

It’s this ability to achieve rich interactivity so simply and quickly that’s unprecedented, and that has enabled what, if I may be cheeky, I’d like to call “A New Kind of Workflow.” I’m sure something as daring and innovative as Incredible Numbers would have been possible without this ability to turn ideas rapidly into things that work, but I’m equally sure that it would have been much, much more difficult, and it may be that the end product wouldn’t have been quite so much fun.

To finish with, here’s one of those slightly more ambitious pieces of content I talked about. The final version of this appears in the Puzzles section of Incredible Numbers, and may be a pointer toward a section on the four-color theorem in a possible follow-up. The aim of the puzzle is to shade the regions of the map using four colors, so that no two regions of the same color are adjacent. (To pick up the color you want, dip your “paintbrush” in one of the “pots” on the left.)

To view the full content of this page, please enable JavaScript in your browser.

Now, the forms of interactivity in this object are richer than in the other two I’ve linked to: the object needs to respond to user actions within the graphics window, for example, rather than to changes in a control slider. That’s why the code for this prototype wasn’t five lines.

It was 30 lines.

I’ve been making this kind of interactive “thing” for many years now, so I know only too well how many orders of magnitude more code, and time, it used to take in the old days before CDF. That was why, in those old days, a “prototype” was often something that just sat there, looking possibly a little like the working finished product was planned to look, and supplemented by verbal (and indeed verbose) descriptions of the intended functionality.