If you hold a piece of dry spaghetti at two ends and try to snap it, it almost never breaks cleanly into two. Seriously—try it. The strand splits into two long pieces, and one or more smaller chunks of pasta usually ping away from the break.

In case you were wondering, mathematicians have finally figured out a technique to ensure the long-coveted two-piece break. The secret isn’t bend and snap, it’s bend and twist.

Believe it or not, the mysteries of spaghetti have long troubled the great minds of science. Theoretical physicist Richard Feynman—more famous for his Nobel Prize-winning quantum electrodynamics research and his work on the atomic bomb—reportedly puzzled over the problem.

In 2005, researchers finally explained the mystery of why the pasta never seems to snap into two. When you bend a long, thin rod like a piece of spaghetti, it breaks near the middle. This is the most curved region of the rod. Basile Audoly and Sebastien Neukirch worked out this causes a snap-back, where a vibration races through the stick and causes other breaks.

Their revelatory research was recognized with 2006’s Ig Nobel prize for physics. Other winners of that year's awards—which celebrate improbable research—include Nic Svenson and Piers Barnes, who won the mathematics prize for working out how many photos you need to take to ensure nobody’s blinking in a group photo.

Taking this work to its logical conclusion, Ronald Heisser, Vishal Patil and other researchers snapped hundreds more sticks of spaghetti to figure out how to achieve a two-piece break. Their findings were published online Monday in Proceedings of the National Academy of Sciences of the United States of America.

“They did some manual tests, tried various things, and came up with an idea that when he twisted the spaghetti really hard and brought the ends together, it seemed to work and it broke into two pieces,” said co-author Jörn Dunkel, associate professor of physical applied mathematics at MIT in a statement. “But you have to twist really strongly. And [Heisser] wanted to investigate more deeply.”

Heisser constructed a mechanical fracture device to twist the sticks with more precision. He and Patil filmed the device break hundreds of spaghetti sticks to crack the recipe for a perfect break.

First, they discovered, you have to twist the spaghetti at an angle of nearly 360 degrees. Then slowly draw the clamps holding each end of the strand together until it snaps. The technique works for both Barilla No 5 and Barilla No 7 spaghetti variations, the researchers reported.

Patil figured out why this technique preserved the integrity of the strands using mathematics. “Once [spaghetti] breaks, you still have a snap-back because the rod wants to be straight,” Dunkel explained. “But it also doesn’t want to be twisted.”

A “twist wave” generated by the unraveling strand moves faster than the vibration from the “snap-back.” This dissipates the potentially destructive energy and stops it fracturing the spaghetti any further. “That’s why you never get this second break when you twist hard enough,” Dunkel said.

Of course, if you don’t have a tailored spaghetti-snapping machine, you can always try it by hand. Twist your strand of spaghetti really hard and slowly bend, and maybe you too will achieve a perfect two-piece break.

Basile Audoly and Sebastien Neukirch did not immediately respond to a request for comment.