This is not unrelated to what I submitted as my entry to The Big Internet Math-Off last summer. I have been revisiting this idea ready for a class next week in my second year programming module.

I have this idea that I am trying to teach my students to program, rather than to write code in a particular language, so I am bullish about throwing them into a different syntax and allowing them to flex their programming muscles. With this in mind, I intend to spend a brief period drawing graphics using TikZ.

My eye was drawn to this picture from the Aperiodvent day 7 entry (which is from this 2015 post by Vicky Neale on Alex Bellos’ Guardian Blog):

I decided to try to recreate these images using TikZ. First, the images. I’m sure the colours could be made prettier, but here is what I got. Click to enlarge.

And now the code. I’m sure it, too, could be made prettier, but it works.

\documentclass[oneside]{article} \usepackage[a4paper,margin=10mm]{geometry} \usepackage{tikz} \begin{document} \pagestyle{empty} ~\vspace{25mm} \begin{center} \begin{tikzpicture} \draw [green, ultra thick] (0,0)--(0,-2); \foreach \i in {0,...,9} { \draw [green, ultra thick] (9-\i,0) -- (0,\i) -- (\i-9,0); } \foreach \i in {0,...,7} { \draw [green, ultra thick] (7-\i,7) -- (0,\i+7) -- (\i-7,7); } \foreach \i in {0,...,5} { \draw [green, ultra thick] (5-\i,12) -- (0,\i+12) -- (\i-5,12); } \draw [red,fill=red] (2,13) circle [radius=0.3]; \draw [yellow,fill=yellow] (-1,13.5) circle [radius=0.3]; \draw [red,fill=red] (-1,9.5) circle [radius=0.3]; \draw [yellow,fill=yellow] (1,9) circle [radius=0.3]; \draw [green,fill=green] (1,8) circle [radius=0.3]; \draw [red,fill=red] (0.8,7) circle [radius=0.3]; \draw [lightgray,fill=lightgray] (-3,7.5) circle [radius=0.3]; \draw [lightgray,fill=lightgray] (1.7,2.7) circle [radius=0.3]; \draw [red,fill=red] (1.2,1.2) circle [radius=0.3]; \draw [yellow,fill=yellow] (-2,1) circle [radius=0.3]; \draw [yellow,fill=yellow] (-2.5,1.5) circle [radius=0.3]; \draw [green,fill=green] (-5,0) circle [radius=0.3]; \end{tikzpicture} \end{center} \newpage ~\vspace{10mm} \begin{center} \begin{tikzpicture}[xscale=0.8,yscale=1.2] \draw [blue,fill=blue] (-11,-10) rectangle (11,10); \foreach \i in {0,...,9} { \draw [yellow, ultra thick] (9-\i,0) -- (0,\i) -- (\i-9,0); \draw [yellow, ultra thick] (9-\i,0) -- (0,-\i) -- (\i-9,0); } \foreach \i in {0,0.2,...,1} { \draw [yellow] (1-\i+9,4) -- (9,\i+4) -- (\i-1+9,4); \draw [yellow] (1-\i+9,4) -- (9,-\i+4) -- (\i-1+9,4); } \foreach \i in {0,0.2,...,1} { \draw [yellow] (1-\i-7,7) -- (-7,\i+7) -- (\i-1-7,7); \draw [yellow] (1-\i-7,7) -- (-7,-\i+7) -- (\i-1-7,7); } \foreach \i in {0,0.2,...,1} { \draw [yellow] (1-\i-8.5,-3) -- (-8.5,\i-3) -- (\i-1-8.5,-3); \draw [yellow] (1-\i-8.5,-3) -- (-8.5,-\i-3) -- (\i-1-8.5,-3); } \foreach \i in {0,0.2,...,1} { \draw [yellow] (1-\i-3,-8) -- (-3,\i-8) -- (\i-1-3,-8); \draw [yellow] (1-\i-3,-8) -- (-3,-\i-8) -- (\i-1-3,-8); } \foreach \i in {0,0.2,...,1} { \draw [yellow] (1-\i+5,-5) -- (+5,\i-5) -- (\i-1+5,-5); \draw [yellow] (1-\i+5,-5) -- (+5,-\i-5) -- (\i-1+5,-5); } \end{tikzpicture} \end{center} \newpage ~\vspace{10mm} \begin{center} \begin{tikzpicture}[scale=1.5] \foreach \i in {0,...,35} { \pgfmathparse{(mod(\i+7,36))*10} \node at (\pgfmathresult:5) (A\i) {}; \pgfmathparse{\i*10} \node at (\pgfmathresult:5) (B\i) {}; \draw [red, ultra thick] (A\i.center)--(B\i.center); } \draw [teal, line width=12] (-1,3) .. controls (1,8) .. (0.3,8.5); \draw [teal, line width=12] (1,3) .. controls (-1,8) .. (0.3,8.5); \draw [teal, fill=teal] (0.3,8.5) circle [radius=0.3]; \end{tikzpicture} \end{center} \end{document}]]>

