If you're fortunate enough to find someone you want to settle down with forever, the next question is: How do you achieve happily ever after?

According to mathematician Hannah Fry, it may come down to a simple formula. 

Fry, who works at the UCL Centre for Advanced Spatial Analysis in London, explains in her 2014 TED Talk and recently released book, The Mathematics of Love that the best predictor of long-lasting relationships is how positive and negative a couple can be to one another. 

In her book, she discusses the groundbreaking work of psychologist John Gottman and his team. Over many years they observed hundreds of couples and noted their facial expressions, heart rates, blood pressure, skin conductivity, and the words they used in conversation with their partners.

They discovered low-risk couples have more positive interactions with each other, and high-risk couples tend to spiral into negativity. 

Equation

As Fry puts it, "In relationships where both partners consider themselves as happy, bad behaviour is dismissed as unusual". For example, a wife might assume her husband's grumpiness is due to stress at work or a bad night's sleep. 

"In negative relationships, however, the situation is reversed," writes Fry. "Bad behaviour is considered the norm." A husband, for instance, might think his wife's grumpiness is 'typical', due to her 'selfishness' or other negative personality trait.

Gottman then teamed up with mathematician James Murray, and they began to understand how these spirals of negativity happen. They came up with the below equations, which predict how positive or negative a husband and wife will be at the next point in their conversation.

As Fry explains, the model is framed as husband and wife but also applies to same-sex spouses and unmarried couples in long-term relationships.

Equation2

The wife's equation is the top line, the husband's the bottom, and it solves for how positive or negative the next thing they say will be.

In hers, w stands for her mood in general, rwWt represents her mood when she's with her husband, and IHW shows how the husband's actions influence her. The husband's follows the same pattern. 

Equation3

Gottman and Murray found that the influence a couple has on each other is the most important factor. If a husband says something positive, like agrees with his wife or makes a joke, the wife will likely react positively in turn. Meanwhile, if he does something negative, like interrupts her or dismisses something she's said, she will likely be negatively impacted.

The 'negativity threshold' pinpoints when the wife becomes so frustrated by her husband that she responds very negatively.

Interestingly, Fry says she would have imagined that the best relationships would have a high negativity threshold, meaning they'd be focused on compromise and would bring up an issue only if it was "a really big deal." But in fact, the opposite is true. 

"The most successful relationships are the ones with a really low negativity threshold," writes Fry. "In those relationships, couples allow each other to complain, and work together to constantly repair the tiny issues between them. In such a case, couples don't bottle up their feelings, and little things don't end up being blown completely out of proportion."

Happy couples, then, tend to have more positive interactions than negative ones, and thus are more likely to give each other the benefit of a doubt. When there is an issue, they're more likely to bring it up quickly, fix it, and move on.

"Mathematics leaves us with a positive message for our relationships," Fry says, "reinforcing the age-old wisdom that you really shouldn't let the sun go down on your anger."

Watch Fry's TED Talk on the mathematics of love below.

This article was originally published by Business Insider.

More from Business Insider: