COMPUTING SCIENCE
Group Theory in the Bedroom
An insomniac's guide to the curious mathematics of mattress flipping
Brian Hayes
Pillow Talk
I'm not a mathematician, but I've been hanging around with some of
them long enough to know how the game is played. Once you've solved
a problem, the next step is to generalize it beyond all recognition.
There's a nerdy joke with the punchline, "Consider a spherical
cow"; in the same spirit I ask, "Consider a cubical mattress."

A cube has a much higher order of symmetry than the generic
orthotope of an ordinary mattress. Any of six faces can be turned
uppermost for sleeping on, and each face has four orientations, so
there are 24 states in all. (The group is S 4,
the same group we encountered at the breakfast table and in the
garage.) Is there a golden rule for flipping an unlabeled cubical
mattress—a single maneuver that can be repeated 24 times to
cycle through all the configurations? The answer is no, but I'll
leave the proof of that fact as an exercise.
There is a silver rule for cubical mattress flipping: As
with an ordinary mattress, if we label the configurations, we can
step through them one by one by counting. But there is a subtle
difference. On the ordinary mattress, there are six essentially
different ways to label the configurations—six ways to arrange
the numbers 0 through 3— but it doesn't matter which one you
choose. With any arrangement of the numbers, you can always go from
one state to the next in a single flip. For the cube, there are many
more labelings (the exact number is 23!, or
25,852,016,738,884,976,640,000), and they are not all equal. When
you tour all 24 states in numerical order, some labelings allow
every transition to be accomplished by a simple quarter turn around
the roll, the pitch or the yaw axis. Other labelings require
more-complicated maneuvers—rotations around multiple axes (or,
equivalently, around a diagonal). How many of the labelings fall
into each category? Is there any simple rule that distinguishes the
two classes?
If you have answered those questions and you still can't
get to sleep, you are welcome to go on and consider a hyper-cubical
mattress—one that takes the form of a cube in
n-dimensional space, for some n greater than 3.
The 4-D mattress has 24 square faces and 96 configurations.
As far as I know, neither Sealy nor Simmons nor anyone else is yet
selling a four-dimensional mattress. As a matter of fact, the trend
seems to be in the opposite direction. Mattress makers now promote
the one-sided, "no-flip," mattress, whose only symmetry
operation is a 180-degree turn around the yaw axis. This innovation
finally gives us a golden rule for mattress flipping, but it solves
the problem in a trivial, dull and unsatisfying way.
Still, there remain ways to increase the number of permutations, to
provide opportunities for creative problem-solving, to make life
more interesting. One could get married.
© Brian Hayes
» Post Comment