The result is a command `\stargraph`

, which takes two parameters, the number of radial nodes and the radius in cm of the graph. Here is the definition of `\stargraph`

and its use in a document.

\documentclass{article} \usepackage{tikz} \newcommand{\stargraph}[2]{\begin{tikzpicture} \node[circle,fill=black] at (360:0mm) (center) {}; \foreach \n in {1,...,#1}{ \node[circle,fill=black] at ({\n*360/#1}:#2cm) (n\n) {}; \draw (center)--(n\n); \node at (0,-#2*1.5) {$K_{1,#1}$}; % delete line to remove label } \end{tikzpicture}} \begin{document} \begin{center} \stargraph{7}{2} % usage: \stargraph{number of radial nodes>0}{radius in cm} \end{center} \end{document}

Here is the result of making this document:

]]>So it was that I realised I could enter some Babylonian-style tablets made from gingerbread.

I made a gingerbread reconstruction of a particular tablet, YBC 7289, which Bill Casselman calls “one of the very oldest mathematical diagrams extant“. Bill writes about the notation on the tablet and explains how it shows an approximation for the square root of two. I’m sure I didn’t copy the notation well, because I am just copying marks rather than understanding what I’m writing. I also tried to copy the lines and damage to the tablet. Anyway, here is my effort:

In addition, I used the rest of the dough to make some cuneiform biscuits. I tried to copy characters from Plimpton 322, a Babylonian tablet thought to contain a list of Pythagorean triples. Again, Bill Casselman has some interesting information on Plimpton 322.

Below, I try to give a description of my method.

I tried the recipe given but I don’t know if I mistranslated the American cups measurements, but it came out too dry, so I adjusted the ingredients and tried again before making it the third time for real. Below is a description of what I did.

The idea here is to make a gingerbread that tastes good but crucially has the stiffness to take the cuneiform writing and that doesn’t rise much so the writing stays in place while it cooks. There’s a lot of chilling to harden the dough. I should mention that you make the dough one day and cook it the next.

Ingredients:

- 500g plain white flour;
- 110g soft brown sugar;
- 160g butter;
- 145g treacle;
- 1 medium egg;
- 1 teaspoon bicarbonate of soda;
- 2 teaspoons ground ginger powder;
- half teaspoon cinnamon;
- half teaspoon nutmeg;
- half teaspoon salt.

Method:

Day one, mix the dough.

- Weigh the butter and cut up into lumps, leave on a plate to warm up for at least 20 minutes.
- Mix the dry ingredients in a bowl.
- Add the butter and mix up.
- Add the treacle and egg and mix well. I used a food processor. It made a stiff dough.
- Compress into a bowl, cover with cling film and put in the fridge overnight.

Day two, make the gingerbread.

