When it comes to happiness, it seems that the young and the old have the secret. And it turns out what's true for humans is also true for our primate cousins, explains neuroscientist Tali Sharot.

How does happiness change with age?

Most people assume that as children we live a carefree existence, then we go through the miserable confusion of teenage years ("Who am I?") but regain happiness once we figure it all out and settle down, only to then grow grumpy and lonely with every additional wrinkle and grey hair.

Well, this is utterly wrong.

It turns out that happiness is indeed high in youth, but declines steadily hitting rock bottom in our mid-40s - midlife crisis, anyone? Then, miraculously, our sense of happiness takes a turn for the better, increasing as we grow older.

About the author Tali Sharot is a neuroscientist at University College, London • Dara O Briain's Science Club is broadcast on BBC Two on Tuesday 4 December at 21:00 GMT • Follow @BBCScienceClub

This U-shape pattern of happiness over the life span (high during youth and old age, low during midlife) has been observed across the globe, from Switzerland to Ecuador, Romania to China. All in all, it has been documented in more than 70 countries, in surveys of more than 500,000 people in both developing and developed countries.

How can we explain these counter-intuitive findings?

Does it have something to do with juggling kids and careers in our 30s and 40s? Apparently not. Even after accounting for the presence of kids in the household the U-shape pattern of happiness remains.

Perhaps the pattern is due to generational differences? As studies did not follow the same individuals throughout life, but rather different individuals of different ages, it could be that teenagers and the elderly are happier than the middle-aged because they were born during better times.

But this is not the case. Controlling for "cohort effects" does not seem to affect the U-shape pattern. It also persists when other demographic factors are accounted for, including marital status, education, employment status, and income.

Then, just last month, a group led by Prof Andrew Oswald from the University of Warwick, reported that happiness of our evolutionary cousins - the great apes - also follows a U-shape pattern throughout life.

Of course we cannot ask apes to rate their life satisfaction on a scale from one to 10. But the well-being of 508 apes was estimated by asking their human care-givers to assess it. Apes, like humans, were less happy during midlife than when younger or older.

The existence of a midlife crisis in the great ape strengthens the notion that the pattern of happiness throughout life is not due to socioeconomic factors. This leaves two likely explanations.

Firstly, "the survival of the happiest" - happiness is known to be related to longevity. Put simply, the happier live longer, while the pessimistic die prematurely, possibly because the latter experience more stress, which impacts on health negatively.

Image caption Happy now?

Therefore, the elderly individuals who remain for scientists to test should be happier than the average 30- or 40-year-olds. But this only explains the latter half of the U-shape.

Secondly, the U-shape could arise in both humans and apes because of similar age-related changes in brain structures that influence happiness. One part of our brain which changes considerably both throughout the first two decades of our life, and as we move into old age, is the frontal lobe.

Our frontal lobes mature well into our mid-20s and then start deteriorating as early as 45. This means that as we develop, we slowly increase some frontal-lobe function, which we then lose later in life.

One such function is our ability to learn from bad news.

My colleagues and I have found that people tend to discount the relevance of undesirable information to themselves (such as news that alcohol is bad for your liver) but readily adopt good news (being told that red wine is good for the heart). So when smokers see warning signs on cigarette packets they think: "Yes, smoking kills - but mostly it kills the other guy."

At the same when we hear the housing market is going up we think: "The value of my house is going to double!"

Using brain imaging techniques we discovered that the tendency to discount bad news is related to how well regions of the frontal lobe are coding unexpected negative information.

Now, you may think that discounting bad news can get people into trouble - for example, causing us to smoke more and save less. There is some truth to this, but it is also good for our mental health.

Our research shows that the successful incorporation of bad news is related to depression. Discounting bad news, as most of us do, presumably allows us to keep a rosy view of the future, and while this view is not necessarily realistic it does keep us happy.

Happiness around the world U-shape pattern is global, but age at which happiness is lowest differs between countries

Happiness hits rock bottom at 35.8 years in UK; low point in US only emerges a decade later; in Italy, happiness hits low at 64.2 years

US citizens are less happy with each passing decade since 1900; in Europe, happiness declined until 1950 and has been increasing steadily ever since

Women are at their least happy at 38.6 years on average; males hit low point at 52.9 years

But the tendency to discount bad news also follows a U-shape pattern over our lifespan. Kids, teenagers and the elderly discount unwanted information more than middle age individuals.

The developmental change in the frontal lobes appears to be mirrored by our ability to learn from bad news, which in turn could drive age-related differences in happiness.

So happiness may come at a price - a reduced ability to take into account unwanted information.

In essence, this means that we may need to re-frame health and safety campaigns, especially those targeted at the young and the elderly. Instead of, or in addition to, labelling a packet of cigarettes with the words "SMOKING KILLS", we may want to print "80% of people who try to quit smoking succeed".

And instead of highlighting the risks of skin cancer on a bottle of sun lotion, how about highlighting the sun cream's benefits (fewer wrinkles, healthier-looking skin)?

Will fewer people reach for another cigarette when we focus on social norms? Will more people protect their skin from UV rays when we emphasise the positive? Each case needs to be tested.

But given that we now know that people tend to respond to warnings with "It's unlikely to happen to me" and to the possibility of a glorious future with "Why not me?" there is reason to believe this may be so.

Tali Sharot is the author of The Optimism Bias and The Science of Optimism, of which this is an adapted extract

You can follow the Magazine on Twitter and on Facebook