Forgive baristas. You’d be a little emo too if the irreducible unit of your job involved juggling variables including not only the choice of coffee bean and how long it was roasted, but also water pressure, water temperature, total coffee mass, size of individual coffee grains (ranging from 100 to 200 μm—that’s grind setting), and the degree to which those grains are packed together, all working to optimally extract the more than 2,000 different molecules that contribute to taste and smell. Now imagine that even if you follow the boss’s recipe, which usually only specifies some of those things, you still don’t always get 40 milliliters of consistent espresso. It’s a process that 40 pages of partial differential equations can barely wrap their squiggly little symbolic arms around.

No wonder the barista never gets your name right.

In fact, the one thing that coffee specialists agree on is that it’s all very complicated. But now one of them—a computational chemist with a sideline in championship-level espresso-pulling named Chris Hendon—is offering a solution to this specific reproducibility crisis. After six years of work, Hendon says he has a kind of formula for dealing with all those variables to ensure a heretofore unobtainable same-same espresso every time. To be clear, these are the kind of procedural, methodological matters that coffee adherents fight duels over. If all this research seems like a tempest in a teacup (or a dustup in a demitasse?) well, coffee is a high-stakes game.

Hendon got interested in coffee as a PhD student in England, but his fascination extended beyond its function as a solution of good ol’ C 8 H 10 N 4 O 2 . (That’s caffeine.) Hendon wanted to know about all the other stuff in there too, and his friendship with a local coffee pro turned into stints on the UK and US Barista Championship teams, the World Cup of coffee. “You usually see that the score sheets vary between the judges, and it’s not the judges’ palettes varying. It’s that you pulled four shots of espresso and they don’t taste the same,” Hendon says. “I’ve tasted these espressos. These things are crazy. They’re so good, and you’re not able to make four reproducible ones during competition? That’s where it started.”

Tweaking the kind of variables that shot-pullers generally use to try to pull a perfect cup—grind and tamping down, and sometimes water temperature and pressure—didn’t seem to fix the problem. So Hendon started messing with more inscrutable variables in the lab, like the mineral content of the water or the age of the beans. “We wanted to be able to predict espresso extractions,” Hendon says. A cup of coffee is mostly water, mixed with dissolved solids (around 1 percent in pour-over and anywhere from 7 percent to 12 percent in espresso). So “extraction yield” uses the refractive index of the coffee, essentially the amount of light that can pass through it, to infer how much coffee’s in the coffee; it’s roughly the equivalent of “brix” in wine. “As the density of the coffee increases, or you dissolve more stuff, you see a proportional increase in refractive index,” Hendon says. “It doesn’t tell you any qualitative information. It could be the worst-tasting cup of coffee you ever had and it could have the same extraction yield as the best.” But it’s something you can count.