- Roll out the dough. I made a big tablet and a set of little biscuits. I put a tea towel on the side with greaseproof paper on top, and rolled on this using a rolling pin and some flour. The dough is quite happy to be pushed around and cut up.
- Put the rolled out dough on greaseproof paper on baking sheets and put it in the fridge for half an hour to re-stiffen.
- Cuneiform writing using a square handle of a chopstick. The linked blog post has a lot on this, including a nice video demonstration of the technique. I bought some cheap chopsticks online, and while the handles were square, they were a bit too rounded. This meant the impressions made in the gingerbread were not very clear, especially after baking. My parents had a sharper-handled chopstick and I was able to use this for the real thing. So it is important to get the right tool. I also used a blunt knife for making lines and a teaspoon for scraping out sections of the tablet I was copying that were broken.

- After scribing, refrigerate again while heating up the oven.

- I cooked mine at gas mark 4 for 10 minutes (biscuits) or 12 minutes (large tablet). Our oven is a bit quirky, though, so you might want to experiment. The first go I over-cooked them a little.

Probably by now you are firmly of the view that I am not a recipe writer! There is a lot more detail in the original blog post and I recommend reading this and watching the short video before starting.

I am grateful to Farrell Monaco for sharing her cuneiform gingerbread recipe, and to Bill Casselman for his pages on Babylonian mathematics tablets.

]]>Bernard Bolzano (1781 – 1848) worked to "free calculus from the concept of the infinitesimal" and was born on 5 Oct http://bit.ly/9TV331

— Maths History (@mathshistory) October 5, 2010

That autumn, I looked into the Twitter API and wrote myself a program that would run every day and tweet these little titbits. I loaded some messages into a database and scheduled a daily tweet at 10:23am starting from 16th December 2010.

Johann Radon (1887-1956) worked on the calculus of variations, differential geometry & measure theory & was born 16 Dec http://bit.ly/eAQlSK

— Maths History (@mathshistory) December 16, 2010

Over the months that followed, I slowly built up a database of daily tweets, sometimes managing to get a few weeks ahead of the present, and sometimes missing days and filling them in the following year. Sometime in 2011 or 2012, I had a full year’s tweets in the database. Since then, I have been tweaking. Sometimes someone sends in an error and I make a correction. I’ve also swapped all the URLs from bit.ly (necessary in 2010 to fit the message in a tweet) to the full address. But, generally speaking, the script has pushed a daily mathematician onto the feed every day since then without interference.

Generally speaking, this has had some success. The account currently has about 65k followers. Twitter’s statistics system regularly records 10,000 ‘impressions’ per tweet (which Twitter defines as “Times a user is served a Tweet in timeline or search results”), several times that for a big name. (Though I tried to set up the database to promote less-well-known names and areas, of course the big names cause most interest.)

There is more to history than marking dates and reading biographies, but as an exercise in raising some awareness of history of mathematics, I think it is going pretty well.

And today I sent my last @mathshistory daily mathematician tweet.

Michael Mästlin (1550-1631) Kepler's teacher, publicised the Copernican system, born 30 Sep https://t.co/DVTY0o9Oev

— Maths History (@mathshistory) September 30, 2018

Since BSHM got themselves a web server a little while ago, we have been chatting about moving the daily tweets over to it. I remain a member of BSHM, but I finished my term on Council in 2013. I think it does the Society a lot of good to have full control over its Twitter account and not be relying on me and my server. Over the summer we duplicated the database and code, and over the last few days we’ve been testing it. Now it’s ready to go.

So ends my eight-year run tweeting daily mathematicians from @mathshistory. Tomorrow’s tweet will be served from BSHM. Basically, followers should notice no difference, but for me it will be very strange – the first ever @mathshistory daily mathematician tweet not sent by me.

]]>Nim objects could be anything, of course, but conventionally sticks or stones are used. There are various types of dot in LaTeX that might look like stones, but somehow a line of dots didn’t seem satisfactory. There are various ways to draw a line (not least simply typing ‘|’), including some tally markers (e.g. in hhcount). My problem with these (call me picky) is that they are all identical lines, and a ‘heap’ of them just looks very organised. Really, I want a set of lines that looks like someone just threw them into heaps (though probably without crossings for the avoidance of ambiguity). So I wrote my own.

I used PGF/TikZ. My basic strategy was to draw a thick vertical line in TikZ with a little wobble added so each one doesn’t look extremely well-lined-up with its neighbour, achieved by adding or subtracting a small random number in PGF. This is a command `\drawnimstick`

. On top of this, I made a command `\nimgame{}`

which takes a comma-separated list of numbers and makes a row of Nim heaps with those numbers of sticks. For example, `\nimgame{5,2,3}`

makes a 3-pile Nim game with five sticks in the first pile, two in the second and three in the third. There is no limit to the number of piles or the number in a pile, but this code doesn’t do anything to cope when line breaks start happening because I only anticipate using small numbers of small piles myself.

Here are the definitions of the commands `\drawnimstick`

and `\nimgame{}`

.

% load packages and seed random number \usepackage{pgf,tikz} \pgfmathsetseed{\number\pdfrandomseed} % command \drawnimstick draws a single Nim stick with a little random wobble. \newcommand{\drawnimstick}{% \pgfmathsetmacro{\topx}{(random(0,20)-10)/100}% top of the line: 0 +/- random \pgfmathsetmacro{\botx}{(random(0,20)-10)/100}% bottom of the line: 0 +/- random \begin{tikzpicture}% \draw[very thick] (\topx,0) -- (\botx,0.5);% draws line \end{tikzpicture}% } % command \nimgame takes a comma-separated list of numbers and makes Nim heaps holding those number of sticks \newcommand{\nimgame}[1]{% \begin{center}% \def\listofgames{#1}% \foreach \heap in \listofgames {% picks the numbers from the list \foreach \index in {1, ..., \heap} {% loops for this heap \drawnimstick\hspace{0.5mm}% draws a stick + 0.5mm space }% \hspace{10mm}% 10mm horizontal space between heaps }% \end{center}% }

And here are some examples of it in action:

\documentclass{article} ...(the above definitions here)... \begin{document} % examples Here is a multi-pile Nim game: \nimgame{1,3,2} Here is another multi-pile Nim game: \nimgame{10,20} Here is another multi-pile Nim game: \nimgame{2,3,4,7,6,5} \end{document}

Here is the output of the code above (of course, if you run it again, all the lines shift because the random parameters vary on run time):

]]>I made a silly joke, and it made me think.

You may be aware that our own Christian Lawson-Perfect is running the Big Internet Math-Off here at the Aperiodical, a single-elimination tournament with sixteen competitors. I was knocked out in round one by the brilliant Alison Kiddle. I joked that if Alison went on to win, then I’d be joint second.

Much as I like and respect @ch_nira, I’ll be rooting for @ajk_44. If she goes on to win the #BigMathOff final and is crowned The World’s Most Interesting Mathematician, then I’m joint-second, right? https://t.co/8Jt37gHFif

— Peter Rowlett (@peterrowlett) July 10, 2018

I’ve been mulling this over and I felt there was something there in thinking about the placement of the non-winners in such a tournament, so I had a play.

I started by doing the only sensible thing: I used an online random name generator to generate sixteen names and arranged them into eight first-round matches. Lacking an actual competition and with the Big Internet Math-Off in recent memory, I decided each match by generating a random number $0$-$100$ for one opponent and taking $100$ minus this for the other. Think of it, if you like, as percentage of a public vote. Thankfully, there were no draws, so I didn’t have to invent a tiebreaker rule.

Here’s the outcome, written up using this lovely LaTeX tournament code example.

Clearly, Michal wins, by winning the final. But who came second? Norah lost the final, so clearly has a claim to being second. She won one fewer match than did the winner.

