If you sometimes start your morning with a frothy cappuccino and finish off the evening  with a heady glass of beer, then your day opens and closes with one of the most scientifically intriguing kinds of food: the edible foam. There are deep mathematical mysteries in these interlocked bubbles, and recently they have also become one of the most fertile areas for culinary innovation.

Top-ranked chef Ferran Adrià of elBulli in Catalonia, Spain, began experimenting with culinary foams in the mid-1990s in his quest to present diners with new and unexpected culinary experiences. Adrià used unconventional foaming agents such as gelatin or lecithin rather than eggs or cream. He used whipping siphons pow­ered by pressurized nitrous oxide—much like cans of Reddi-wip but sturdier—to create eth­er­eal foams from foods as diverse as cod, foie gras, mushrooms and potatoes. That started a revolution in foams, as chefs, among them Hes­ton Blumenthal of Bray, England, New York City’s Wylie Dufresne, and Chicago’s Grant Achatz, have taken to foaming all manner of savory foods.

These dishes have an aura of mystique about them and not just for their novel texture. Although foams may look like random jumbles, the bubbles within all foams seem to self-organize to obey three universal rules first observed by Belgian physicist Joseph Plateau in 1873. These rules are simple to describe but have been remarkably hard to explain. The first rule is that whenever bubbles join, three film surfaces intersect at every edge. Not two; never four—always three. Second, each pair of intersecting films, once they have stabilized, forms an angle of exactly 120 degrees. Finally, wherever edges meet at a point, the edges always number exactly four, and the angle is always the inverse cosine of –1/3 (about 109.5 degrees).

Only a century later, in 1976, did Rutgers University mathematician Jean Taylor prove that, at least in the case of two joined bubbles, Plateau’s rules derive from the action of surface tension, which forces the bubbles to adopt the most stable configuration. Mathematicians are still attempting to nail down exactly what happens in a froth of three or more bubbles, as well as the unsolved question of what arrangement of bubble shapes in a foam will fill a container while using the least surface area (and thus the least energy). In 1887 Lord Kelvin had proposed that a honeycomb of tetra­dec­a­hedrons, each with six square and eight hexagonal faces, is the answer. But in 1994 phys­i­cists Dennis Weaire and Robert Phel­an of Trinity College in Dublin published an even better—though not neces­sar­ily optimal—solution: a foam of two kinds of cells, one made solely from 12 pentagons and the other constructed from two hexagons and 10 pentagons.

In foamy foods, bubbles that do not follow Plateau’s rules quickly pop. The same fate occurs to bubbles that are too small: surface tension raises the pressure inside them beyond the breaking point. That is one reason that liquid foams become coarser as they age—and why it is best to sip your cappuccino while it is fresh.