### Tags

### Related Posts

### Share This

# The Code part 3

This week’s review of The Code has been delayed a day as I was at the cinema on Wednesday night. Saw Super 8, the new film from JJ Abrams. Like others films he has directed it’s a good film. I always hope that one day he might do a great film – this isn’t it.

Back to the TV review. In this week’s programme we saw Marcus du Sautoy risk his life to show his belief in “The Code” when he calculated where a 30kg ball would land and sat just beyond the landing spot. Given that the series has used special graphics effects (this week was full of “tilt shift” effects where the focus has been monkeyed around with to achieve a miniaturization look) one may doubt the event. Particularly as later in the programme effects were used on the ball to make it fall short and go into orbit. However, it did look like he really did the stunt! Quite brave for a man who says he can’t do arithmetic.

Anyhow, leaving aside the distractions, what was the show about? Prediction mainly. When can we use mathematics to predict what will happen? Quite often is of course the answer. Du Sautoy brought in Christopher Columbus, starling flocks, ants, rock-paper-scissors, serial killers, chaos, lemmings, weather prediction, the butterfly effect, the wisdom of crowds, forecasting flu with Google (the number of web searches for flu symptoms and remedies follows the incidence of flu in the population – fancy that!) and looking for patterns in cities. The latter featured an interview with Geoffrey West who recently gave a TED talk. (I think the talk will feature in my new course on making presentations as an example of what not to do!)

Most of the uses of mathematics were legitimate but the use in catching criminals seemed dubious. The example given involved using the seemingly random locations of the 36 Mardi Gra [sic] bombs in the 90s to predict the location of the bomber or bombers. It turned out that the bombers lived close to the area predicted by the mathematics. Unfortunately, the predicted area was huge and would have been of no use to police, and in fact the bombers were caught in the end by good old-fashioned coppering. It was the sort of result that looked good in hindsight, more of a postdiction than a prediction!

More successful was the prediction of the volatility of lemming populations. It has been known for many years that Disney faked the famous lemming suicide film and so the suicide explanation for huge variation of the lemming population is of no use.

In case you weren’t taking notes, the population is modelled by the logistic equation (or map) which is

where is the total population, is the population in the next cycle, and is the population growth rate. The value gives a nice and steady population, gives an oscillation and gives chaos, which is what we see for the lemmings.

So that’s it, the series is over. All that is left is for someone to use the clues, break the code and find the hidden treasure. Hmmm, was that a 6 in the bird flock?

I’ve broken Excel before with that equation. Apparently, even though they give you many, many cells, they don’t want you to actually use them all. I was looking at the behaviour of the system after many generations, so I had R from 0 to 4 (in iterations or .1 or .01 or smaller, it was a few summers ago) and successive Ps going along the right. After a few hundred generations I grabbed all the data and threw it in a graph, to get the fairly iconic image that is probably in the show. Oh, and used the random number generator to give the initial population.

Anyway, there was a noticeable delay whenever I updated the sheet. A nice property was that the final graph looked pretty much the same regardless of the initial population.

I was doing it in Excel because I wasn’t on my own computer, and very, very bored at the time.

There’s no need to apologize for the use of Excel – we’re all friends here. Actually, I’m surprised at what can be done with Excel. Mind you, back in the 90s when the national Teaching Quality Assessment was done here at Leeds one of the panel recommended that we use spreadsheets to teach maths. We ignored him…

the formula Pn = R.P.(1-P) can’t be right to give the numbers of population …

Actually it says Pn = R(P -P.P), also negative all the time and very steady for every value of R…

I think the formula should be:

Pn = R.P – R.P.d where d represents the percentage of death in a given year, so it would be:

Pn = R.P.(1-d)

Well, I think many things in the programmes could have been prefaced with “It’s a little more complicated than this, but …”. You can make the population formula as complicated as you like (predators anyone?) to try and improve the modelling. The standard way of introducing the formula is the simple form used in the programme. If anyone is interested see the Wikipedia entry for more information on the map.

Could have sworn there was a 6 in the starling flock. Watched it twice as Marcus du Sautoy turned to face the camera. But why?

I though it might be a clue for the competition associated with the programme. See the BBC webpage.

Carlo is absolutely correct, the formula as stated by Marcus du Sautoy is incorrect. If P represents the population the previous year, there are three possibilities.

The first two possibilities are P=0 and P=1. In both cases, Pn=0 and remains there.

The third possibility is that P>1. In that case, (1-P) is negative and, therefore Pn is negative. Absurd.

For the correct formula, see http://people.maths.ox.ac.uk/dusautoy/Jenny%27s%20Scans/Sexy%20Maths/Times2-20090429-Pushing-the-lemming-theory-over-the-edge.pdf

It’s amazing that Marcus would produce this program with such a gross error.

I don’t think it such an error and I don’t think Marcus can be blamed too much. The problem is that he is restricted because he is making a TV programme and can’t go deeply into the subject. Something has to be left out. The letter P represents the population, but what he left out (or discreetly tried to hide) is that P is not

equalto the number of lemmings. It is the proportion of lemmings compared to some notion of the maximum possible number that the environment can handle. Hence P is a number between 0 and 1. Using this we get the chaotic behaviour seen.Actually the oscillation appears when R = PI =(approx.) 3.141592653 and chaos appears when R = (PI+4)/2 =(approx.) 3.570796327

Here’s a little PHP program i wrote. From another website

i learned you need to add a max population to the formula.

<?

// Lemming growth

$p=100; // Initial population

$r=3.2; // reproduction rate , at 4 all die and below 1.

$k=5000; // max population

for ($i=1;$i<1500;$i++){ // loops 1500 generations

$tot=$r*$p*(1-$p/$k); // the formula

$p=$tot;

if ($tot<0){$tot=0;}

$tot=intval($tot);

print "$i $tot”;

if ($tot==0){print “All Dead”;break;}

}