Why do headphones tangle in your pocket?

You coiled the cable neatly. You put it in your bag without ceremony, walked to school, and pulled out something that now requires two hands and a pin. Nobody interfered with it. The bag was not shaken deliberately. Somehow an object that went in unknotted has arrived knotted, and it happens to garden hose, charging cables and skipping ropes with equal enthusiasm.
There are enormously more tangled arrangements than tidy ones, and random jostling wanders into whichever kind is commoner.
A knot needs an end to travel
Start with something surprising about knots. Take a cable and hold both ends firmly, then wave the middle around for an hour. Nothing whatever happens.
You cannot introduce a knot without passing an end through a loop, so a cable with both ends held is permanently safe. The branch of mathematics that studies this is knot theory, and its first rule is that a closed loop with no free ends can never gain or lose a knot.
A cable in a bag has two ends, and they are unsupervised. Every jolt of walking shifts the coils, and occasionally an end slips underneath a neighboring strand.
Nothing has to go right for a knot to form. One end simply has to wander under one loop, once.
Each crossing of that kind is almost undetectable, and none of them individually looks like a knot. Accumulate a few dozen over a twenty minute journey and the cable is genuinely, mathematically knotted.
Untidy arrangements outnumber tidy ones
Now the deeper reason, and it is not about cables at all. Imagine writing down every possible arrangement a cable could adopt inside a bag.
An overwhelming majority of those arrangements contain at least one knot. Neat coils are a vanishingly small minority, because there are very few ways to be tidy and an astronomical number of ways to be untidy.
Random jostling does not prefer either kind. It simply moves the cable from one arrangement to the next, over and over, and choices made without preference land in whichever group is bigger.
That imbalance is called entropy: a measure of how many different arrangements would look equally messy from outside. Shuffling anything for long enough drives it toward whatever there is most of.

Three thousand tumbles in a box
Two physicists decided to measure it rather than argue about it. In 2007, a few years before you were born, Dorian Raymer and Douglas Smith in California built a box that tumbled a piece of string, dropped one in, and switched on the motor.
Then they did it again. Three thousand four hundred and fifteen times, with strings of different lengths and thicknesses, photographing every result and identifying each knot mathematically.

Their findings are wonderfully specific. Knots often appeared within seconds. They identified one hundred and twenty different kinds, some requiring eleven crossings to describe, which is a properly complicated knot.
Length mattered enormously. Strings under a certain length almost never knotted, and beyond that the chance climbed steeply before leveling off near certainty.
String length below which knots almost never appeared, and the length at which they became routine, in centimeters.
Below roughly 46 cm(18 in) the box produced almost nothing. Past about 150 cm(5 ft) a knot was the normal outcome.
The reason is straightforward once stated. A short string cannot form a loop big enough for its own end to fall through, so the very first step is unavailable to it.
It is not just that you notice the bad days
The work earned an Ig Nobel Prize in 2008, an award for research that makes people laugh and then think. It also produced genuinely useful results, because long molecules inside living cells face exactly the same problem.
DNA, the enormously long molecule carrying the instructions for building a living thing, is packed into a space far smaller than its own length. Cells run dedicated machinery whose entire job is untying it.
Which knots you actually get
The knots that appear are not random scribbles. Mathematicians classify knots by their crossing number: the smallest number of times the cable must cross itself in any drawing of the knot.
Simple knots are commonest, because there are fewer routes to a complicated one. Complicated ones do appear regardless, and an eleven-crossing knot in thin cable will occupy you for some time.
The whole classification descends from Peter Guthrie Tait, a Scottish physicist working in the nineteenth century. Through the 1870s he drew and cataloged every knot he could distinguish, in the belief that atoms themselves were knots tied in space.
A rigid cable assists you. It resists forming the small loops a wandering end requires, which is precisely why thick garden hose tangles less readily than thin earphone wire of identical length. Engineers call that resistance to bending stiffness, and it is measurable.
Tumble your own and count

Your shortest string will almost never knot, however energetically you shake it. Your longest will knot most times, and often more than once.
That climb is the whole experiment. It shows the effect depends on something measurable rather than on luck, and it is the same curve the physicists published from a machine that cost considerably more than a lunchbox.
Tidiness is a small target
None of this makes tangling inevitable, and the remedy follows directly from the mechanism. Remove the free ends and you remove the only route a knot has.
Wrapping a cable and then tucking the plug through the coil does exactly that. So does a clip, a hook and loop tie, or simply winding it round something. Any of them turns two wandering ends into none.
Everything else in your bag is doing the same thing on a smaller scale, and losing the same argument. There are very few ways to be neat, an enormous number of ways to be messy, and jostling has no opinion about which one it produces.


