The scientists who developed a neat equation to predict happiness, highlighting the importance of expectations, have a new, improved formula showing how well-being depends not only on what happens to us but also how this compares to other people.

The pursuit of a recipe for happiness has consumed many years for many scientists. They want to define the joy and feeling of happiness, how people come to experience it and how to help them get a bit more of it.

It's a complicated search but there are some things we do know for sure about happiness.

We are more likely to be happier if we have a happy friend nearby. Happiness is infectious.

And we know that money does matter. We need enough of it to live well - that makes us happier than not having money. But after a point, more money doesn't make a lot of difference.

And money spent on doing, rather than by buying things, works. Apparently an experience, such as a holiday or going skydiving, brings more happiness than a good shopping spree, according to research in the journal Psychological Science.

The new equation, showing how happiness depends not only on what happens to us but also how this compares to other people, has been developed by University College London researchers.

This team developed in 2014 an equation to predict happiness, highlighting the importance of expectations.

That earlier research showed how happiness depends not on how well things are going but whether things are going better or worse than expected.

The latest study, published in the journal Nature Communications, found that inequality reduces happiness.

This is true whether people are doing better or worse than another person they just met.

"Our equation can predict exactly how happy people will be based not only on what happens to them but also what happens to the people around them," says Dr Robb Rutledge of the Institute of Neurology and Max Planck Centre for Computational Psychiatry and Ageing Research.

"On average we are less happy if others get more or less than us, but this varies a lot from person to person.

"Interestingly, the equation allows us to predict how generous an individual will be in a separate scenario when they are asked how they would like to split a small amount of money with another person.

"Based on exactly how inequality affects their happiness, we can predict which individuals will be altruistic."

The study experiments included gambling and anonymously splitting a small amount of money with another person that they had just met.

On average, people whose happiness was affected by getting more than others, something that might relate to guilt, gave away 30 percent of the money.

Those who were affected by getting less than others, something that might relate to envy, gave only 10 percent.

"Our results suggest that generosity towards strangers relates to how our happiness is affected by the inequalities we experience in our daily life," says Archy de Berker, co-lead author of the study.

Economists have difficulty explaining why some people are more generous than others.

This latest research at University College London give a clue. This is the first time that people's generosity has been directly linked to how inequality affects their happiness.

For those who like to work their way through a few numbers, here's the latest, improved happiness formula:

And here's the explanation, in full text:

    This is the updated equation to predict happiness, where t is the trial number, w0 is a constant term, other weights w capture the influence of different event types, 0 ? γ ? 1 is a forgetting factor that makes events in more recent trials more influential than those in earlier trials, CRj is the certain reward if chosen instead of a gamble on trial j, EVj is the average reward for the gamble if chosen on trial j, and RPEj is the RPE (reinforcement prediction error) on trial j contingent on choice of the gamble. The RPE is equal to the reward received minus the expectation in that trial EVj. If the CR was chosen, then EVj = 0 and RPEj = 0; if the gamble was chosen, then CRj = 0. The variables in the equation are quantities that the neuromodulator dopamine has been associated with in previous neuroscience studies. The additional term w4 relates to advantageous inequality (guilt) when the reward received by the subject Rj exceeds the reward received by the other player Oj, and w5 relates to disadvantageous inequality (envy) when Oj exceeds Rj.

This article was originally published by Business Insider.

More from Business Insider: