Why do people fart?

      The gas present in the intestine comes from swallowed air; gas produced in the intestinal lumen or diffused into the intestinal lumen from the blood. 
Normally, people swallow small amounts of gas during eating and drinking (gagging), but some people swallow gas unconsciously and repeatedly during eating and other occasions, especially when they are anxious. Most of the swallowed gas is subsequently burped out (belching), and only a small amount enters the small intestine. The amount of gas entering the intestine is largely influenced by body position: the esophagus empties its contents into the back of the stomach, and in the upright position, the gas rises above the liquid contents of the stomach and comes into contact with the gastroesophageal junction, where it can easily be burped out. When lying down, gas trapped below the gastric juice is more easily pushed to the duodenum. Excessive salivation can also lead to increased air swallowing and may be associated with many gastrointestinal disorders (GERD), ill-fitting braces, other therapies, or any cause of nausea. Belching may be associated with antacid application; because patients attribute relief of ulcer symptoms to burping rather than antacids, patients may continually burp to relieve pain.

Gas production in the intestinal lumen can occur through several mechanisms. Bacterial metabolism can produce large amounts of hydrogen (H2), methane (CH4), and CO2. Almost all of the H2 is produced in the colon by bacterial metabolism of ingested fermentable substances (carbohydrates and amino acids), so the amount of hydrogen can be disregarded after a longer fast or when the food has been completely absorbed by the small intestine after a meal. Other poorly understood factors (such as differences in intestinal flora and dynamics) can also be associated with the production of different gases. The normal population cannot fully absorb carbohydrates from some common foods. Under normal conditions, excessive gas can also be produced from undigested polysaccharides in fruits and vegetables.

Large amounts of H2 can be produced after ingestion of certain fruits and vegetables containing undigested carbohydrates (e.g., cooked beans) and in patients with malabsorption, and patients with disaccharidase deficiency (mostly lactose intolerance) can excrete large amounts of disaccharides into the colon and ferment them to produce H2 (see section 30). Insufficient secretion and other causes of carbohydrate malabsorption should be considered.

CH4 is produced by the metabolism of endogenous substances by bacteria in the colon. The rate of CH4 production is only marginally affected by food intake. Some people excrete large amounts of CH4 continuously, while others produce little or no gas, mostly familially, in infancy, and for life.

CO2 may also be produced by bacterial metabolism, but one of its more important sources is the reaction of HCO-3 with H+, which releases 22.4 ml of CO2 per 1 mg equivalent of HCO-3. Hydrogen ions can come endogenously from hydrochloric acid in the stomach or exogenously from fatty acids released during fat digestion, which sometimes equates to hundreds of mg equivalent of hydrogen ions. Theoretically, up to 4 L of CO2 can be released into the duodenum after a single meal. Acidic products released in the colon by bacterial fermentation of unabsorbed carbohydrates may also react with HCO-3 and produce CO2. Although bloating may occasionally occur, the rapid absorption of CO2 into the bloodstream prevents intolerable flatulence.

The direction of gas dispersion between the intestinal lumen and the blood depends on the partial pressure difference between the two. The production of H2, CH4 and CO2 reduces the partial pressure of nitrogen in the intestinal lumen so that it is much lower than that in the blood, which explains the high amount of nitrogen in the intestinal lumen.