Mo Gawdat had it all. He was a high flyer in his homeland of Egypt who earned a lot of money from as early as his late 20s, which helped to support his loving wife and two children.
It could be said that his life was the epitome of happiness. But despite everything, Gawdat was completely miserable for years in his 20s and 30s.
As an engineer, he had developed a mind-set of trying to control everyone and everything around him, and would constantly complain when life didn't go his way.
Putting his pragmatic brain to good use, Gawdat - who is currently the chief business officer at Google X - decided to devote as much time as he could to discovering how happiness could be attained as a lasting state of being - in fact, he spent 10 years reading about happiness.
But, as he says in a talk he gave at Google (tinyurl.com/star2-gowdat), he "didn't get it".
So, like any engineer worth his/her salt, he dedicated himself to solving the problem of happiness by scientific means.
"The way I did it was by literally taking as many data points as I could find of situations where I felt happy, and trying to find the thread line that ran between them," he says in an e-mail interview.
"You can ask a million people around you, 'What is happiness to you?' and people will say things like, 'Happiness is to see my daughter smile', 'Happiness is to be in nature', 'Happiness is to have a good cup of coffee'. All of those things are not conclusive - they're reasons for happiness, but they're not the pattern of happiness."
Eventually, he came up with an equation that, in his opinion, can be used to maintain happiness regardless of what's happening in your life.
Happiness, says Gawdat, is equal to or greater than your perception of the events of your life, minus your expectations of how life should behave.
In other words, if you perceive the events in your life as being equal to or greater than your expectations, you'll be happy - or, at least, not unhappy.
This equation for happiness is explored at length in Gawdat's book, Solve For Happy: Engineer Your Path To Joy (Bluebird Books for Life, 2017).
In the book, he explains his "6-7-5" model, which we need to understand if we're to achieve happiness on demand.
First, there are the "6 Grand Illusions", which are the illusions of thought, self, knowledge, time, control, and fear.
Next, we have the "7 Blind Spots" of our filters, assumptions, predictions, memories, labels, emotions, and exaggerations.
Finally, we are encouraged to reflect on the "5 ultimate truths" of now, change, love, death, and design.
So what's the first step we need to take on the path to lasting happiness?
"It starts by realising that, sometimes, things that make us unhappy are just going to happen and there is nothing you can do to change that," says Gawdat.
"When such things happen, what do you want to do? Do you want to remain in that state of unhappiness for the rest of your life, to have no impact on the world or no motivation to find happiness again? Or do you want to accept the fact that sometimes life will get tough on occasion, and commit to making life a little bit better tomorrow than it is today?"
In 2014, Gawdat's happiness equation was put to the ultimate test when he lost his 21-year-old son, Ali, following complications during a routine operation.
The loving father describes his son as "the light of my life", and told a touching tale of how friends came to pay their last respects with tears in their eyes, which quickly transformed to joy and a celebration of a cherished friend who enriched their lives in so many ways.
The loss of his son inspired Gawdat to put his thoughts on happiness down on paper as a tribute to the wise young man who helped his father to put the equation together.
And so Solve For Happy became, in part, Ali's legacy, with Gawdat hoping that it will help to bring happiness to people around the world.
"When I lost Ali, of course I had the right to crumble and cry for the rest of my life - but what difference would that have made?" says Gawdat.
"Would it have made my family happier? Would it have made me work better - would it have made Ali come back? Life was amazing with him around, and it got worse when he left. But now, it's getting a little better again and I hope that he's proud of me, that I'm doing this."
Not that Gawdat didn't feel devasted; he felt all the crushing devastation and pain that comes with losing a child, and he admits that the pain is still with him today.
However, he believes that, while pain is a necessary part of life, we don't have to add to it by suffering needlessly.
"The difference between pain and suffering is paramount. Pain comes from outside you: it's the world telling you that you need to be alert. Suffering is when you recall the pain over and over in your head, which causes you the psychological torture that you feel from this.
"When I think about my wonderful son Ali, I don't remember losing him, I remember having him. I can think of the same event and think how I was blessed to have 21-and-a-half amazing years with this young man who completely gave me love and knowledge and wisdom. He was the light of my life and so, instead of remembering him with sadness, I can remember him with happiness."
Happiness is when we're at peace with life and we wouldn't mind if it didn't change much.
Even though most of us would like to be happier, we nevertheless struggle to cultivate happiness beyond fleeting moments of joy that arise from time to time.
To develop happiness, says Gawdat, it has to be prioritised in the same way that we might prioritise a healthy lifestyle.
When we begin going to the gym or ditching junk food for healthier options, it can be difficult at first, but it soon becomes easier and we are able to enjoy the benefits that come with our new habits.
"You are in charge of your life: if you make something a priority, you make it happen," he insists.
"For example, if you make being paid at the end of the month a priority, you show up to work every day to make sure you get paid. Unless you make happiness a priority, there's nothing anyone can do to help you.
"When you make it a priority, it might be difficult at the beginning, but then it gets a little easier. The 10th time you go to the gym, it becomes a lot easier, and by the 20th time you start to wonder how you ever lived without going to the gym.
"I think that's the message for everyone to take on board: If you prioritise happiness, it becomes easy and you can make it happen. If you don't, then you'll always have your problems."