But what about Betsy? Michal beat Betsy, so if we choose to believe the fiction of the tournament, Betsy is worse (at being assigned a random number $>50$) than Michal. But is she better or worse that Norah? Think about it. I’d say we don’t know, because this hasn’t been tested. We know Michal is better than Betsy, and Michal is better than Norah, but whether Betsy is better or worse than Norah is untested. All we can do, therefore, is award them joint second place. They both lost one match, to Michal, and they didn’t play each other.

But there are a bunch of other people who also lost only one match to Michal and haven’t played each other. If they hadn’t been knocked out, perhaps they could have gone on to win, or at least prove themselves better than one of our second-place candidates. So perhaps they are all joint second. The people Michal knocked out are: Norah, Betsy, Camilla and Maia.

By the same logic, if you were knocked out by a second-place competitor, you might have a claim to being joint third. As Michal beat Norah and Norah beat Yasmin, there’s a clear ordering here that puts Yasmin third. But Siobhan, who was beaten by joint-second-place Betsy, hasn’t played Yasmin, so I don’t think we can reasonably say Yasmin is better (at being assigned a random number $>50$) than Siobhan. The people beaten by a second-place competitor are: Yasmin, Iris and Amirah (knocked out by Norah), Cathy and Hiba (knocked out by Betsy) and Abigail (knocked out by Camilla).

Who was knocked out by a third-place competitor? Lacie and Judy (knocked out by Yasmin), Niamh (knocked out by Iris) and Siobhan (knocked out by Cathy). By the same logic, these are joint fourth place.

There is now only one competitor not placed: Agnes, who was knocked out by Lacie. An argument could be constructed to put her as the only competitor in fifth place.

Here’s a diagram showing the tournament with these placements.

So in the **final**, we have two competitors: one in first place, one in second.

In the **semi-finals**, four: one first, two second and one third. That is, the two from the final are there in their original positions, plus they each knock out one competitor who is, therefore, placed one less than them.

In the **quarter-finals**: one first, three second, three third and one fourth.

In the **first round**: one first, four second, six third, four fourth and one fifth.

Round | 1st | 2nd | 3rd | 4th | 5th |
---|---|---|---|---|---|

Final | 1 | 1 | 0 | 0 | 0 |

Semi | 1 | 2 | 1 | 0 | 0 |

Quarter | 1 | 3 | 3 | 1 | 0 |

1st | 1 | 4 | 6 | 4 | 1 |

Do we recognise these numbers? Labelling from the final backwards, at each stage we keep the competitors from the stage that happens after it in their places and add as many again that they knocked out, each one place below them. So, e.g., the number of second place competitors in the semi-final is the sum of the number of first and second place competitors in the final. In general, the number in column $m$ in row $n$ is made from the number who were in column $m$ in row $n-1$ plus the number in column $m-1$ in row $n-1$. We are making Pascal’s triangle.

I don’t think about single-elimination tournaments very much (I didn’t know the term until very recently), probably because I have little-to-no interest in sport. Is this result obvious to everyone? I appreciate it’s not the most practical way to look at a tournament — I’m not sure that anyone would seriously buy my argument that someone who rocked up in round one and won nothing, but happened to be playing the eventual winner, deserves joint second-place with the person who won three matches to be knocked out in the final. But as a bit of fun with logic, I thought it was quite nice.

Sadly, Alison was knocked out in the second round by Nira Chamberlain, so, depending on Nira’s performance in later rounds, the best I can hope for is joint-third place, and I might yet be fifth.

]]>This claim was famously made by Carl Sagan in the seminal programme Cosmos.

The cosmos is rich beyond measure. The number of stars in the universe is larger than all the grains of sand on all the beaches of the planet Earth.

More or Less come to a fairly standard answer, that Sagan was correct. This sort of problem, which involves approximating unknowable numbers based on a series of estimates, is called a Fermi problem. I’ve written about Fermi problems here before. The More or Less approach to answering this raised a question from a reader of this blog.

