Melancholia (from Greek μελαγχολία melancholia "sadness", literally black bile), also lugubriousness, from the Latin lugere, to mourn; moroseness, from the Latin morosus, self-willed, fastidious habit; wistfulness, from old English wist: intent, or saturnine, was a concept in ancient and pre-modern medicine. Melancholy was one of the four temperaments matching the four humours. In the 19th century, "melancholia" could be physical as well as mental, and melancholic conditions were classified as such by their common cause rather than by their properties.
The name "melancholia" comes from the old medical belief of the four humors: disease or ailment being caused by an imbalance in one or other of the four basic bodily liquids, or humors. Personality types were similarly determined by the dominant humor in a particular person. According to Hippocrates and subsequent tradition, melancholia was caused by an excess of black bile, hence the name, which means 'black bile', from Ancient Greek μέλας (melas), "dark, black", and χολή (kholé), "bile"; a person whose constitution tended to have a preponderance of black bile had a melancholic disposition. In the complex elaboration of humorist theory, it was associated with the earth from the Four Elements, the season of autumn, the spleen as the originating organ and cold & dry as related qualities.
Melancholia was described as a distinct disease with particular mental and physical symptoms in the 5th and 4th centuries BC. Hippocrates, in his Aphorisms, characterized all "fears and despondencies, if they last a long time" as being symptomatic of melancholia. When a patient could not be cured of the disease it was thought that the melancholia was a result of demonic possession.  
In his study of French and Burgundian courtly culture, Johan Huizinga noted that "at the close of the Middle Ages, a sombre melancholy weighs on people's souls." In chronicles, poems, sermons, even in legal documents, an immense sadness, a note of despair and a fashionable sense of suffering and deliquescence at the approaching end of times, suffuses court poets and chroniclers alike: Huizinga quotes instances in the ballads of Eustache Deschamps, "monotonous and gloomy variations of the same dismal theme", and in Georges Chastellain's prologue to his Burgundian chronicle, and in the late fifteenth-century poetry of Jean Meschinot. Ideas of reflection and the workings of imagination are blended in the term merencolie, embodying for contemporaries "a tendency", observes Huizinga, "to identify all serious occupation of the mind with sadness".
The most extended treatment of melancholia comes from Robert Burton, whose The Anatomy of Melancholy (1621) treats the subject from both a literary and a medical perspective. Burton wrote in the 16th century that music and dance were critical in treating mental illness, especially melancholia.
But to leave all declamatory speeches in praise  of divine music, I will confine myself to my proper subject: besides that excellent power it hath to expel many other diseases, it is a sovereign remedy against  despair and melancholy, and will drive away the devil himself. Canus, a Rhodian fiddler, in  Philostratus, when Apollonius was inquisitive to know what he could do with his pipe, told him, "That he would make a melancholy man merry, and him that was merry much merrier than before, a lover more enamoured, a religious man more devout." Ismenias the Theban,  Chiron the centaur, is said to have cured this and many other diseases by music alone: as now they do those, saith  Bodine, that are troubled with St. Vitus's Bedlam dance.
A famous allegorical engraving by Albrecht Dürer is entitled Melencolia I. This engraving portrays melancholia as the state of waiting for inspiration to strike, and not necessarily as a depressive affliction. Amongst other allegorical symbols, the picture includes a magic square, and a truncated rhombohedron. The image in turn inspired a passage in The City of Dreadful Night by James Thomson (B.V.), and, a few years later, a sonnet by Edward Dowden.
During the early 17th century, a curious cultural and literary cult of melancholia arose in England. It was believed that religious uncertainties caused by the English Reformation and a greater attention being paid to issues of sin, damnation, and salvation, led to this effect.
In music, the post-Elizabethan cult of melancholia is associated with John Dowland, whose motto was Semper Dowland, semper dolens. ("Always Dowland, always mourning.") The melancholy man, known to contemporaries as a "malcontent," is epitomized by Shakespeare's Prince Hamlet, the "Melancholy Dane." Other major melancholic authors include Sir Thomas Browne, and Jeremy Taylor, whose Hydriotaphia, Urn Burial and Holy Living and Holy Dying, respectively, contain extensive meditations on death.
A similar phenomenon, though not under the same name, occurred during the German Sturm und Drang movement, with such works as The Sorrows of Young Werther by Goethe or in Romanticism with works such as Ode on Melancholy by John Keats or in Symbolism with works such as Isle of the Dead by Arnold Böcklin. In the 20th century, much of the counterculture of modernism was fueled by comparable alienation and a sense of purposelessness called "anomie"; earlier artistic preoccupation with death has gone under the rubric of memento mori.
The Arabic word found as ḥuzn and ḥazan in the Qur'an and hüzün in modern Turkish refers to the pain and sorrow over a loss, death of relatives in the case of the Qur'an. Two schools further interpreted this feeling. The first sees it as a sign that one is too attached to the material world, while Sufism took it to represent a feeling of personal insufficiency, that one was not getting close enough to God and did not or could not do enough for God in this world. The Turkish writer Orhan Pamuk, in the book Istanbul: Memories and the City, further elaborates on the added meaning hüzün has acquired in modern Turkish. It has come to denote a sense of failure in life, lack of initiative and tendency to retreat into oneself, symptoms quite similar to melancholia. According to Pamuk it was a defining character of cultural works from Istanbul after the fall of the Ottoman Empire. One may see similarities with how melancholic romantic paintings in the west sometimes used ruins from the age of the Roman Empire as a backdrop.
As a parallel with physicians of classical Greece, ancient Arabic physicians and psychologists also categorized ḥuzn as a disease. Al-Kindi (c. 801–873 CE) links it with disease-like mental states like anger, passion, hatred and depression, while the Persian physician Avicenna (980–1037 CE) diagnosed ḥuzn in a lovesick man if his pulse increased drastically when the name of the girl he loved was spoken. Avicenna suggests, in remarkable similarity with Robert Burton, many causes for melancholy, including the fear of death, intrigues surrounding one's life, and lost love. As remedies, he recommends treatments addressing both the medical and philosophical sources of the melancholy, including rational thought, morale, discipline, fasting and coming to terms with the catastrophe.
The various uses of ḥuzn and hüzün thus describe melancholy from a certain vantage point, show similarities with female hysteria in the case of Avicenna's patient and in a religious context it is not unlike sloth, which by Dante was defined as "failure to love God with all one's heart, all one's mind and all one's soul". Thomas Aquinas described sloth as "an oppressive sorrow, which, to wit, so weighs upon man's mind, that he wants to do nothing."
|Wikimedia Commons has media related to Melancholia.|