*The Mathematics of Secrets* kicks off with a pretty decent chunk of introductory linear algebra in the service of basic substitution ciphers, preceded by a few pages of terminology. This is introduced apologetically as an unfortunate necessity, but some of the explanation could be handled better. Part of the rundown is handed off to the following quote from David Kahn, none of the terms in which have previously been defined (the ellipses are the book’s, not mine):^{2}

A code consists of thousands of words, phrases, letters, and syllables with the codewords or codenumbers…that replace these plaintext elements….In ciphers, on the other hand, the basic unit is the letter, sometimes the letter-pair…, very rarely larger groups of letters….

Clear? Once the book gets going, it offers a pretty good explanation of a variety of different encryption techniques from simple substitution ciphers through to modern stream ciphers and key exchange systems, as well as the strategies used to attack them. In one of the most accessible sections, Holden explains a particularly elegant system for cracking ‘polyalphabetic’ substitution ciphers: ones where the encoded ‘ciphertext’ is produced by switching to a different substitution cipher ‘alphabet’ after each letter, in particular the case where a relatively small number of alphabets are used in rotation. The first thing to work out is the length of the cycle: how long before the encoding alphabets repeat? One method of finding this is to compute the “index of coincidence”: the probability that two randomly chosen letters of the ciphertext are the same. For a normal ‘monoaphabetic’ cipher this would be the same as for unencoded text: about $0.066$ for English. The more alphabets are used, the nearer this number gets to $1/26=0.038$, the value for a string of random letters. The value your ciphertext gives you suggests a rough value for the number of alphabets, give or take one or two. A second approach is to look for short strings of three or four letters that show up twice in the ciphertext. Some of these will be coincidental, but more will arise from repetitions in the message that happen to get encoded using the same sequence of alphabets. In that case, the distance between the repetitions must be a multiple of the number of alphabets. So any particularly prevalent factor among the distances-between-repeats is a good bet for the number you’re looking for. The two methods combine perfectly, since the second will give you candidates that are unlikely to be close in value, so the approximate value gained from the first should settle which is the correct one. Once you know the number of alphabets, you can split the message up and attack the parts with normal frequency analysis. Holden explains this clearly, with the full details and a couple of examples in case you want to have a go yourself. (I don’t know how challenging these informal exercises are — I had a review to get on with — but I’m guessing they’re less intense than *The Code Book*‘s cipher challenge, which stood unsolved for thirteen months despite a £10,000 prize.)

Towards the middle of the book, some of the discussion of real-world implementations of modern cipher systems towards can get a little mystifying. A flurry of ‘key schedules’, ‘S-boxes’ and ‘P-boxes’ seem to be chained together in specific arrangements it’s hard to muster up much enthusiasm for. Perhaps some of these details could have been relegated to appendices and more time spent on the general aims of these systems, which I think I am still a little hazy on. The version of the book the publishers sent us was also marred in a couple of places by typographical annoyances. Ciphertext is marked out in the main prose in small caps, but plaintext (unencoded messages) are not distinguished at all, producing the momentarily baffling sentence on page 46 “The plaintext letters at repeat 4 times”. And in one unfortunate instance, factorial signs have been omitted leading to the startling claim that $12 = 479,001,600$.

Things get going again when it’s time for the fun stuff. The seemingly-impossible shenanigans of public-key encryption, where the two parties can concoct some secret numbers that only the two of them know despite all their communication being entirely public, is well-explained. As are the newfangled elliptic-curve-based systems that might one day replace all that current mucking about with massive semiprimes, and the exciting world of quantum cryptography, where the preposterous properties of protons are corralled into a fundamentally unbreakable code system. This more theoretical stuff seems to me a lot more interesting than worrying about why a P-box was added at the beginning and end of the DES standard (even the author seems unsure: “Apparently, the P-boxes are merely there to make the data easier to handle on the original chip”). Unless you have a particular interest in the gnarlier details, a few pages might prove skippable, but otherwise this is a decent tour of cryptography for anyone who wants to go a bit deeper than Simon Singh took them.

Joshua Holden: The secrets behind secret messages: press release from the publishers with an interview with the author

The Mathematics of Secrets at Princeton University Press

- I will in this review unapologetically make no attempt to maintain any distinction between the terms code and cipher; cryptography, cryptanalysis and codebreaking, etc.
- Khan is introduced as “author of perhaps the definitive account of the history of cryptography”. Obviously, I beg to differ.

