We tend to yawn most on first awakening, when we are bored, when we are trying not to fall asleep, and sometimes when we are nervous. A yawn is usually followed by a feeling of general well-being and relaxation, but also of increased alertness. Everyone yawns, from small babies to the elderly, and other mammals, birds, reptiles and even fish all yawn.
Yawning is also usually accompanied by the urge to stretch, technically known as pandiculation, and some have concluded that this urge to stretch the muscles is part of a yawn's alertness function. However, it is notable that, while yawns on awakening tend to be accompanied by stretching, yawns before sleep tend not to be. The action of yawning also has the effect of stretching the eardrums and opening the Eustachian tubes to the ears (which is why a yawn often serves to “unpop” ears popped due to pressure changes), and it is usually accompanied by characteristic motions, such as a throwing back of the head and a squinting or closing of the eyes.
In humans, yawning can be observed in utero by the third trimester, and can be clearly seen in newborn babies. This early development, and its prevalence in even quite rudimentary animals like reptiles and even fish, is evidence of its evolutionary antiquity. Among most mammals, males yawn more than females, suggesting a possible link to testosterone and threat gestures, but, among humans, males and females yawn about equally, perhaps indicating that this evolutionary behaviour no longer applies to modern humans.
Given that yawns tend to occur during times of sleepiness, boredom and nervousness, it seem intuitively likely that a major function of yawning (and the stretching that usually accompanies it) may be to help make us more alert, although exactly how this works is still not clear. It was believed for many years that yawning served to provide more oxygen to the blood, and particularly to the brain, although this now appears not to be the case (yawning as a result of high levels of carbon dioxide or low levels of oxygen has been conclusively disproved in many experiments and studies, although the belief is still widespread, even within the medical sector).
Yawning may, however, have some minor effect on body temperature, and particularly in cooling the brain, by cooling the blood which eventually makes its way to the brain (the brain is known to work most efficiently within quite a narrow temperature range, and to be extremely sensitive to overheating). This hypothesis has been backed up by recent studies of the effects of yawning on the brains of rats, and also by recent research which suggests that yawning occurs more in the warmer summer months.
Furthermore, some studies have shown that yawning is accompanied by increases in heart rate, lung volume and eye muscle tension, physiological effects different from those accompanying a normal deep inhalation, which also tends to lend some support to the brain cooling hypothesis. Additionally, there is some speculation that the increased bood flow to the brain that occurs during yawns increases the speed of neurotransmitter activity in the brain, leading to quicker reactions and increased alertness. Interestingly, stress and anxiety also cause the brain to heat up, which neatly explains the otherwise inexplicable tendency for yawning in, for example, parachutists about to jump from a plane, Olympic athletes getting ready to compete, etc.
Many of the muscular and respiratory features of yawning are shared by sneezing, and in some respects a yawn is a kind of slow-motion sneeze. Perhaps more surprisingly, it also shares many features with orgasm (some individuals taking certain types of antidepressants even experience yawns that trigger orgasms!) In rare cases, chronic yawning has been reported, or conversely a persistent inability to effectively yawn (leading to a frustrating feeling of being constantly in mid-yawn, but without the satisfaction that a completed yawn usually brings). Even stranger, some hemiplegic people (paralyzed on one side of their body, e.g. after a stroke) sometimes experience spontaneous lifting or flexing of otherwise paralyzed limbs, known as an "associated response". Even individuals with "locked-in syndrome" or those in a perisistent vegetative state can be observed to yawn, despite their complete unresponsiveness and immobility in all other respects.
To some extent, yawning is a reflex, controlled by the same neurotransmitters in the brain (including serotonin, dopamine and glutamate) that affect emotions, mood and appetite. But it is not a reflex in the same sense as a physical knee-jerk, for example, and it may also be to some extent a semi-voluntary action. Having said that, it is not usually possible to voluntarily initiate a yawn, which is evidence of its unconscious control. Intense self-awareness (e.g. when being specifically observed) also tends to inhibit yawning (a factor that needs to be taken into account in experimental studies).
Interestingly, yawning is in fact contagious, albeit not in the technical sense (i.e. it is not transmitted by germs), but in the sense of involuntary imitation and positive feedback: when we see someone yawn, it makes us want to yawn too, and sometimes even thinking or reading about yawning can be enough to trigger one, as can the audio-only stimulus of the sigh-like sound of a yawn. This appears to be more due to social conditioning than to any purely physiological reaction, and it has been hypothesized that a major function of the contagiousness of yawning may be to promote social cohesiveness, and possibly to ensure that everyone in a social grouping is equally alert during a period of drowsiness or boredom when guards might otherwise be let down. It may therefore be a kind of survival instinct inherited from our evolutionary past.
Although the gaping mouth is the most obvious trait of yawning, it is apparently not essential to its contagiousness: yawns with the mouth hidden (either by a polite hand, or covered up in a video or photo) are just as effective as stimuli, and the observer is able to pick up on other aspects (eye, face and body patterns and movements). On the other hand, the mouth alone is not a sufficient stimulus to ensure contagiousness (the gaping mouth on its own could equally well indicate singing or yelling).
The idea of yawning as an empathetic reaction is supported by studies showing that children with autism spectrum disorders (who are typically less prone to empathy) tend to be less affected by contagious yawning. Schizophrenics and schizotypal individuals, who also tend to be deficient in their ability to empathize, also show reduced susceptibility to contagious yawns, as do young children (under the age of about five) for similar reasons. Although most animals yawn spontaneously, contagious yawning appears to be limited to those higher primates that also demonstrate empathy and self-awareness. It has also been shown that the contagiousness of yawning among developmentally normal people tends to be strongest among family members, followed by friends and then acquaintances, and it is least strong among strangers.