But that's less than a factor of 3 difference! For Fermi estimates of numbers of that size, those two answers are essentially the same. It wouldn't take much of an error in either estimate to push sand ahead of stars…

— Paul Taylor (@aPaulTaylor) July 8, 2018

Alright, actually Paul is one of the writers of this blog, rather than a reader. Even so, are his concerns warranted?

The numbers in the More or Less piece are

- for stars: “1 followed by 22 zeros” (approx. 4:18 in the podcast audio), described as 10 sextillion;
- for sand: “3.65 with 21 zeros after it” (approx. 8:30), described as about 4 sextillion.

Fermi estimation involves making order-of-magnitude estimates based on informed guesses about the inputs. (Listen to the More or Less piece if you want to hear this process in action.) Then, given the level of estimation, you aren’t supposed to take too seriously differences within the same order of magnitude – 3 million and 5 million can’t be taken to be seriously different – but if one number comes out at least an order of magnitude bigger than the other, you take this to be your conclusion. In that sense, what More or Less did was correct – 10 sextillion is one order of magnitude bigger than 4 sextillion and so, we conclude, bigger.

There is an uncomfortable feeling which comes from how similar these numbers are, given the amount of guessing involved. Something about comparing so-many sextillions and some-other-number-of sextillions seems like there isn’t that much difference. Actually, the difference between $4 \times 10^{21}$ and $1 \times 10^{22}$ is $6 \times 10^{21}$, so we’d need More or Less to have missed out more than half the sand on Earth in estimating to have come to the wrong conclusion.

There are people who’ll tell you that the only number to pay attention to in a Fermi estimate is the $10^n$ term, because the other is just noise. But this leads to awkwardness. In this case, $4 \times 10^{21}$ is four times bigger than $1 \times 10^{21}$ but only two-and-a-half times smaller than $10^{22}$. Can we really say $1 \times 10^{21}$ and $9 \times 10^{21}$ are effectively the same, while $10 \times 10^{21}$ is significantly bigger?

It’d certainly be a clearer conclusion if the numbers came out several orders of magnitude different, but then obviously very differently-size numbers wouldn’t make for such an interesting piece of rhetoric, would they? The real question you have to ask, then, is whether any doubts you have about the way each number was estimated amounts to a big enough difference in either number.

I guess it is also possible to think about this estimation method too seriously — it’s only really designed to give a rough-and-ready, back-of-the-envelope guesstimate. There’s something about the way the More or Less piece suddenly comes to a conclusion and ends, with a definitive-sounding “Carl Sagan was right” and “he nailed it”. I’d say a few more caveats would have been appropriate. Some discussion of upper and lower bounds, or just an acknowledgement of how much error would cause the conclusion to flip, might have been nice. Paul points out, and I think he’s right, that the fact these numbers are pretty close is remarkable, and perhaps this could have been remarked upon. So, in conclusion, I don’t think the More or Less conclusion is necessarily wrong, but it could have been framed better.

]]>Yesterday morning, my son and I did something similar with our cat, Tabby. This is in response to Matt Parker’s latest initiative, Psychic Pets. Matt is hoping to get thousands of pet owners to make predictions, in order that the odds are good a pet can be found which predicted all prior results for both teams in the final. The good news is it’s fairly straightforward to take part.

Matt’s made a video which explains.

And, for readers who are teachers, there are teaching resources related to the project from Think Maths.

I figure there are teams people Matt reaches are more likely to pick and some that are likely to be less well-picked, and so chose Peru to help Matt get good coverage and because their first match was later the same day. I wrote out sheets with team names and ‘draw’, and offered Tabby the choice of each combination of sheets with a cat biscuit on it. (I’m not completely on top of the details of the World Cup, but the Psychic Pets website has all the info.) Tabby is the sort of cat who will do almost anything for a cat biscuit, even take part in one of Matt’s silly projects. She made her basic three predictions, which I videoed and uploaded to the site.

Made a contribution for @standupmaths’ latest stupid project, @PsychicPets.

