Hanging Around with Mathematics

Katie Steckles

Imagine you are hanging a picture on the wall – like this photo of 2006 ACM A.M. Turing Award laureate Frances Allen. You have two nails already hammered into the wall so they are sticking out an inch. Your picture is in a frame, with a piece of string attached at the top two corners, and you can hang it on the wall by hooking the string over the two nails.

Frances Elizabeth Allen (ACM A.M. Turing Award – 2006). Image Credits: HLFF/Peter Badge

If either of the nails was pulled out of the wall, your picture would remain hanging – since the string passes over both nails, removing one nail would leave the string looped around the remaining nail, and the picture would still hang.

But what if we wanted something different to happen? What if we wanted to be able to hang the picture so that as soon as any single nail is removed, it falls off the wall?

It sounds impossible, but there is a way to arrange the string that achieves this. I will leave the solution until later in the post, to give you time to think about it. It is not as simple as just placing the string over the top of the two nails, but can be done by winding the string around the nails in a particular pattern (and assumes the string can be as long as you need to achieve this).

Why Am I Hanging Pictures?

This might not feel like a particularly mathematical topic: hanging a picture on the wall seems like a simple enough problem that we do not need to involve mathematics. But of course, as always, there is some more advanced maths hiding in there. The idea of passing a string over a nail, or indeed wrapping it around the nail in a more complicated pattern, can be described mathematically.

Consider the clockwise and anticlockwise turns the string makes as you go along its length. For example, the standard put-the-string-across-the-top-of-both-nails approach means going clockwise over the first nail, then clockwise over the second.

Shafrira Goldwasser (ACM A.M. Turing Award – 2012). Image Credits: HLFF/Peter Badge

We could denote the two nails \(A\) and \(B\), and denote a clockwise turn by writing the letter for that nail – so the standard hang would just be \(A\cdot B\). If we wrapped the string twice clockwise around one nail before going over the other, we could write this as \(A\cdot A\cdot B\).

June Huh (Fields Medal – 2022). Image Credits: HLFF/Peter Badge

We can think of an anticlockwise turn as being the inverse of a clockwise turn around the same nail: If we were to perform one after the other, they would cancel out:

Maryam Mirzakhani (Fields Medal – 2014). Image Credits: HLFF/Peter Badge

It would be conventional to denote the anticlockwise move around nail \(A\) as \(A^{-1}\), and if we performed the hanging operation \(A\cdot A^{-1}\cdot B\), the first two moves would cancel out – in practice, the string would not actually be fastened to the first nail at all, and if a heavy picture was hanging on it, you would just be left with the string hanging over nail \(B\).

Shigefumi Mori (Fields Medal – 1990). Image Credits: HLFF/Peter Badge

These hanging operations behave like algebraic objects in a group structure (for more on groups, see this post I wrote in 2019). In the article, I talk about the property of commutativity, using the example of addition and numbers. Elements which commute are ones which can be combined in any order – for example, we know that with numbers, 2 + 4 = 4 + 2.

But in some groups, the objects must be combined in the specific order given, and changing the order will give a different result – and this applies to our picture hanging setup. For example, the configurations \(A\cdot B\) and \(B\cdot A\) are obviously different:

Whitfield Diffie (L) and Martin Hellman (R) (ACM A.M. Turing Award – 2015). Image Credits: HLFF/Peter Badge

If we have a configuration that involves using a hanging operation and its inverse, they will only cancel out if they are next to each other in order: \(A \cdot A^{-1} \cdot B\) will cancel out to leave \(B\) as we saw above, but \(A \cdot B \cdot A^{-1}\) will stay hanging in place.

Daphne Koller (ACM Prize in Computing – 2007), and Terence Tao (Fields Medal – 2006). Image Credits: HLFF/Peter Badge

Nailing Down The Problem

In order to tackle our original puzzle, we can consider what happens when a nail is removed from the wall. In the hanging operation notation, this would correspond to any instances of that letter, or its inverse, being deleted from the expression – since the nail is no longer there to hold the string in place.

We can exploit this to find a solution to our problem – finding a combination where if you remove the As, the Bs will cancel out, and vice versa. In the notation given, one solution to this problem would be \(A\cdot B\cdot A^{-1}\cdot B^{-1}\) – going clockwise over both nails, then anticlockwise over the first, then looping round to go anticlockwise over the second.

Madhu Sudan (Nevanlinna Prize – 2002). Image Credits: HLFF/Peter Badge

Here, if one of the nails is removed, the picture will fall off the wall: If we take out \(A\), our expression just becomes \( B \cdot B^{-1}\), and similarly if we take out \(B\) it will just be \( A \cdot A^{-1}\), both of which will cancel out and disappear. This provides a solution to the original problem as stated, but anyone who wonders how this can be extended to more nails need only look to mathematics – of course there is a pattern here.

The object \( A \cdot B \cdot A^{-1} \cdot B^{-1}\), consisting of a pair of group elements, followed by their inverses, is known as a commutator. It is so-called because in a situation where the elements A and B commute (they can swap places without changing the value of the result) the commutator will cancel out to be zero – so it can be used as a measure of whether two things have this property.

Commutators can be denoted \([A,B] = A \cdot B \cdot A^{-1} \cdot B^{-1}\), and any object from a group can be given as an input to our commutator brackets \([\ ,\ ]\) – including sequences of hanging operations. In particular, I could put in another commutator: We write \([[A,B],C] = [A \cdot B \cdot A^{-1} \cdot B^{-1}, C]\) for the commutator of the commutator \([A,B]\) with a third nail \(C\), which would be written in full as:

\[ A \cdot B \cdot A^{-1} \cdot B^{-1} \cdot C \cdot B \cdot A \cdot B^{-1} \cdot A^{-1} \cdot C^{-1}\]

Here, we alternate between the commutator \([A,B]\) and nail \(C\), and the second two instances are inverses. The inverse of \(A \cdot B \cdot A^{-1} \cdot B^{-1} \)is \(B \cdot A \cdot B^{-1} \cdot A^{-1} \). Here, the order of the elements is reversed, then they are flipped from normal to inverse or vice versa – resulting in something which, were it to be written directly next to its inverse, would cancel out one term at a time.

The three-element commutator given above would be the solution to a three-nail problem – if any one of the nails is removed, we are left with elements next to their inverses that would cancel out and leave the picture on the floor.

Joseph Sifakis and dog (ACM A.M. Turing Award – 2007). Image Credits: HLFF/Peter Badge

The generalised picture hanging question is sometimes called the ‘1-out-of-n problem’, since it requires a hanging which will fail if any one of the n nails is removed, and general solutions can be found by creating longer and longer commutators, inverting the whole of the existing string of terms and alternating it with the new extra term.

While this is definitely guaranteed to give a solution, it will not be particularly efficient – the length of the expression will grow exponentially. Luckily, alternative solutions to this problem using shorter strings of terms (and correspondingly, shorter lengths of string to hang the picture) can be found by other methods, and a nice write-up is given in this research paper, which connects it to the theory of mathematical knots and links.  

Meanwhile, commutators are an important and useful tool in studying groups, and have many serious mathematical applications in understanding pure mathematical group structures, and in other areas like quantum mechanics. But I believe that it is their usefulness in hanging pictures, in a very specific and unnecessary way, that means they should formally be categorised as applied mathematics.

The post Hanging Around with Mathematics originally appeared on the HLFF SciLogs blog.