by Matt Parker
The software fix arrived at the base in Dhahran on 26 February. The day after the missile attack.
Nothing to worry about
In mathematics, it is impossible to divide numbers by zero. Many an internet argument has raged over this, with well-meaning people maintaining that the answer to dividing by zero is infinity. Except it is not. The argument is that if you take 1/x and let x get closer and closer to zero, the value shoots off to be infinitely large. Which is half true.
This line shows the result of dividing one by numbers close to zero.
It only works if you come at it from the positive direction; if x starts negative and then approaches zero from below, the value of 1/x races towards negative infinity, completely the opposite direction to before. If the limiting value is different depending on the direction you approach it from, then, in mathematics, we say that limit is ‘undefined’. You cannot divide by zero. The limit does not exist.
But what happens when computers try to divide by zero? Unless they have been explicitly told that they can’t divide by zero, they naively give it a go. And the results can be terrifying.
Computer circuits are very good at adding and subtracting, so the maths they do is built up from there. Multiplication is just repeated addition, which is easy enough to program in. Division is only slightly more complicated: it is repeated subtraction and then there may be some remainder. So dividing 42 by 9 requires subtracting as many nines as possible, effectively counting down by 9s: 42, 33, 24, 15 and 6. That took four steps, so 42 ÷ 9 = 4 with remainder 6. Or we can convert 6/9 to a decimal and get 42 ÷ 9 = 4.6666 …
If a computer is given 42 ÷ 0, this system for division breaks. Or rather, it never breaks but goes on for ever. I have a Casio ‘personal-mini’ calculator from 1975 in front of me. If I ask it to calculate 42 ÷ 0, the screen fills with zeros and it looks like it has crashed – until I push the ‘view extra digits’ button and the calculator reveals that it is trying to get an answer and that answer is continuing to rocket up. The poor Casio is continually subtracting zero from forty-two and keeping count of how many times it has done so.
Even older mechanical calculators had the same problem. Except they had a hand crank and required a human to keep literally crunching through the calculation as they continued their futile quest of subtracting zeros. For the truly lazy people of the past there were electromechanical calculators which had a motor built in to drive the calculation crank automatically. There are videos online of people performing a division by zero on these; it results in them spinning through numbers for ever (or until the power is pulled out).
An easy way to fix this in modern computers is to add an extra line to the code telling the computer to not even bother. If you were writing a computer program to divide the number a by the number b, this is some pseudocode of how the function could be defined to avoid the problem:
def dividing(a,b):
if b = 0: return ‘Error’
else: return a/b
The most recent iPhone at the time of writing must have something almost exactly like this. If I type in 42 ÷ 0 it puts the word ‘Error’ up on the screen and refuses to go any further. The built-in calculator on my computer goes one step further and displays all of ‘Not a number’. My handheld calculator (Casio fx-991EX) gives ‘Math ERROR’. I make calculator unboxing videos where I open and review calculators. (Over 3 million views and counting.) One of the tests I always perform is to divide by zero and check what the calculator does. Most are very well behaved.
But, as always, some calculators slip through the gaps. And not just calculators: US Navy warships can get division by zero wrong too. In September 1997 the cruiser USS Yorktown lost all power because its computer control system tried to divide by zero. It was being used by the navy to test their Smart Ship project: putting computers running Windows on warships to automate part of the ship’s running and reduce the crew by around 10 per cent. Given it left the ship floating dead in the water for over two hours, it certainly succeeded in giving the crew some time off.
The prevalence of military examples of maths going wrong is not because the armed forces are particularly bad at mathematics. It’s partly because the military are big on research and development, so they are at the bleeding edge of what can be done, which tends to invite mistakes. Moreover, they have some level of public obligation to report on things which go wrong. Obviously, a lot of undoubtably fascinating maths mistakes never get declassified, but within a private company even more mistakes are completely hushed up. I’m largely limited to talking about mistakes which have been openly reported on.
In the case of USS Yorktown, the details are still a bit hazy. It’s not clear whether the ship had to be towed back to port or if it eventually regained power in the water. But we do know it was a divide-by-zero error. The mistake seems to have started when someone entered a zero in a database somewhere (and the database treated it as a number, not a null entry). When the system divided by this entry, the answer started racing off like a cheap calculator. This then caused an overflow error when it became bigger than the space within the computer memory allocated to it. It took a supergroup of maths mistakes, led by division by zero, to take down a whole warship.
SEVEN
Probably Wrong
Unlikely events can happen. On 7 June 2016 Colombia were playing Paraguay in the 2016 Copa América. The referee flipped a coin to see which football team got to choose which end of the field their goal would be. Except the coin landed perfectly on its edge. After only a moment’s hesitation, and a few laughs from the nearby players who saw it happen, the referee picked the coin up and managed to flip it successfully.
I will accept that falling into grass makes an edge landing more probable. A coin landing on its edge on a hard surface is almost impossible. I believe the coin with the highest chance of landing on its edge is the UK old-style £1 coin (in circulation from 1983 to 2017), which is the thickest coin I’ve seen in daily use. To check how likely it is to land on its edge, I sat down and spent three days flipping one. After ten thousand flips it had landed on its edge fourteen times. Not bad. I suspect the new £1 coin will have similar odds, but I’ll leave those ten thousand flips to someone else.
For something like the much thinner US nickel, I suspect it would take tens of thousands of flips for even a single edge case. But it is still possible. If you want something unlikely to occur, you simply need the patience to create enough opportunities to allow it to happen. Or, in my case, patience, a coin, a lot of free time and the kind of obsessive personality that keeps you sitting in a room flipping a coin by yourself, despite the desperate pleas of your friends and family to stop.
Sometimes the repeated attempts are not so obvious. One of my favourite photos of all time is of someone called Donna, taken when she visited Disney World as a child in 1980. Many years later she was about to marry her now-husband Alex and they were looking through old family photos. Donna showed this photo to Alex, who noticed that one of the people in the background with a pushchair looked like his dad. And it was his dad. And he was the child in the pushchair! Donna and Alex had been photographed together by chance fifteen years before they would meet again and eventually marry.
Obviously, this caught the attention of the media: it had to be fate which caused them to be photographed together. They were destined to marry each other! But it’s not fate; it’s just statistics. It’s like flipping a coin which lands on its edge. The odds of it happening might be incredibly low, but if you heroically try for long enough, you can expect that it will eventually happen.
The coincidence is almost as amazing as someone actually wanting their photo taken with Smee.
The odds of any one couple being photographed together by chance in their youth is incredibly small. But it’s not zero, and I think that is big enough that we shouldn’t be surprised when it happens. Think about how many unknown ‘random’ people there are in photographs of yourself. Hundreds? Thousands? With cameras ubiquito
us in modern phones, I don’t think it is a stretch to estimate that a young person today could be photographed with ten different random people per week. That’s ten thousand people they’re in photographs with by the age of twenty. Of course, there will be some overlap and not everyone in the background of the photos is someone they could go on to marry. So let’s be conservative and say an average human will have been photographed with at least a few hundred anonymous potential marryees.
The chance that a specific person will go on to have a meaningful relationship with one of those few hundred people is incredibly small. There are billions of other people in the world to marry. For someone who does go on to marry, there’s a probability of a couple of hundred out of potentially billions. Those are not good odds. They’re comparable (if not worse) to the probability of winning the lottery. And, like winning the lottery, people such as Donna and Alex should be amazed how lucky they are.
But, like the lottery, we should not be amazed that someone wins. It’s incredible if you win the lottery, but it’s not amazing that someone wins the lottery. You never see newspaper headlines saying: ‘Incredible! Someone won the lottery again this week!’ Because so many people play the lottery, it’s not surprising that people win fairly regularly.
We would not care about Donna and Alex if this coincidence had not happened. They are two arbitrary people living in North America. We only care about them because this photo exists. Even though the chance of this happening to you might be only a hundred out of billions, there are still billions of people it could happen to. My argument is that the population a person could marry and the population this could happen to cancel out. By my logic, across any population we’d expect about as many of these ‘miracle photos’ as the number of times we estimate the average person in that population has been photographed with strangers. There should be hundreds of these photos out there.
I tested this when I was on tour back in 2013 with my show Matt Parker: Number Ninja. I told the story of Donna and Alex and said there should be more bizarre coincidence photographs. And, sure enough, after one show someone came to tell me about a new one that happened to a friend of theirs. This wasn’t a massive tour either: about twenty shows with a total audience of maybe four thousand people. And I still found a new example from someone in the crowd.
In 1993 Kate and Chris met while studying at Sheffield University in the north of England and a few years later decided to go on a world trip. They spent some time on a farm in the middle of Western Australia that was owned by Jonny and Jill, distant relatives of Kate (their nearest relative was her great-great-grandfather, but the families had kept in touch). Jill got out a photo album of her only ever trip to England because there was an image taken somewhere she could not identify.
All the other photos in the album had been labelled with where they were taken, but this was the one photo where Jill did not know the location. She showed it to them and Chris recognized it as Trafalgar Square in London. He continued: ‘Blimey, that bloke looks like my dad. And that looks like my mum. And that’s my sister. And there’s me.’ The photo had been taken on one of his only two childhood visits to London.
Imagine travelling halfway around the world only to be reminded of what you wore as a teenager.
Kate and Chris have now been together for over two decades and told the story about the photo at their wedding as proof that they were meant to be together. I think they should be amazed that they have a photo and a story like this. Most of us do not. But we should not be amazed that it happened at all.
As a depressing bonus thought: don’t forget that, for every one of these photos that is found, there are many more that no one will ever notice. And many, many more which were close to being taken but someone snapped the photo a few seconds before or after the perfect moment. Don’t be disappointed that you don’t have one of these miracle photos: be disappointed that you are much more likely to have walked past a future partner without ever knowing it happened.
Likewise, just because something happens once does not mean it is likely to happen again. It may have just been a lucky sighting of an unlikely event. There was a short-lived game show in the UK a few years ago which was built on uncertain mathematical foundations and in which an early test accidentally worked. I will not name the show or the mathematical friend-of-a-friend of mine who advised on it, but the story is still worth telling.
In the game each contestant was given a target amount of prize money which they needed to earn through some convoluted process. When the maths consultant ran the numbers, they found that the outcome of each game was almost entirely determined by the size of the target. If the target was too high, then there was a very small chance that the contestant would win, even using an optimal strategy. If the target was low, then the contestant would win easily. It would not be much fun to watch a game show where the strategy used by the contestant does not make a difference.
However, the producers decided to ignore the maths. One producer said that he had tried the game at a recent family gathering and his granny had a great time playing it and won the higher amounts a few times. And which should you believe? A comprehensive analysis of the probabilities and expected results of the game show or a few games played by someone’s grandmother? They went with the granny and the show was cancelled mid-season after only the first few episodes had aired because no one ever won the higher prize money.
So it turns out the optimal strategy is to listen to the maths consultant you have hired to crunch the probabilities for you. Because you might just have a lucky grandmother.
A serious statistical error
In 1999 a British woman was sentenced to life in prison for the murders of two of her children. However, the two deaths could have been entirely accidental; every year, just under three hundred babies in the UK die unexpectedly from sudden infant death syndrome (SIDS). During the trial, the jury had to decide if she was guilty of murder beyond reasonable doubt. Was she the perpetrator or the victim in this emotionally charged case? The jury was presented with stats which seemed to imply that two siblings both dying of SIDS was extremely rare. They returned a verdict of guilty (with a majority of ten to two), but the defendant’s conviction was later overturned.
At the trial, erroneous statistics were presented which gave the false impression that there was only a 0.0000014 per cent chance (around one in 73 million) of two babies in such a family dying from SIDS. The Royal Statistical Society claimed there was ‘no statistical basis’ for this figure and was concerned by the ‘misuse of statistics in the courts’.
Upon a second appeal in 2003, the conviction was quashed, the woman having already spent three years in prison. How could maths have gone so far wrong as to convict an innocent woman? The prosecution had taken the probability of a cot death in a family such as this woman’s at one in 8,543 and multiplied 1∕8,543 by 1∕8,543 to estimate the probability of two deaths.
There is a long list of reasons why this is not valid, but the main one is that the two cot deaths are not independent. In mathematics, if two events are independent, then you can multiply their probabilities to find the chance of them both occurring. The chance of pulling the ace of spades from a deck of cards is 1∕52 and the chance of getting heads when you flip a coin is ½. Flipping the coin in no way affects the deck of cards, so we can multiply 1∕52 by ½ to get the combined probability for both happening of 1∕104.
If two events are not independent, then all bets should be off. Or at least, all bets should be thoroughly re-examined. Less than 1 per cent of the US population is taller than 6 feet 3 inches (about 190 centimetres). So if you pick random humans in the US, fewer than one in a hundred will be that tall. But if you pick a random professional basketball player in the NBA, the probability is very different. Height and playing professional basketball are definitely linked: 75 per cent of NBA players are over 6 foot 3 inches tall. Probabilities change if a related factor has already been selected for. SIDS involves possible genetic and en
vironmental factors, so the probability of it happening to a family who has already suffered such a tragedy will be different to the probability in the general population.
And probabilities which are not independent cannot be multiplied together to get the combined probability. Around 0.00016 per cent of the people living in the US play in the NBA (522 players in the 2018/19 season versus a population of 327 million). Naively multiplying that with the 1 per cent probability of being over 6 foot 3 inches tall gives combined odds of one in 63 million of a random population member both being in the NBA and being that tall. But the probabilities are not independent, and that figure incorrectly portrays it as much less likely than it really is. The actual probability is one in 830,000.
The jury was told by an expert witness that the combined probability of two cases of SIDS in the same family was one in 73 million, so they convicted a woman who was later exonerated. That expert witness has since been found guilty of serious professional misconduct by the General Medical Council for incorrectly implying that the deaths were independent.
Getting our heads around probabilities is very hard for humans. But in high-stakes cases like this, we have to get it right.
Flipping difficult
It is easy to trick humans with probability. Here are two games which people consistently get wrong. Feel free to use them to trick any humans of your choosing.
The first is based on a completely fair coin flip. In this case ‘fair’ means that heads and tails are both exactly equally likely (any perfect-edge balance will require a re-flip). So if we had a bet on the coin with you winning on heads (H) and me winning on tails (T), that is entirely fair: we both have the same chance of winning. But a single flip is also a bit boring. So let’s make it more interesting. Let’s bet on three flips in a row; say, you take HTH and I’ll have THH. Now the fair coin is repeatedly flipped until either of those sequences occurs. Don’t like HTH as your prediction? No problem. Choose any of the eight possible options below and you’ll see my prediction next to it. Start flipping a coin. If I win, be sure to post my winnings to me.