You can do it too! https://t.co/yGgW5rI6YB pic.twitter.com/mmHRrmFH9Z— Peter Rowlett (@peterrowlett) June 16, 2018

Well, it didn’t take long to learn that her first prediction, Peru for the win, wasn’t to be. Pat Parslow pointed out on Twitter that this doesn’t prove my cat isn’t psychic — she could be toying with me. But, either way, it doesn’t help advance Matt’s cause.

But, while it’s too late for Tabby, do you have a pet and could get involved? Get started at Psychic-Pets.com.

]]>Enrico Fermi apparently had a knack for making rough estimates with very little data. Fermi problems are problems which ask for estimations for which very little data is available. Some standard Fermi problems:

- How many piano tuners are there in New York City?
- How many hairs are there on a bear?
- How many miles does a person walk in a lifetime?
- How many people in the world are talking on their mobile phones right now?

Hopefully you get the idea. These are problems for which little data is available, but for which intelligent guesses can be made. I have used problems of this type with students as an exercise in estimation and making assumptions. Inspired by a tweet from Alison Kiddle, I have set these up as a comparison of which is bigger from two unknowable things. Are there more cats in Sheffield or train carriages passing through Sheffield station every day? That sort of thing.

The point of these is not to look up information or make wild guesses, but instead to come up with a back-of-the-envelope, ‘wrong, but useful‘, orders of magnitude estimate. Some ‘rules’, if you want to play with these the way I would:

- don’t look up information;
- don’t make precise calculations using calculator or computer;
- be imprecise — there are 400 days in a year, people are 2m tall, etc.;
- round numbers where possible and calculate in your head.

One approach is to estimate by bounding – come up with numbers that are definitely too small and too large, and then use an estimate that is an average of these. But which average?

Say I think some quantity is bigger than 2 but smaller than 400. The arithmetic mean would be $\mathrm{AM}(2,400)=\frac{2+400}{2}=201$. The geometric mean would be $ \mathrm{GM}(2,400)=\sqrt{2\times 400} = 28.28\!\ldots$.

Which is a better estimate? The arithmetic mean is half the upper bound, but 100 times the lower bound. On this basis, for an ‘order of magnitude’-type estimate, you might agree that the geometric mean is a better average to use here. Following my Maths Jam talk, Rob Low said that the geometric mean makes more sense for an order of magnitude estimate, since it corresponds to the arithmetic mean of logs. To see this, consider \[

\begin{align*}

\log(\mathrm{GM}(A, B)) &= \log(\sqrt{AB}) \\

&= \log((AB)^{\frac{1}{2}}) \\

&= \frac{1}{2}\log(AB) \\

&= \frac{1}{2}(\log(A) + \log(B)) = \mathrm{AM}(\log(A), \log(B)) \text{.}

\end{align*}

\]

So, geometric mean it is. However, taking a square root is not usually easy in your head, and we want to avoid making precise calculations by calculator or computer. Enter the approximate geometric mean.

For the approximate geometric mean, take $2=2 \times 10^0$ and $400=4 \times 10^2$, then the AGM of $2$ and $400$ is: \[ \begin{align*}

\frac{2+4}{2} \times 10^{\frac{0+2}{2}} &= 3 \times 10^1\\

&= 30 \approx 28.28\!\ldots = \sqrt{2\times 400} = \mathrm{GM}(2,400) \text{.}

\end{align*} \]

Why does this work? Let $A=a \times 10^x$ and $B=b \times 10^y$. Then \[

\begin{align*}

\mathrm{GM}(A,B)=\sqrt{AB}&=\sqrt{ab \times 10^{x+y}}\\

&=\sqrt{ab} \times 10^{\frac{x+y}{2}} \text{,}

\end{align*}

\]

and \[\mathrm{AGM}(A,B) = \frac{a+b}{2} \times 10^{\frac{x+y}{2}}\text{.}\]

