You're reading: cp’s mathem-o-blog

Instant MathJax preview of LaTeX typed into HTML textareas

I’ve completely rewritten my write maths, see maths library to be a little jQuery plugin that attaches itself to editable areas on pages, like contenteditable elements, textareas, and input boxes. When your cursor is inside some LaTeX, a little preview box appears just above it with the LaTeX rendered through MathJax. I’ve made a demo page on GitHub, and the code itself is available there too.

Continue reading “Instant MathJax preview of LaTeX typed into HTML textareas” on cp’s mathem-o-blog

A huggermuggering nonannouncement of an overinvolved knickknack

It’s odd, the process of waking up. Sometimes you can get out of bed and stumble around for an hour or two, maybe even get dressed and go to work, before your brain does anything to differentiate you from a patient in a highly mobile vegetative state. On other days it seems that your mental starter motor catches on the first try and before you’ve even opened your eyes all sorts of brilliantly original thoughts are competing for attention.

Today is one of those days. As I swung my big long legs out of bed the thought occurred to me that the word “cheese” has an awful lot of Es in it.

Continue reading “A huggermuggering nonannouncement of an overinvolved knickknack” on cp’s mathem-o-blog

Fibonacci Grids

I uploaded this video to YouTube last week but I forgot to make a post here. It’s about a moderately interesting fact about fibonacci numbers that David Cushing told me at MathsJam. I generalised it a bit, so I’ve been meaning to write a post for The Aperiodical or do a snappy video or something like that for ages.

I finally decided last week to just sit down and record myself going through the proof, so here’s that video. I deliberately didn’t prepare beforehand, so it’s just under an hour long and contains a lot of thinking out loud.

Continue reading “Fibonacci Grids” on cp’s mathem-o-blog

Converting a stream of binary digits to a stream of base $n$ digits

James Coglan asked on twitter:

Suggestions wanted: how to turn an indefinite stream of bits (01110010…) into a stream of [A-Z] where letters are evenly distributed.

— James Coglan (@jcoglan) June 11, 2012

And I don’t mean just select character codes, I mean select from an arbitrary-sized character set of any length.

— James Coglan (@jcoglan) June 11, 2012


So you have an infinite stream of uniform random binary digits, and want to use it to produce an infinite stream of uniform random base $n$ digits.

The obvious really easy way to do it is to find the smallest $k$ such that $2^k \geq n$, and generate numbers in the range $0 \dots 2^k-1$.

Continue reading “Converting a stream of binary digits to a stream of base $n$ digits” on cp’s mathem-o-blog

Problems I’m currently thinking about

I’ve been in a bit of a problem-posing mood recently. Hopefully I’ll do some problem-solving soon. Here are a few questions I’ve thought of but haven’t got solutions for. I haven’t done any literature searching, so these might have been done before.

All the problems are quite computery. Maybe I’m a computer scientist, really.

Problem 1: Reordering the alphabet

What reordering of the letters of the alphabet contains the most (contiguous) English words? This is a big search space problem.  I did a little bit of tinkering in python, trying first of all to find the single word which contains the most smaller words.

Continue reading “Problems I’m currently thinking about” on cp’s mathem-o-blog

Newcastle MathsJam April 2012 Recap

April’s MathsJam was very enjoyable. We did a bit of arts and crafts, a bit of playing games, and if it had been NBA Jam instead of Maths Jam I would have been entirely on fire because I used up all my IQ points solving some very fun puzzles. Durham were still on their Easter holidays so the attendance was a modest six people. That was just enough for everyone to be doing the same thing at the same time, so we had a good time.

Continue reading “Newcastle MathsJam April 2012 Recap” on cp’s mathem-o-blog