When we go to a party, we all run our own little calculations (consciously or not) to try to identify this golden moment. For instance, my friend Sam Brodey, a political reporter in Washington, D.C., has a “38-minute rule”: For low-key parties with friends and food, he typically likes to show up 38 minutes after the stated start time. “30 minutes would [be] too early, and 45 too late,” he explained. (For a larger, rowdier house party, he shoots for an hour after the start time.)

I like the simplicity of the 38-minute rule, but for help with some more complicated arrival-time calculus, I reached out to someone with a deep understanding of, well, calculus: Daniel Biss, a mathematician who appreciates how quantification can veer into absurdity. Years ago, when a friend of his, the novelist John Green, wanted to have a precocious character in one of his books develop a formula for predicting the outcome of a romantic relationship, Biss drew up a delightfully complex one with variables such as the “Dumper/Dumpee differential.” It appears in the book An Abundance of Katherines and produces results that can be plotted on a graph.

Biss, a former math professor at the University of Chicago (and the current mayor of Evanston, Illinois), accepted my request to make a similarly preposterous formula for calculating the perfect time to arrive at a party. The result, which you can see—and plug your own numbers into—below, accounts for how punctual your friends are, how early or late you prefer to be, how excited you are about the party, and how accurately you tend to predict the time you’ll get there.