Setting aside the $10^{\frac{x+y}{2}}$ term, which appears in both averages, is it obvious that, for single digit numbers $>0$, \[\mathrm{GM}(a,b)=\sqrt{ab} \approx \frac{a+b}{2}=\mathrm{AM}(a,b) \text{?} \]

There is a standard result that says \[ \begin{align*}

0 \le (x-y)^2 &= x^2 – 2xy + y^2\\

&= x^2 + 2xy + y^2 – 4xy\\

&= (x+y)^2 – 4xy \text{.}

\end{align*} \]

Hence \[ \begin{align*}

4xy &\le (x+y)^2\\

\sqrt{xy} &\le \frac{x+y}{2} \text{,}

\end{align*} \]

with equality iff $x=y$. So $\mathrm{GM}(a,b)\le\mathrm{AM}(a,b)$, but are they necessarily close?

By exhaustion, it is straightforward to show (for single-digit integers, given the rule to round numbers where possible) that the largest error occurs when $a=1$ and $b=9$. Then \[ \sqrt{1 \times 9} = 3 \ne 5 = \frac{1+9}{2} \] and the error is $2$ which, relative to the biggest number $9$ might be seen as quite significant.

I’d say you are not likely to use this method if the numbers are of the same order of magnitude, because the idea is to come up with fairly wild approximations and if they were quite close it might be sensible to think of them as not really different. Then the error is going to be at least one order of magnitude smaller than the upper bound, i.e. $10^\frac{x+y}{2} \ll 10^y$. For example, if your numbers were $1$ and $900$ (as a pretty bad case), then: \[ \mathrm{GM}(1,900)=\sqrt{900}=30 \ne 50=\mathrm{AGM}(1,900) \] and a difference of $20$ on a top value of $900$ is not as significant as a difference of $2$ was on a top value of $9$.

So I suppose I would argue that this makes the error relatively insignificant. However, this thinking left me somewhat unsatisfied. I felt there ought to be a nicer way to demonstrate why the approximate geometric mean works as an approximation for the geometric mean. Following my talk at Maths Jam, Philipp Reinhard has been thinking about this, and he will share his thoughts in a post here in a few days (the post is now online).

I didn’t have time to fit into my talk what I would recommend if the two numbers differed by an odd number of orders of magnitude. For example, $\mathrm{AGM}(1,1000)$ generates another square root in $1 \times 10^{\frac{3}{2}}$ – precisely what we were trying to avoid! What I have recommended to students is to simply rewrite one of the numbers so that the difference in exponents is even. For example, writing $1=1 \times 10^0$ and $1000 = 10 \times 10^2$ gives \[\mathrm{AGM}(1,1000)=5.5 \times 10^{1} \text{.}\]

Following Maths Jam, the esteemed Colin Beveridge made the sensible suggestion of just treating $10^{\frac{1}{2}}$ as $3$, making \[

\begin{align*}

&\mathrm{AGM}(1,1000)\\

&= 1 \times 10^{\frac{3}{2}}\\

&\approx 1 \times 3^3 = 27\text{.}

\end{align*}

\]

This increases our problems, though, because we have the potential to deal with larger differences (hence larger errors) than when dealing with single-digit numbers. Actually, it was wondering why this increased error happens that got me thinking seriously on this topic in the first place. I’ll stop now to let Philipp share what he has been thinking on this.

]]>I just noticed that last Wednesday was ten years since that lecture. It was basic maths for forensic science students. I was given a booklet of notes and told to either use it or write my own (I used it), had a short chat about how the module might work with another lecturer, and there I was in front of the students. That was spring in the academic year 2007/8 and this is the 21st teaching semester since then. This one is the 15th semester during which I have taught — the last 12 in a row, during which I got a full-time contract and ended ten years of part-time working.

I have this awful feeling this might lead people to imagine I’m one of the people who knows what they are doing.

P.S. The other thing that I started when I started working for the IMA was blogging – yesterday marks ten years since my first post. So this post represents the start of my second ten years of blogging.

]]>