What is happiness? It’s a hard question to answer, but that hasn’t stopped scientists, economists, and mathematicians from trying. The quest for a happiness algorithm just got a boost, thanks to a group of neuroscientists who updated an equation with a major hole in it. See, the University College London team’s previous work had assumed that happiness is an individual matter, when everyone knows that’s not true. Your mood is not separate from the mood of people around you — and your sense of fairness is tied to your happiness, maybe more than you think.

In 2014, the researchers built their first computational model to demonstrate what happiness looked like mathematically. The equation was built off a series of tests and revealed that, essentially, the key to happiness was balancing expectations with results. But receiving rewards equal to what you thought you deserved isn’t the whole picture. When the team recognized they completely left out social aspects of happiness, they went back to the chalk board.

The happiness just got a lot more complicated, but no one said human emotions are simple. This is what the old equation looked like:

And here is the new one:

Translated to words, happiness at a given moment equals getting what you think you deserve, and also having the people around you get what they deserve. The team published their results this week in Nature Communications.

To get the data to build this model, the researchers introduced 47 subjects to each other, split them up into groups of 22 and 25, and had them take part in one of two studies, as well as an experimental task to familiarize the subjects to answering questions about their emotional state. In one of the experiments, the subjects had to play a classical dictator game, where they were charged with anonymously splitting money between themselves and a partner. The other experiment was a game with safe and risky options: Participants were told that if they made one choice, then someone else in the trial group would be stuck with the other. Meanwhile, the researchers kept track of the participants’ state of emotional well-being.

Here’s the surprising bit: The researchers found that in both experiments, subjects reported feeling less happy if they ended up better off than other participants. Success didn’t drive happiness, equality did.

“Our results provide striking quantitative confirmation that an individual’s subjective reports of momentary well-being in a social context reflect not only how well things are going relative to expectations, but also how things are going relative to other people,” write the authors.

In their paper the researchers also say that they hope their work lends scientific evidence that increasing inequality will make societies more unhappy — even for those at the top of the food chain.

Photos via University of College London, Nature Communications, Giphy