It happens every time: You reach into your bag to pull out your headphones. But no matter how neatly you wrapped them up beforehand, the cords have become a giant Gordian knot of frustration. 
 
 Along with your Netflix stream inexplicably buffering and Facebook emotionally manipulating you, tangled cords are the bane of modern existence. But until we invent a good way of wirelessly beaming power through the air to our beloved electronic devices, it seems like we’re stuck with this problem. 
 
 Long floppy pieces of string can assume many spontaneous configurations. A string could be nicely laid out in a straight line. Or it could have one end crossed over some section in the middle. There in fact happen to be a lot of configurations where the string wraps around itself, potentially creating a tangle and eventually a knot. With relatively few of these random configurations being tangle free, chances are higher that the string will be a mess. And once a knot forms, it’s energetically difficult and unlikely for it to come undone. Therefore, a string will naturally tend toward greater knottiness. 
 
 Humans have been tying things up with string for many thousands of years, so it’s no surprise mathematicians have been working on theories of knots for a long time. But it wasn’t until the 1800s that the field really took off, when physicists like Lord Kelvin and James Clerk Maxwell were modeling atoms as spinning vortices in the luminiferous ether (a hypothetical substance that permeated all space through which light waves were said to travel). The physicists had worked out some interesting properties of these knot-like atoms and asked their mathematician friends for help with the details. The mathematicians said, “Sure. That’s really interesting. We’ll get back to you on that.” 
 
 Now, 150 years later, physicists have long since abandoned both the luminiferous ether and knotted atomic models. But mathematicians have created a diverse branch of study known as knot theory that describes the mathematical properties of knots. The mathematical definition of a knot involves tangling a string around itself and then fusing its ends together so the knot can’t be undone (Note: This is kind of hard to do in reality). Using this definition, mathematicians have categorized different knot types. For instance, there is only one type of knot where a string crosses itself three times, known as a trefoil. Similarly, there is only one four-crossing knot, the figure eight. Mathematicians have identified a group of numbers called Jones polynomials that define each type of knot. Still, for a long time knot theory remained a somewhat esoteric branch of mathematics. 
 
 In 2007, physicist Douglas Smith and his then-undergraduate student Dorian Raymer decided to look at the applicability of knot theory to real strings. In an experiment, they placed a string into a box and then tumbled it around for 10 seconds. Raymer repeated this about 3,000 times with strings of different lengths and stiffness, boxes of different size, and varying rotation rates for the tumbling. 
 
 They found that about 50 percent of the time, a string would emerge from its quick spin with a knot in it. Here, there was a big dependence on the string’s length. Short strings—those less than about a foot in a half in length—tended to stay knot-free. And the longer a string got, the greater the odds of knot formation became. Yet the probability only increased up to a certain size. Strings longer than five feet became too cramped in the boxes, and wouldn’t form knots more than roughly 50 percent of the time. 
 
 Raymer and Smith also classified the types of knots they found, using the Jones polynomials developed by mathematicians. After each tumble, they took a picture of the string and fed the image into a computer algorithm that could categorize the knots. Knot theory has shown that there are 14 kinds of primary knots, which involve seven or fewer crosses. Raymer and Smith found that all 14 types formed, with higher odds of forming simpler ones. They also saw more complicated knots, some with up to 11 crossings. 
 
 The researchers created a model to explain their observations. Basically, in order to fit inside a box, a string has to be coiled up. This means the end of the string lies parallel to different segments along the length of the string. As the box spins, the string end has a certain chance of falling over and around one of these middle segments. If it moves enough times, the end will essentially braid itself around some part in the middle, tangling up the string and creating different knots. 
 
 The most important question from these experiments is what can be done to keep my cables from getting all screwy. One method that decreased the chances of knot formation was placing stiffer strings into the tumbling boxes. Perhaps this is what motivated Apple to make the power cables for more recent generations of laptops less flexible. It also helps explain why your long, thin Christmas tree lights are always a tangled mess while your shorter and stockier surge protector cable stays relatively smooth. 
 
 A smaller container size also helped keep the knots away. Longer strings pressed against the walls of a small box, preventing the cord from falling over itself and braiding up. This has been proposed as the reason why umbilical cord knots are rare (happening in about 1 percent of births): The womb is too small to allow for the organ to tangle around itself. Finally, spinning the boxes faster than normal helped prevent knotting because the strings were pinned to the sides by centrifugal forces and couldn’t braid themselves. However, I’m not sure how you would apply this to your own pocket dilemma of cord tangles. Perhaps you could travel around by quickly somersaulting everywhere. Or buy clothes with really tiny pockets. ||||| Why do shoelaces untie themselves? This team may have the answer 
 
 It’s the bane of tennis shoe wearers everywhere: No matter how tightly you tie your laces, they seem to come undone, often at the most inopportune time. Now, for the first time, scientists have untangled why shoelace knots fail. The work also reveals the best knots to tie and could have implications for everything from surgery to new cancer drugs. 
 
 “We deal with them coming untied all the time,” says Colin Adams, a mathematician at Williams College in Williamstown, Massachusetts, who was not involved with the study. “And yet, nobody’s ever taken the time to say: Why does it happen?” 
 
 Here’s one thing we do know about shoelaces: The “square knot” holds up better than the “granny knot.” Both knots appear about the same, with two bunny-ear loops, but the granny tends to rotate to its side—one loop pointing up the shoe, the other down. (Still confused? Check out this TED video.) 
 
 To find out why even the best knots fail, Oliver O’Reilly, a mechanical engineer at the University of California, Berkeley, and colleagues put a volunteer on a treadmill. The test subject tied her shoes with the weaker granny knot so that the researchers had a better chance of watching it unravel. The scientists attached accelerometers to her shoes to measure the acceleration, or g-force, the knot experienced with each stride. 
 
 Using slow-motion video, the team uncovered two stages of knot slippage: a gradual loosening with each step, and a sudden “catastrophic failure.” When the knot started to unravel, it fell apart within two strides. The researchers were surprised by the g-force the knot experienced as it bobbed up and down, which was more than any rollercoaster can generate. 
 
 Walking was key. The same knot that failed within 15 meters of walking stuck around if participants just stomped their feet on the ground or swung them while sitting on a table, the team reports today in the Proceedings of the Royal Society. Neither impact by itself—stomping or swinging—was enough to undo the knots. 
 
 “We were able to see that these two combined effects lead to shoe knots failing,” O’Reilly says. “You need both together.” 
 
 The scientists then designed an experiment to measure how long it took for knots to unravel and the rate at which the laces slipped. Working on a shoestring budget and borrowing lab equipment on weekends, the researchers designed a mechanical pendulum that smacked a plate. The pendulum’s swing approximated leg movements, and the smack the impact of shoes with the ground. The pendulum sported a shoelace with weighted ends—the added weight was needed to simulate how strongly the ends whip on runners’ shoes. The team used this controlled setup to calculate the precise slip rate of shoelaces, tied either granny or square. 
 
 The experiment confirmed the treadmill observations. Both knots initially slipped apart at a slow, gradual rate with each swing and smack of the pendulum. Eventually, though, the laces became loose enough to rapidly slip apart at a much faster rate. The study also demonstrated the superiority of the square knot. This winning knot failed about half the time (when weighted), whereas the granny knot always failed. 
 
 But though the scientists know that one knot is more resilient, they still can’t explain why. It may have something to do with how the laces press against each other within the knot and the knot’s tension, Adams says. “If you could actually predict when a knot is going to fail,” he says, “that would have implications beyond shoelaces.” 
 
 This could include knots used in surgical sutures, on boats, and in mountaineering. But knots also exist on the microscopic level: DNA knots and unknots when it creates copies of itself, for example. Scientists are already exploiting these properties to create drugs that slow tumor growth. ||||| It happens to us all. You’re out running, or just out for a walk. And all of a sudden you feel that flick, flick of a loose shoelace. 
 
 Now science can explain exactly why it happens. And, just maybe, offer a solution. 
 
 It’s simple physics, a team at the University of California Berkeley discovered. 
 
 “There is plenty of interaction between the swinging motion of your leg, causing the laces to whip forward, and also the impact on the ground. You actually need both,” said Christine Gregg, a graduate student who worked on the study. 
 
 A knot failure happens two ways: gradually, then suddenly. UC Berkeley 
 
 The laces are moving and then the thunk of your foot hitting the ground jars the knot. 
 
 “The impact force of the shoe during the striking of the heel is transmitted to the knot by the tongue of the shoe and the eyelets. As a result, the center of the knot deforms,” Gregg and her colleagues wrote in their report, published in the Proceedings of the Royal Society A. 
 
 It’s a gradual process, until it isn’t. 
 
 “The speed of the knot failure brings to mind a Hemingway line from ‘The Sun Also Rises’ describing a character’s descent into bankruptcy—which here we found to be an apropos description of knot failure—it happens ‘Two ways. Gradually, then suddenly’,” the team wrote. 
 
 As a runner, Gregg had the problem frequently. “It would definitely be a problem. At least once on a run I would stop and retie them.” 
 
 And the professor whose lab she works in, Oliver O’Reilly, has a daughter whose shoes never stay tied, Gregg said. 
 
 As a mechanical engineer, Gregg felt it was an important problem to solve. So the team videotaped Gregg running with her shoes tied and analyzed the forces at work. 
 
 Related: How to Motivate Yourself to Work Out 
 
 Then they tried a mechanical pendulum to really pinpoint the movements involved. 
 
 “It might seem like a trivial problem, but the fact remains that we are trying to understand what fundamentally makes a knot strong,” said Gregg. 
 
 Why Some Knots Are Better 
 
 That has implications for surgery, aerospace engineering, even for parents of toddlers. 
 
 “When you talk about knotted structures, if you can start to understand the shoelace, then you can apply it to other things, like DNA or microstructures, that fail under dynamic forces,” said Christopher Daily-Diamond, the other graduate student who worked on the study. 
 
 “This is the first step toward understanding why certain knots are better than others, which no one has really done.” 
 
 Related: How a 'Might-Do' List can Help You Work Smarter 
 
 That’s not to say there isn’t a lot of knot science out there — there is. Websites will explain why granny knots are terrible and why a proper square knot not only looks better, but holds up better. 
 
 Gregg has made use of this new knowledge. 
 
 “There are many ways to solve this problem. If you are OK with double knotting, that’ll work,” she said. 
 
 She herself has learned to make a proper square knot instead of the twisted granny knot most people use to tie their shoes. 
 
 “I’ve been tying it a new way for about two years now,” she said. 
 
 It wasn’t easy to break old habits. “Muscle memory is both a blessing and a curse,” said Gregg. 
 
 “Every once in a while I find myself going back to my old habits. I remember the first time I did it, it took me a full two minutes to tie my shoe.”
– You get off the subway, stash your earbuds in your pocket, and when you pull them out again, they're completely tangled—even after you painstakingly untangled them yesterday. Why does it happen every time? Well, there's actually a whole branch of science to help explain, and it's called knot theory, Wired reports. A 2007 experiment conducted at the University of California, San Diego, may shed some light on the situation. Researchers dropped string into a motorized spinning box, examining the resulting knots. They argued that knots occurred because when a string is coiled in order to fit in a small space, its end is parallel to other sections. Spinning makes it possible for that end to loop around a segment, and more spinning means more looping. In half of the 10-second spins, strings came out knotted. The longer a string was, the higher the chance of knotting—up to a point. Strings shorter than a foot-and-a-half didn't usually get knotted, and those beyond five feet long got knotty just half the time. So how to avoid knots? Stiffer cables help reduce tangling, as do smaller spaces. Or you can try a do-it-yourself method to avoid tangling.