Steven Strogatz on math, from basic to baffling.

My wife and I have different sleeping styles — and our mattress shows it. She hoards the pillows, thrashes around all night long, and barely dents the mattress, while I lie on my back, mummy-like, molding a cavernous depression into my side of the bed.

Bed manufacturers recommend flipping your mattress periodically, probably with people like me in mind. But what’s the best system? How exactly are you supposed to flip it to get the most even wear out of it?

Brian Hayes explores this problem in the title essay of his recent book, “Group Theory in the Bedroom.” Double entendres aside, the “group” in question here is a collection of mathematical actions — all the possible ways you could flip, rotate or overturn the mattress so that it still fits neatly on the bed frame.

By looking into mattress math in some detail, I hope to give you a feeling for group theory more generally. It’s one of the most versatile parts of mathematics. It underlies everything from the choreography of contra dancing and the fundamental laws of particle physics, to the mosaics of the Alhambra and their chaotic counterparts like this image.

Michael Field

As these examples suggest, group theory bridges the arts and sciences. It addresses something the two cultures share — an abiding fascination with symmetry. Yet because it encompasses such a wide range of phenomena, group theory is necessarily abstract. It distills symmetry to its essence.



Normally we think of symmetry as a property of a shape. But group theorists focus more on what you can do to a shape — specifically, all the ways you can change it while keeping something else about it the same. More precisely, they look for all the transformations that leave a shape unchanged, given certain constraints. These transformations are called the “symmetries” of the shape. Taken together they form a “group,” a collection of transformations whose relationships define the shape’s most basic architecture.

In the case of a mattress, the transformations alter its orientation in space (that’s what changes) while maintaining its rigidity (that’s the constraint). And after the smoke clears, the mattress has to fit snugly on the rectangular bed frame (that’s what stays the same). With these rules in place, let’s see what transformations qualify for membership in this exclusive little group. It turns out there are only four of them.

The first is the “do-nothing” transformation, a lazy but popular choice that leaves the mattress untouched. It certainly satisfies all the rules, but it’s not much help in prolonging the life of your mattress. Still, it’s very important to include in the group. It plays the same role for group theory that zero does for addition of numbers, or that 1 does for multiplication. Mathematicians call it the “identity element,” so I’ll denote it by the symbol I.

Next come the three genuine ways to flip a mattress. To distinguish among them, it helps to label the corners of the mattress by numbering them like so:

The first kind of flip is depicted near the beginning of this post. The handsome gentleman in striped pajamas is trying to turn the mattress from side to side by rotating it 180 degrees around its long axis, in a move I’ll call H, for “horizontal flip.”

A more reckless way of overturning the mattress is a “vertical flip” V. This maneuver swaps its head and foot. You stand the mattress upright, the long way, so that it almost reaches the ceiling, and then topple it end over end. The net effect, besides the enormous thud, is to rotate the mattress 180 degrees about the axis shown below.

The final possibility is to spin the mattress half a turn while keeping it flat on the bed.

Unlike the H and V flips, this “rotation” R keeps the top surface on top. That difference shows up when we look at a top view of the mattress — now imagined to be translucent — and inspect the numbers at the corners after each of the possible transformations.

The horizontal flip turns the numerals into their mirror images. It also permutes them so that 1 and 2 trade places, as do 3 and 4.

The vertical flip permutes the numbers in a different way and stands them on their heads, besides mirroring them.

The rotation, however, doesn’t generate any mirror images. It merely turns the numbers upside down, this time exchanging 1 for 4 and 2 for 3.

These details are not the main point. What matters is how the transformations relate to one another. Their patterns of interaction encode the symmetry of the mattress.

To reveal those patterns with a minimum of effort, it helps to draw the following diagram. (Images like this abound in a terrific new book called “Visual Group Theory,” by Nathan Carter. It’s one of the best introductions to group theory — or to any branch of higher math — I’ve ever read.)

The four possible “states” of the mattress are shown at the corners of the diagram. The upper left state is the starting point. The colored arrows indicate the moves that take the mattress from one state to another.

For example, the green arrow pointing from the upper left to the lower right depicts the action of the rotation R. The same green line also has an arrowhead on the other end, because if you do R twice, it’s tantamount to doing nothing.

That shouldn’t come as a surprise. It just means that turning the mattress head to foot and then doing that again returns the mattress to its original state. We can summarize this property with the equation RR = I, where RR means do R twice, and I is the do-nothing identity element. For that matter, the horizontal and vertical flip transformations also undo themselves: HH = I and VV = I.

The diagram embodies a wealth of other information. For instance, it shows that the death-defying vertical flip V is equivalent to HR, a horizontal flip followed by a rotation — a much safer path to the same result. To check this, begin at the starting state in the upper left. Head due east along H to the next state, and from there go diagonally southwest along R. Because you arrive at the same state as if you’d simply followed V to begin with, the diagram demonstrates that HR = V.

Notice, too, that the order of those actions is irrelevant: HR = RH, since both roads lead to V. This indifference to order is true for any other pair of actions. You should think of this as a generalization of the commutative law for addition of ordinary numbers, x and y, according to which x + y = y + x. But beware: the mattress group is special. Many other groups violate the commutative “law.” Those fortunate enough to obey it are particularly clean and simple.

Now for the payoff. The diagram shows how to get the most even wear out of a mattress. Any strategy that samples all four states periodically will work. For example, alternating R and H is convenient — and since it bypasses V, it’s not too strenuous. To help you remember it, some manufacturers suggest the mnemonic “spin in the spring, flip in the fall.”

The mattress group also pops up in some unexpected places, from the symmetry of water molecules to the logic of a pair of electrical switches. That’s one of the charms of group theory. It exposes the hidden unity of things that would otherwise seem unrelated … like this anecdote about how the physicist Richard Feynman got a draft deferment.

The army psychiatrist questioning him asked Feynman to put out his hands so he could examine them. Feynman stuck them out, one palm up, the other down. “No, the other way,” said the psychiatrist. So Feynman reversed both hands, leaving one palm down and the other up.

Feynman wasn’t merely playing mind games; he was indulging in a little group-theoretic humor. If we consider all the possible ways he could have held out his hands, along with the various transitions among them, the arrows form the same pattern as the mattress group!

But if all this makes mattresses seem way too complicated, maybe the real lesson here is one you already knew — if something’s bothering you, just sleep on it.

NOTES

Thanks to Mike Field and Marty Golubitsky for sharing their images of symmetric chaos; Margaret Nelson for preparing the illustrations; and Paul Ginsparg, Jon Kleinberg, Tim Novikoff, Diana Riesman and Carole Schiffman for their comments and suggestions.

Need to print this post? Here is a print-friendly PDF version of this piece, with images.