It's all in the code

Mathmo v0.9.3

leave a comment »

I’ve just released v0.9.3 of the Mathmo interactive workbook for A-level at This release gives users much more control over question generation – allowing such things as question sharing, and predictable exercise content. It features a new cleaner user interface which should work on a wider range of browsers – but this is all still in test, so let me know of any issues at It requires HTML5 and SVG support from the browser, which does cut out IE8 (IE9+ are ok) and some Android browsers which lack SVG.

This is still alpha as we have a few more features to implement yet – see the outstanding issues list for details. However it should be good to use. 

In this release we moved away from the mobl-lang technology base which had begun to stagnate, and are now using Google’s Angular.js along with d3.js for plots. This is going to be the way of many NRICH interactives to come, so please ditch those old IE8 and IE7 browsers as soon as you possibly can! If you have XP and so can’t upgrade to IE9 or IE10, use Chrome. We recommend Chrome anyway.


Written by gmp26

May 13, 2013 at 8:27 am

Posted in Uncategorized

Tagged with ,

The nought point threeness of 0.3

with 5 comments

I seem to be programming a lot in javascript these days. Since I work on and one thing that crops up a lot is the need to represent numbers on screen. A simple requirement would be that 0.3 shows up as 0.3 rather than something like 0.29999999999987. For this, javascript provides a couple of useful functions. One rounds your number to a fixed number of decimal places, and the other returns as many significant figures as you want.

So far so good, but there’s a mildly surprising aspect to these two functions. They don’t return numbers. Instead they return character strings – text to you and me. Think about it some more and you realise that yes you really do want the character string “0.3” rather than some number 0.3. After all, the computer program does not usually manipulate a data structure that represents three tenths precisely. Instead, it uses a truncated binary representation that fits the machine architecture better. That’s why, given a chance, it might print out 0.29999999999987 instead of 0.3.

This gets one thinking about the huge difference between the machine’s internal representation of a number – the working model which can be manipulated arithmetically – and the external representation – the set of characters to be sent to a display device. 

The machine usually represents 0.3 in an approximate binary form simply because that’s the fastest thing to manipulate if all you want is answers to 13 significant figures or so. But if you really wanted to do rational arithmetic precisely, then fine, the machine can use a better data structure – one that stores the integers 3 and 10 separately – and achieve perfect precision. We’ve all played with calculators that can add fractions perfectly after all.

The interesting thing about this is that internally, the number we know as 0.3 has to be represented in different ways for different purposes. It’s an object that contains both data – the binary floating point string, the 3, the 10 – and algorithms. Provided we can capture the essence of 0.3 in these objects in a finite amount of computer memory and processing time we have a precise internal model of the number.

Now what about a transcendental number?  Can a computer hold a perfect model of pi? How big an object would the representation be? Would it be finite? Can we ask for ‘perfect’ or must we make do with ‘practical’? Tricky one…


Written by gmp26

January 27, 2012 at 10:18 am

A Random Rambling Rant

leave a comment »

Recently wrote this statistics article for schools on NRICH which I billed as ‘for teachers’. It was very loosely based on the work we did for our article in Science . I’m interested to know whether the references in the article would be considered too ‘adult’ for a schools context? e.g. xkcd language can be a little Anglo Saxon, and OKTrends produce some outstanding visualisations that perhaps tell you more than you want to know about the statistics of sex. Disappointed if they are deemed inappropriate because they generated sooo much interest here! And that’s half the battle.

Written by gmp26

October 31, 2011 at 11:49 am

jQuery Mobile

leave a comment »

Alpha level HTML5/CSS rendering framework for mobiles with good cross-platform intentions. Some way to go before this framework is ready. In my experience to date it suffers from a slightly boring design and difficult-to-debug page loads on real devices that yield nothing more than a white screen. Really hard to debug since the errors do not show in desktop emulators.

Written by gmp26

May 15, 2011 at 5:43 pm


leave a comment »

Cappuccino is a development system very closely modelled on Apple’s Cocoa. Cocoa compiles Objective C into C. Capp compiles Objective-J into javascript. Cappuccino wraps javascript in the same square bracket messaging syntax used in Cocoa to turn C into an object orientated language. In doing this it creates a language which has strong typing and in-built classic classes. The correspondence is so close with Cocoa that tools such as XCode interface builder can also be used to design in-browser Cappuccino user interfaces. So it’s a good solution for Cocoa programmers. At present Cappuccino apps work well on the desktop, but need serious re-theming for mobile use. Motorola recently invested in this technology.

Cappuccino is often compared to SproutCore – e.g. see

Written by gmp26

May 15, 2011 at 5:05 pm


leave a comment »

Another language that compiles to ‘javascript – the good bits’. Excellent tutorial, good tools. Very fast way to learn good programming practice in js since tutorial displays coffescript and generated javascript side by side. Downside is semantic use of white space which left me completely confused when attempting to code nested array and object initialisers.  It just seems to be buggy in this area.

Written by gmp26

May 15, 2011 at 10:49 am

The M-Project

leave a comment »

A mobile webapp generator and framework based on Nodejs tools currently using jquery-mobile for HTML5/CSS rendering.

  • Very similar to the ruby based Sproutcore. There’s an app generator, an app server, and an app builder, all implemented in javascript and running under Nodejs. Sproutcore does the same, but uses Ruby.
  • UI code is also similar to Sproutcore – though it feels slightly less verbose.
  • On the desktop this works beautifully. Mobile devices appear to have webapp loading problems.
  • Open source with commercial support
I was sold on this system – it’s well supported with good documentation – but became frustrated with the intermittent loading problem I see on Android devices. I have a feeling that current jquery-mobile 0.3 and 0.4 have a race condition in their loading, which is exacerbated by slower mobile loads and occasional 3G/wifi channel hopping.
I may return to this system in future to see whether things have improved.

Written by gmp26

May 15, 2011 at 10:34 am

Posted in Uncategorized

Tagged with , ,


Get every new post delivered to your Inbox.

Join 110 other followers