Mathematicians have come up with a formula that predicts how the head on a pint of beer will change after pouring.
Their advance could shed light on why the foam on a pint of lager quickly disappears, but the froth on a pint of Guinness sticks around.
The research could not only provide tips for better brewing, but could also have applications in metallurgy, say the authors.
Details of the work by mathematicians in the US appear in the journal Nature.
Beer foam, as well as metals and ceramics - for which the formula also works, is a cellular structure comprising networks of gas-filled bubbles separated by liquid.
The walls of these bubbles move as a result of surface tension. The speed at which the walls move is proportional to the curvature of the bubbles.
As a result of this movement, the bubbles merge and the structure "coarsens", meaning that the foam settles and eventually disappears.
The research extends work by computer pioneer John von Neumann, who in 1952 devised an equation to explain what happens to cellular stuctures in two dimensions.
Until now, nobody had been able to prove that von Neumann's result worked at higher dimensions.
Writing in Nature, Robert MacPherson, from the Institute for Advanced Study in Princeton, New Jersey, and David Srolovitz, from Yeshiva University in New York, describe an equation that works in three dimensions, as well as four, five and six dimensions.
"What happens in beer is the small bubbles shrink; the big bubbles grow," Professor Srolovitz told BBC News.
"Eventually, the big bubbles pop - although they pop for slightly different reasons. On Earth, there's gravity and the liquid that's within the walls tends to drain out back into the beer. The walls get thinner and thinner and eventually they pop."
Asked why some beers such as Guinness have a creamy head that persists longer than those of many lagers, Professor Srolovitz explained:
"What this theory does is tell you how every single bubble in the froth will evolve. There are some materials properties that go into the final equation.
"So for beer, it will be the diffusivity of the gas in that little liquid layer that's in the wall of the bubble. Another is the surface tension.
He added: "I don't know the tricks that Guinness uses; they could be adding a little surfactant to get the head just right. That is just pure speculation on my part."
But the equation can be applied to other materials, in particular, metals and ceramics.
Most engineered materials, including metals and ceramics are polycrystalline - that is, they are composed of many small crystalline grains which are separated by boundaries.
If, for example, a piece of metal is heated in a furnace, the average size of the metal grains grows.
The small grains will disappear, while the big ones will grow, due to changes in the boundaries between individual grains. Exactly the same mathematics can be used to describe this process as describes the evolution of froth on a pint of beer.
The work could help scientists develop improved materials.