Bonus challenge: See if you can count how many times Katie accidentally says ‘compass’ instead of ‘pair of compasses’ during the video.

]]>I’d half-remembered Katie’s friend’s Dad’s golf tournament problem and made a guess about the root of the difficulty she was having, but on closer inspection it wasn’t quite the same. I’m going to try to recount the process of coming up with an answer as it happened, with wrong turns and half-baked ideas included.

Here’s a summary of what she told me:

- There are 7 groups, each with a leader (who must be in charge of the choreography or something)
- There are five timetable periods available, each an hour long.
- Each dancer should get at least 3 hours’ rehearsal time.
- Some students belong to more than one group.

She also gave me the list of dancers in each group. (Names have been changed to make the maths easier)

I could’ve pretended these are their real names, but then this post would have to be about the astronomically unlikely coincidence of being presented with a real-world maths problem with such helpfully ready-made notation.

1: Amelia | Bmelia | Cmelia | Dmelia | |
---|---|---|---|---|

2: Emelia | Dmelia | Fmelia | Gmelia | |

3: Hmelia | Cmelia | Imelia | Jmelia | Kmelia |

4: Lmelia | Mmelia | Nmelia | Omelia | |

5: Pmelia | Gmelia | Qmelia | Rmelia | |

6: Smelia | Rmelia | Tmelia | Umelia | |

7: Vmelia | Smelia | Pmelia | Tmelia | Jmelia |

SIL was concerned that among the people in two groups were the leaders of two other groups – Smelia and Pmelia. I wasn’t sure that this made any difference, but it was an extra bit of information to bear in mind in case it later led to a complication I hadn’t thought of.

My first instinct was that I needed to come up with an individual timetable each dancer. SIL’s original email wasn’t very clear about what exactly she needed, so I thought that giving each dancer 3 hours would turn out to be difficult – maybe the room can only accommodate so many people at once, for example. With that in mind, I set about looking for ways to assign dancers to periods while maximising the length of time groups had together.

First: if every dancer gets exactly 3 hours’ rehearsal, is it possible to look at every permutation of timetables and rank them by how well they fit the constraints? In other words, **can I brute force it**?

There are 20 dancers, each of whom need to be timetabled in 3 of 5 periods, so 12 dancers in each period. That’s ${20 \choose 12} = 125970$ choices of dancers for each period, and a total of

\[125970^5 = 31720180268697990275700000 \]

timetables for the whole class. Most of those will be invalid, giving some dancers more or less rehearsal time than they need, but any number wider than your field of vision is a bad candidate for brute forcing.

Alternately, each dancer is assigned 3 out of 5 periods, and that happens for each of the 20 dancers. Looking at it this way, there are

\[ {5 \choose 3}^{20} = 10^{20} = 100000000000000000000 \]

timetables to consider. While that’s a million times smaller than my first guess and the least significant digit is starting to hove into my peripheral vision, that’s still far too big. so I think brute forcing is out, and I’ll have to **do some thinking**.

I’m not very good at thinking.

Strategy 2: **get someone else to do it, preferably a computer**.

This is some kind of linear programming problem, so I did a quick google and ended up at GLPK: the GNU Linear Programming Kit. I’d never heard of it before, but further googling led to this program to solve the knapsack problem on wikibooks.org which looked enticingly gnomic:

# en.wikipedia.org offers the following definition: # The knapsack problem or rucksack problem is a problem in combinatorial optimization: # Given a set of items, each with a weight and a value, determine the number of each # item to include in a collection so that the total weight is less than a given limit # and the total value is as large as possible. # # This file shows how to model a knapsack problem in GMPL. # Size of knapsack param c; # Items: index, size, profit set I, dimen 3; # Indices set J := setof{(i,s,p) in I} i; # Assignment var a{J}, binary; maximize obj : sum{(i,s,p) in I} p*a[i]; s.t. size : sum{(i,s,p) in I} s*a[i] <= c; solve; printf "The knapsack contains:\n"; printf {(i,s,p) in I: a[i] == 1} " %i", i; printf "\n"; data; # Size of the knapsack param c := 100; # Items: index, size, profit set I := 1 10 10 2 10 10 3 15 15 4 20 20 5 20 20 6 24 24 7 24 24 8 50 50; end;

Unfortunately, the documentation for GMPL, the language used by GLPK, is hard both to find and to read.

