You're reading: Posts Tagged: maths on the web

Colourful Mathematics – A Review of Alex Berke’s Book ‘Beautiful Symmetries’

Title page of "Beautiful Symmetry, A Coloring Book About Math"

Group theory is a strange and wonderful area of study in mathematics, with plenty of key ideas and core concepts for one to wrap their algebra-hungry head around. But how do you introduce these algebraic constructs to beginners in a fun and engaging manner, whilst simultaneously providing a thoughtful read for the experts? This is exactly what mathematician and computer scientist Alex Berke accomplishes with her mathematical colouring book Beautiful Symmetry and its innovative group colouring concept.

Where could you (or your rich pal) give everyone $1 million?

Recently someone on Twitter, and then two people on US cable news, said that Michael Bloomberg could have used the \$500 million he spent on his presidential campaign to give everyone in the USA \$1 million. This caused quite a fuss.

In short, someone divided 500 by 327, saw that the answer was bigger than 1 and the units were “millions”, and concluded that the money could instead have been distributed to give everyone \$1 million.

That’s an easy mistake to make for someone writing a tweet, but the kind of error that should have made someone think “does that make sense?” before planning a segment on TV news about it.

It’s raised a couple of interesting questions, though:

  • If that money was shared between every American citizen, how much would each one get?
  • If Michael Bloomberg wanted to give \$1 million to everyone in a smaller area, where could he choose?

I realised that all the data I need is freely available on the internet, so I made a website to do the calculations for you:

make-it-rain-bloomberg.glitch.me

It asks you how much money you’ve got, then for every power of 10 dollars, it tells you where in the USA you could give every resident that much.

To give you an idea of how far the net worths of people like Michael Bloomberg could go, it’s got a list of shortcuts for billionaires. Appropriately, I got that data from Bloomberg’s own website. Bloomberg himself was mysteriously missing from the list, so I got his net worth from Google and added it in myself.

The most unexpected thing for me was seeing how much money these people would have left over after giving everyone in the USA \$100. They’d still be enormously, unimaginably rich!

I’ll describe a few of the fiddly details of the implementation now. At first the “how much money have you got?” input was a text field, but I realised it’d be much better to have a slider that you can swing from \$1 all the way up to \$1 trillion. It’s a logarithmic scale, so powers of 10 are equally spaced.

I got data on the populations of US cities and states from data.census.gov.

Working out which amounts and places to show you wasn’t completely straightforward. I thought it’d be easiest to fix the amounts given away to a power of 10 per person, and to find places where the population meant that the amount left over would be as small as possible. To do that, my code works through the list of places in ascending order of population, and stops at the last place whose population is big enough to give everyone at least the target amount.

I enjoyed making this tool, and I hope it helps somebody get a better feel for what these big numbers mean.

Spread your wealth at make-it-rain-bloomberg.glitch.me.

TeXnique: a LaTeX typesetting game

You know what’s fun? Typesetting mathematics! Glad you agree, because here’s a game that puts the fun in ‘underfilled hbox’.

Screenshot of TeXnique. A box showing the target formula above a box showing a rendering of code typed in the box below.

In TeXnique, you’re shown a typeset bit of mathematical notation, and have to frantically type LaTeX to reproduce it. You get three minutes, and you’re awarded points when you produce something that’s a pixel-perfect replica of the original. Think Typing of the Dead crossed with The Art of Computer Programming.

When I first saw this I rolled my eyes, but now my high score is 68 and I don’t know why I keep going back to it.

The formulas are largely well-known snippets of notation, so you might find some of them coming out through muscle memory, but if a symbol shows up that you can’t remember the macro for, there’s always the brilliant Detexify tool.

Play: texnique.xyz by Akshay Ravikumar.

Mathigon

This is a guest post from Philipp Legner, the creator of Mathigon an interactive maths education platform.

Every year, thousands of students around the world ask themselves why they have to learn mathematics. Calculators can do long division. You can look up the quadratic formula on the internet. And when will you ever need calculus in everyday life? It seems like they have a point.

In fact, the maths curriculum has not changed significantly in the last 50 years. Its primary focus is on memorising rules and procedures which can be used to solve standardised exam questions. I created Mathigon because I strongly believe we need to change this – not only to make mathematics more enjoyable for students, but also to teach different skills that are much more useful in life: problem-solving, abstraction, logical reasoning, creativity, and curiosity.

I’m streaming digits of π for π day

It’s π eve, and I’ve had a silly idea: I’m going to take the ridiculous website I made to show all the digits of π, and stream it scrolling indefinitely through them over the internet.

Starting at midnight GMT on 2019-03-14, the stream below will start scrolling down through the digits of π:

I had this idea this morning, and it’s running on my desktop PC which I’ll be away from until 8am tomorrow, so I won’t be surprised if something goes wrong.

But if it doesn’t: hooray!

I’ve made myself a calculator

Screenshot of my calculator, showing 3867/5000 = 0.7734

For the past couple of weeks at work, I’ve been checking through our computer-based assessments before the students have a go at them. That means I’ve had to do lots and lots of calculations by hand, to confirm the computer’s got the right answer. Well, not quite by hand – I use a calculator for the stuff that I can’t keep in my head.

I’ve got a calculator app called RealCalc Plus on my phone, which I highly recommend. The main thing it’s got going for it is its RPN mode. While most calculators ask you to type in expressions pretty much as you’d see them on a page, read from left to right with numbers separated by operators and brackets, reverse Polish notation looks like this:

1 5 √ + 2 ÷

That computes $\phi = \frac{1+\sqrt{5}}{2}$. You put the numbers in first, and then say what to do with them. This might look obtuse, but it can make long expressions much easier to type in. Because there are no brackets, you don’t need to remember to close them. And if the same fragment appears more than once in the expression, you can just duplicate it on the stack, instead of typing it all out again. I’ve been using an RPN calculator for a few years now, and I get a warm mathmo feeling when I think about all the time it’s saved me.

But there are a couple of things that regularly trip me up. Once you’ve performed a calculation, you can see the result but you can’t see how you got there, so when you’ve got a couple of long numbers sitting on the stack and you can’t remember which is which, you just have to start again. And if you want to repeat a calculation but with a slightly different starting value, you’ve got no choice other than to type it all in again.

So, about halfway through my marathon of testing, with thumbs sore from tapping calculator buttons, I decided there was nothing for it except to make my own calculator. It would mainly be like RealCalc, but do something to solve those two problems. I headed straight to my favourite gaudily-decorated coding environment, Glitch.com, and set to work.

xkcd comic "Is it worth the time?" - a table showing how long you should spend shaving time off a task, depending on how often you do it
xkcd no. 1205, “Is it worth the time?”, licensed under a Creative Commons Attribution-NonCommercial 2.5 License.

In this case, I think the day or so I spent making the calculator was worthwhile. I’ve been using the new calculator to finish off my testing duties, and it feels much better to use: I can do calculations quicker, and I lose track of what I’m doing less often.

The first change I made was to display not just the results of calculations, but how they were obtained. When you press 1 2 +, a box is pushed to the stack with a 3 at the bottom, but also the 1 and 2 and a + symbol above it. This works for nested operations, too, but the ingredients are hidden by default until you tap the box. There’s an ‘undo’ button, which throws away an operation and puts the operands back on the stack – very handy when you tap the wrong operator!

Numbers that you type in directly are shown in blue. You can tap any blue number and enter a new value, and any operations it feeds into are recalculated. I’ve used that quite a few times to set up a formula, such as the quadratic equation, and each time I used it I just need to change the input values and the result appears at the bottom.

It’s also useful for factorising numbers: I can start by typing something like 10199 3 ÷, and I just replace the 3 with different prime numbers until the result is an integer.

After a while, I realised that there was another optimisation to be made: sometimes a formula uses the same variable more than once! For example, in the quadratic formula, $b$ appears twice:

\[ x = \frac{ -b \pm \sqrt{b^2 – 4ac}}{2a} \]

It would be nice if you could use the same number in more than one place, and have every instance update when you change the value of one of them. Every RPN calculator has a ‘copy’ button, to push another copy of the last item on the stack, so I just decided to make copies remember they’re linked. You can move copies of a number around, but when you overwrite one of them, all the others take the new value too.

In order for this to not make your head explode, I needed a way of showing which number boxes are linked together in this way. Asking the user for a name felt like overkill, and would interrupt your flow unnecessarily if you’re not planning on using the overwriting feature.

I came up with a nice solution: when you copy a number, it’s assigned an emoji. All copies of the number have the emoji stuck onto them, so you can quickly tell who they are.

This was way more useful than I expected! While I was testing a horrible question involving cancelling fractions with very large denominators, the linking feature really came into its own. By setting up $n/p$ and $d/p$, I could quickly find common factors of $n$ and $d$ just by changing the value of $p$ until both divisions produced integers. Bonza!

I’m quite happy with my calculator and I haven’t felt the need to go back to RealCalc yet. Hooray!

You can use it too: go to nice-calculator.glitch.me. If you open it on your phone, you can add it to your home screen and it should act like a normal app, instead of a web page.

Google+