"What came first, the music or the misery?" This John Cusack one-liner from High Fidelity captures how many people think about sad music: potentially depressing but totally necessary.

Now, psychologists have determined a reason why we're so attracted to melancholy songs: They're actually good for our emotional health. To paraphrase Paul McCartney's Hey Jude, sad songs do make it better.

The science: Researchers Liila Taruffi and Stefan Koelsch from the Free University of Berlin collected detailed data on the music-listening habits of some 772 people, 408 from Europe and the remainder from Asia and North America. The participants reported the frequency with which they listened to sad music, when and why they did, and what kind of emotions it evoked in them. The results were published in the journal PLOS ONE.

The authors ranked the reasons why participants typically choose to listen to sad music, as well as their evaluation as to the function of the sad tunes served in that context.

What it means: Despite the range of reasons why people report listening to sad music, it's mostly because they're feeling sad or lonely and want to improve their emotional state.

Sad music leads listeners to experience "a wide range of complex and partially positive emotions, such as nostalgia, peacefulness, tenderness, transcendence and wonder," the authors wrote. "The average number of emotions that participants reported to have experienced in response to sad music was above three. This suggests that a multifaceted emotional experience elicited by sad music enhances its aesthetic appeal."

A few respondents in the study reported they use music as a trigger to relive past events, while relaxation and accenting nature fall closely behind. Only a few cite the construction of the music itself rather than the emotional response it inspires.

In practice, this means that over 76% of listeners reported nostalgia, 57.5% peacefulness and just over half tenderness. Less-reported emotions included tension, joyful activation and a sense of power:

Why it matters: The authors speculate that sad music is a "means for improving well-being," helping to "facilitate venting of negative emotion or mood" — hence the high numbers of people reporting listening to sad music in a time of emotional distress.

"Processing negative feeling(s) teaches us not only to avoid a similar emotionally negative experience later — a process not unlike the reinforcement of physical pain — but also to what would bring us positivity. Listening to sad music helps us focus in on what's making us sad by empathizing with someone else."

Or perhaps more aptly summarized by McCartney:

Hey Jude, don't make it bad