For reference, here’s the GMPL language reference. It’s a breezy 70 pages, but my eyes go fuzzy when I look at it.

While I could probably get it to find a solution for me, I’d probably spend longer learning how to write the program than I would have spent coming up with the answer on my own. So, I made a mental note to learn all about GMPL at a later date, because it does look rather marvellous, and decided to phone SIL and fish for more hints.

On talking to SIL, it turned out **I was solving the wrong problem**! I’d assumed there’d be a constraint on the number of dancers who could rehearse at once, and that dancers wouldn’t want to be assigned more than 3 periods, so the problem would be putting the right people in the room at the same time. That wasn’t the problem at all: everybody can rehearse at the same time, and SIL was perfectly happy to work her charges like dogs for the full 5 periods if required. The real problem was how to make sure that each group leader got at least 2 hours with their whole group. So even if everybody’s in the room for all 5 sessions, the timetable should tell them which group’s dance they should be rehearsing at any time.

Suddenly, the problem looked a lot more manageable: for the sake of simplicity, I can begin by assuming everyone’s in the room, and I just need to assign periods to groups, making sure not to timetable two groups sharing a dancer in the same period.

I immediately returned to a little doodle I’d made while thinking about how to avoid thinking earlier.

While some dancers belong to two groups, no dancer belongs to three groups. That’s good: if a dancer belongs to three groups, then it’s impossible to give all three of those groups two hours rehearsing with all their members, since there are only 5 hours available.

Next I thought about the timetable from the perspective of a dancer who belongs to two groups: for two hours they’ll be with one group, for two different hours they’ll be with the other, and there’s another hour spare. If I can split the groups into two sets so that none of the groups in each set have a dancer in common, I’m done: I can timetable the groups in the first set to dance together for the first two hours, and then the groups in the second set will dance together in the two following hours.

So **I needed the graph I’d drawn above to be bipartite**. Unfortunately, it isn’t:

No matter how I shuffle things about, that triangle involving groups 5,6 and 7 will scupper any attempt to draw a bipartite graph. It also became clear at this point that group 4 is either really unpopular or really snooty.

So, it was impossible. But at least **now I know it’s impossible!** I rang SIL to tell her the good news: she hadn’t wasted hours stupidly, it really isn’t possible to timetable her groups fairly. SIL’s sister (aka my wife) told me not to bother her with the details, but I felt that my findings were only good news if I explained my reasoning. At least I didn’t use the word ‘bipartite’. To offer extra comfort, I worked out that the only spanner in the works was **Pmelia**: she belongs to groups 5 and 7, and only removing her edge from the graph would make it bipartite.

I asked if it would be possible to swap Pmelia out of group 7 for one of the members of group 4, maybe Nmelia. Unfortunately, SIL said that wasn’t possible. So, having realised that Pmelia was the problem (should’ve guessed: alliteration is a powerful epistemological tool), I came up with a “least-bad” timetable:

- In the first two periods, groups 2, 3 and 6 should rehearse with all of their dancers.
- In the following two periods, groups 1, 5 and 7 should rehearse with all of their dancers, but 7 will have to make do without Pmelia.
- In the fifth period, group 7 should rehearse for another hour, with Pmelia included this time.
- Group 4 can do whatever the heck they like.

Now, having had all this marvellous insight, there was still the chance that my timetable would be unacceptable for some reason SIL hadn’t yet mentioned, but I got lucky and she was very happy with it. She did ask what the dancers should do when they’re not timetabled. Rather than get bogged down in more unwelcome thinking, and since SIL didn’t have any particular aims for them, I told her to get them to sort themselves out: there’s no point making up a rule unless you really need to.

So, that’s the story of how I accidentally got my graph theory wedged in my sister-in-law’s dance class. I quite like the simplicity of my final answer, though I expect I’ll carry a grudge against people called Pmelia for a long while.

]]>The Carnival rounds up maths blog posts from all over the internet, including some from our own Aperiodical. See our Carnival of Mathematics page for more information.

]]>(Apologies that the last few seconds of the video cut off – apparently the 10-minute limit is actually a 9:49 limit and YouTube declined to notify me of this, or that they’d cut the end off.)

]]>I quite enjoyed describing about what I do, so I’ve decided to reproduce my answers here. Enjoy!

**Your Name: **Christian Lawson-Perfect

