It was probably the 21st century’s preeminent sage Bill Murray that summed up the problem most succinctly: “How to tie the strongest knot ever: 1) Put some headphones in your pocket 2) Wait one minute”.

But have you ever wondered exactly why this happens? Well, scientists have and to find out what mysterious pocket-sized-goings-on are going on they did what any sensible researcher would: they put different pieces of wire in a box and shook them up to see if they got knotted. They did this a lot, in fact, 3,415 times in all.

The results (detailed in a now quite venerable 2006 paper entitled "Spontaneous knotting of an agitated string" by Dorian M. Raymer and Douglas E. Smith) showed that two key factors cause complex knots to “form within seconds”: “critical string length” and “agitation time”.

The probability of knot forming versus string length.

Essentially the longer the lengths of cable and the more they’re shaken the more likely it is that a knot will spontaneously form. Qualities such as cable rigidity and diameter also play a part but it's length and time spent tumbling that matter most – and unfortunately, these are the factors you’re least likely to change.

Raymer and Smith came to their conclusion by experimenting with cables of varying length and different “agitation times," finding that cables shorter than 46 centimetres will rarely – if ever – get knotted, with the probability increasing with cable size before plateauing just after 2 metres in length.

For the average pair of earphones (defined as 139 centimetres in length) this means the probability of a knot spontaneously forming in an enclosed space about the size of your bag is just under 50 per cent. That’s right, every time you dump your earphones after arriving at school or work there’s a one in two chance you're dicing with death going to be slightly annoyed later in the day.

Knot formation in action. The box on the left is the rotating container used by Raymer and Smith, with one crossed wire quickly leading to chaos.

Raymer and Smith also noted that the Y shape of earphones increases the chance of knotting substantially, with only one end of the wire or cable having to cross another to start off the tumble-weed reaction of a spontaneous tangle.