**Your Age: **31

**Your Work Place: **Newcastle University

**Your Job Title: **Mathematician / e-learning officer *(officially it’s only the second one of those two, but that’s a hopelessly vague title; ‘mathematician’ gets you much closer to imagining what I do all day)*

**Secondary school: **Dame Allan’s. GCSE Maths, Statistics, French, German, Physics, Chemistry, Biology, IT, History. (I hope they don’t notice I didn’t do GCSE English!)

**College**: Dame Allan’s *(again. Sorry, I went to one of those posh schools.)* A-Level Maths, Further Maths, French, Physics.

**Apprenticeship**: None.

**University: **Newcastle University. Master’s degree in Mathematics and Statistics.

**First Job: **Newcastle University. Tutor and e-learning officer.

**Are there any tips you would give someone who wants a career in your field?**

Maths is much more about persistence than natural ability – everybody gets stuck, and it’s **much** more than just doing sums – in fact, some of us are hopeless at doing actual calculations. Doing puzzles and playing games is the best way to develop your thinking skills.

**Best thing about your job?**

I get to solve interesting maths problems, and travel around the world to meet people who use the software I make.

**Not-so-good thing about your job?**

Like all jobs, there are forms to fill in and meetings to attend. On busy days when I’m interrupted a lot, it makes it hard to get any good maths done.

While we’re not massively bothered by the pricing, the articles do raise, and then completely fail to address, an interesting point: an oval pizza is harder to cut into equally sized pieces! Luckily, maths is here to save the day. I found a nice method and made a video explaining how it works:

Take a look and improve your future pizza cutting technique!

Cheesed off! Families roundly cheated by trendy oval pizzas as experts warn they are smaller in size… And how CAN you slice them into equal portions, anyway? in The Daily Mail

Why those trendy new oval pizzas you see in major supermarkets may not be worth it, in The Mirror

(Sadly, all proper newspapers have declined to comment)

]]>The Carnival rounds up maths blog posts from all over the internet, including some from our own Aperiodical. See our Carnival of Mathematics page for more information.

]]>Back in 2013, Evelyn Lamb (@evelynjlamb, first on our list) beat us to the punch with a comprehensive list of women on Twitter fitting the adjective ‘mathy’; we can’t guarantee all the account handles are still accurate or they’re still tweeting, but it’s a nice place to start. The list is also available as a Twitter List you can subscribe to.

This week, the #womeninmaths hashtag is kicking off with details of all the events and talks going on to celebrate women, and there are several Twitter accounts dedicated to tweeting about women in maths all year round – including @womeninmaths (the Twitter account of the LMS’s Women in Maths committee) and more generally @STEMWomen. International Women’s Day has its own Twitter account @womensday.

And finally, here’s a (far too short) list of some more cool mathematical women I’ve recently met/heard of/worked with, and their Twitter handles.

- Eugénie von Tunzelmann (@eugenieVT): works in computer graphics and 3D rollercoaster design, and has a tattoo of a hypercube on her arm
- Laura Taalman (@mathgrrl): met her while she was mathematician in residence at MoMATH in New York, and does lots of interesting stuff with 3D printing and maths
- Sam Durbin (@samdurbin1): coordinator of maths masterclasses at the Royal Insititution, and an unstoppable force of nature when it comes to promoting maths
- Finally, Nalini Joshi (@monsoon0): mathematician at the University of Sydney, and (as of today) the first ever woman to have her portrait hanging in the prestigious MacLaurin Hall at the university:

On #internationalwomensday , the amazing Nalini Joshi has her official portrait unveiled! A beautiful work by artist Celeste Chandler. pic.twitter.com/wwEPS8wqMj

— Sydney Science (@Sydney_Science) 8 March 2017

The Mathematical Association of America also helpfully tweeted this collection of handles:

Happy #InternationalWomensDay! #Follow mathematicians: @evelynjlamb @alittlestats @EricaNWalker @doctor_talitha @jennapcarp @jennapcarp

— MAA (@maanow) March 8, 2017

]]>More #Womeninmath: @AWMmath @WVUMathDoc @mathcirque @csquaredd13 @KelseyAHE @EKTBenn @kristinheysse @KristinLauter @mathyadriana

— MAA (@maanow) March 8, 2017

The film is a painstaking and at times brutally realistic depiction of the struggles faced by African-Americans, and by women, during the era of the early space missions.

It’s the first film I’ve ever seen where the BBFC certificate at the start warns, where you’d usually see “scenes of violence/nudity/strong language”, a warning for “discrimination theme” – and it’s justified, as you find yourself battered by the repeatedly unfair and horrible treatment received by the clearly brilliant and lovely main characters, and worst of all how that is completely normal and widespread for the time. Langley, where NASA HQ is located, is in Virginia, a state where segregation continued in many aspects until the Civil Rights Act of 1964 – this meant ‘coloureds’ had to use separate bathrooms, drink from separate water fountains, sit in a separate section at the back of the bus and attend separate schools, all of which (and their horrible demoralising effects) are seen clearly in the film.

It also doesn’t shy away from the discrimination received by women, which is another layer of problems these characters face – even within their own community, they encounter people with a ‘do they let women do that?’ attitude. When one character arrives in her new department to provide her mathematical expertise and is immediately handed a bin which needs emptying, it’s not clear whether it’s because she’s female or black (or both).

But you’re here for the maths, right? This is at its core a film about a mathematician, an engineer and a computer scientist and how they helped America put a man into space. The maths and science is well incorporated into the story and doesn’t feel awkward, and serves to display the brilliance of the main characters, as well as the difficulty of the work everyone at NASA was doing – it was groundbreaking, and in some cases involved inventing new mathematical techniques to solve problems nobody imagined they’d have to solve (and this aspect of the space race is even mentioned as a justification for the huge cost and effort of the programme).

In one early scene, Katherine Johnson (as a child) demonstrates her mathematical brilliance by, having skipped two grades in school, being called up to the blackboard in front of a room of older students. She demonstrates that the product of two quadratics, set equal to zero on the board, can easily be solved by noting that if a product of two things equals zero, it means one of the two terms must equal zero so you can factorise each of the two quadratics, set each of the four resulting components to zero and find four solutions. It’s a beautiful piece of maths, well explained and displayed in full, front and centre in the scene. While some filmmakers might worry about this, it completely works and demonstrates her brilliance – the looks on the other students’ faces tell the story too.

Elsewhere in the film, Katherine is required to do Analytic Geometry, studying the trajectories of the space flights and their take-off and landing. The initial calculations for the earlier low-Earth orbit flights were simpler, and it’s when they start considering the more complex orbital flights – in which the trajectory of the capsule changes from an elliptical orbit of the Earth to a parabolic trajectory as it comes down, where they needed to work out something new. Together the team realises they can use numerical integration – Euler’s Method, which has been known for a long time but hadn’t been used at NASA for years – to obtain a solution which works numerically, without having to actually solve the differential equations. Johnson’s brilliance in helping come to this realisation is clear, and anyone watching who didn’t understand the maths can maybe even get a sense of the beauty and satisfaction mathematicians find in their work, especially when it has such amazing applications.

The other main characters demonstrate their excellence in their own fields too. Mary Jackson, clearly a brilliant engineer, is encouraged by her boss to join the NASA engineer training programme, but finds her bachelor’s degree in maths and physics is insufficient; the administrator’s veiled joy in telling her she doesn’t qualify could just be a true bureaucrat relishing in the rules, but as with many of the things people do in the film it’s in line with the standards of the era, and advancement seems an impossible dream.

The third amazing role model in this film is Dorothy Vaughan, who runs the computing department (at the time, a team of human ‘computers’ who perform all the calculations by hand). She notices that the new IBM supercomputer coming in to do the calculations will make all their jobs obsolete, so she educates herself and her team, getting books on Fortran from the library and using her skills with machinery and numbers to understand how it works.

I’m glad this film exists, and I’m double glad that it’s such a well-made piece of cinema, with well-developed characters, a gripping story and emotional tugs which work regardless of whether you’re interested in maths – because it means lots of people will see it. I hope that as well as telling these women’s stories – something badly needed – and reminding us of how painfully recent these attitudes held sway (and warning us not to let them take hold again now!) this film will also help people to see the wonder of maths and science, and show that people who do these things struggle the same as everyone else, and are all part of the same world.

It looks like the film is having this effect – many people are now talking about it, and Katherine Johnson also features in this new LEGO set, recently approved, of Women Pioneers at NASA. I’d recommend going to see it, but also taking along some tissues and being prepared to come out energised and angry that people were treated this way, and, I’d hope, ready to take on injustice now.

]]>