You are a helpful, respectful, and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
What is Magnesium deficiency and explain in detail?
Magnesium deficiency is an electrolyte disturbance in which there is a low level of magnesium in the body. It can result in multiple symptoms. Symptoms include tremor, poor coordination, muscle spasms, loss of appetite, personality changes, and nystagmus. Complications may include seizures or cardiac arrest such as from torsade de pointes. Those with low magnesium often have low potassium.Causes include low dietary intake, alcoholism, diarrhea, increased urinary loss, poor absorption from the intestines, and diabetes mellitus. A number of medications may also cause low magnesium, including proton pump inhibitors (PPIs) and furosemide. The diagnosis is typically based on finding low blood magnesium levels (hypomagnesemia). Normal magnesium levels are between 0.6 and 1.1 mmol/L (1.46–2.68 mg/dL) with levels less than 0.6 mmol/L (1.46 mg/dL) defining hypomagnesemia. Specific electrocardiogram (ECG) changes may be seen.Treatment is with magnesium either by mouth or intravenously. For those with severe symptoms, intravenous magnesium sulfate may be used. Associated low potassium or low calcium should also be treated. The condition is relatively common among people in hospitals.

Signs and symptoms
Deficiency of magnesium can cause tiredness, generalized weakness, muscle cramps, abnormal heart rhythms, increased irritability of the nervous system with tremors, paresthesias, palpitations, low potassium levels in the blood, hypoparathyroidism which might result in low calcium levels in the blood, chondrocalcinosis, spasticity and tetany, migraines, epileptic seizures, basal ganglia calcifications and in extreme and prolonged cases coma, intellectual disability or death. Magnesium plays an important role in carbohydrate metabolism and its deficiency may worsen insulin resistance, a condition that often precedes diabetes, or may be a consequence of insulin resistance.People being treated on an intensive care unit (ICU) who have a low magnesium level may have a higher risk of requiring mechanical ventilation, and death.

Causes
Magnesium deficiency may result from gastrointestinal or kidney causes. Gastrointestinal causes include low dietary intake of magnesium, reduced gastrointestinal absorption or increased gastrointestinal loss due to rapid gastrointestinal transits. Kidney causes involve increased excretion of magnesium. Poor dietary intake of magnesium has become an increasingly important factor – many people consume diets high in refined foods such as white bread and polished rice which have been stripped of magnesium-rich plant fiber.Magnesium deficiency is not uncommon in hospitalized patients. Up to 12% of all people admitted to hospital, and as high as 60–65% of people in an intensive care unit, have hypomagnesemia.About 57% of the US population does not meet the US RDA for dietary intake of magnesium. The kidneys are very efficient at maintaining body levels; however, if the diet is deficient, or certain medications such as diuretics or proton pump inhibitors are used, or in chronic alcoholism, levels may drop.
Low levels of magnesium in blood may be due to not enough magnesium in the diet, the intestines not absorbing enough magnesium, or the kidneys excreting too much magnesium. Deficiencies may be due to the following conditions:

Medications
Loop and thiazide diuretic use (the most common cause of hypomagnesemia)
Antibiotics (i.e. aminoglycoside, amphotericin, pentamidine, gentamicin, tobramycin, viomycin) block resorption in the loop of Henle. 30% of patients using these antibiotics have hypomagnesemia.
Long term, high dosage use of proton-pump inhibitors such as omeprazole
Other drugs
Digitalis, displaces magnesium into the cell. Digitalis causes an increased intracellular concentration of sodium, which in turn increases intracellular calcium by passively increasing the action of the sodium-calcium exchanger in the sarcolemma. The increased intracellular calcium gives a positive inotropic effect.
Adrenergics, displace magnesium into the cell
Cisplatin, stimulates kidney excretion
Ciclosporin, stimulates kidney excretion
Mycophenolate mofetil

Genetics
Gitelman-like diseases, which include the syndromes caused by genetic mutations in SLC12A3, CLNCKB, BSND, KCNJ10, FXYD2, HNF1B or PCBD1. In these diseases, the hypomagnesemia is accompanied by other defects in electrolyte handling such as hypocalciuria and hypokalemia. The genes involved in this group of diseases all encode proteins that are involved in reabsorbing electrolytes (including magnesium) in the distal convoluted tubule of the kidney.
Hypercalciuric hypomagnesemic syndromes, which encompass the syndromes caused by mutations in CLDN16, CLDN19, CASR or CLCNKB. In these diseases, reabsorption of divalent cations (such as magnesium and calcium) in the thick ascending limb of Henles loop of the kidney is impaired. This results in loss of magnesium and calcium in the urine.
Mitochondriopathies, such as caused by mutations in SARS2, MT-TI or as seen with Kearns-Sayre syndrome.
Other genetic causes of hypomagnesemia, such as mutations in TRPM6, CNNM2, EGF, EGFR, KCNA1 or FAM111A. Many of the proteins encoded by these genes play a role in the transcellular absorption of magnesium in the distal convoluted tubule.

Metabolic abnormalities
Insufficient selenium, vitamin D or sunlight exposure, or vitamin B6.
Gastrointestinal causes: the distal digestive tract secretes high levels of magnesium. Therefore, secretory diarrhea can cause hypomagnesemia. Thus, Crohns disease, ulcerative colitis, Whipples disease and celiac sprue can all cause hypomagnesemia.
Postobstructive diuresis, diuretic phase of acute tubular necrosis (ATN) and kidney transplant.

Other
Acute myocardial infarction: within the first 48 hours after a heart attack, 80% of patients have hypomagnesemia. This could be the result of an intracellular shift because of an increase in catecholamines.
Malabsorption
Acute pancreatitis
Fluoride poisoning
Massive transfusion (MT) is a lifesaving treatment of hemorrhagic shock, but can be associated with significant complications.

Pathophysiology
Magnesium is a co-factor in over 300 functions in the body regulating many kinds of  biochemical reactions. It is involved in protein synthesis, muscle and nerve functioning, bone development, energy production, the maintenance of normal heart rhythm, and the regulation of glucose and blood pressure, among other important roles. Low magnesium intake over time can increase the risk of illnesses, including high blood pressure and heart disease, diabetes mellitus type 2, osteoporosis, and migraines.There is a direct effect on sodium (Na), potassium (K), and calcium (Ca) channels. Magnesium has several effects:

Potassium
Potassium channel efflux is inhibited by magnesium. Thus hypomagnesemia results in an increased excretion of potassium in kidney, resulting in a hypokalaemia. This condition is believed to occur secondary to the decreased normal physiologic magnesium inhibition of the ROMK channels in the apical tubular membrane.In this light, hypomagnesemia is frequently the cause of hypokalaemic patients failing to respond to potassium supplementation. Thus, clinicians should ensure that both magnesium and potassium is replaced when deficient. Patients with diabetic ketoacidosis should have their magnesium levels monitored to ensure that the serum loss of potassium, which is driven intracellularly by insulin administration, is not exacerbated by additional urinary losses.

Calcium
Release of calcium from the sarcoplasmic reticulum is inhibited by magnesium. Thus hypomagnesemia results in an increased intracellular calcium level. This inhibits the release of  parathyroid hormone, which can result in hypoparathyroidism and hypocalcemia. Furthermore, it makes skeletal and muscle receptors less sensitive to parathyroid hormone.

Arrhythmia
Magnesium is needed for the adequate function of the Na+/K+-ATPase pumps in cardiac myocytes, the muscles cells of the heart. A lack of magnesium inhibits reuptake of potassium, causing a decrease in intracellular potassium. This decrease in intracellular potassium results in a tachycardia.

Pre-eclampsia
Magnesium has an indirect antithrombotic effect upon platelets and endothelial function. Magnesium increases prostaglandins, decreases thromboxane, and decreases angiotensin II, microvascular leakage, and vasospasm through its function similar to calcium channel blockers. Convulsions are the result of cerebral vasospasm. The vasodilatatory effect of magnesium seems to be the major mechanism.

Asthma
Magnesium exerts a bronchodilatatory effect, probably by antagonizing calcium-mediated bronchoconstriction.

Neurological effects
reducing electrical excitation
modulating release of acetylcholine
antagonising N-methyl-D-aspartate (NMDA) glutamate receptors, an excitatory neurotransmitter of the central nervous system and thus providing neuroprotection from excitoxicity.

Diabetes mellitus
Magnesium deficiency is frequently observed in people with type 2 diabetes mellitus, with an estimated prevalence ranging between 11.0 and 47.7%.
Magnesium deficiency is strongly associated with high glucose and insulin resistance, which indicate that it is common in poorly controlled diabetes. Patients with type 2 diabetes and a magnesium deficiency have a higher risk of heart failure, atrial fibrillation and microvascular complications. Oral magnesium supplements has been demonstrated to improve insulin sensitivity and lipid profile.  However, their effect on cardiovascular risk in diabetes are to be determined.

Homeostasis
Magnesium is abundant in nature. It can be found in green vegetables, chlorophyll (chloroplasts), cocoa derivatives, nuts, wheat, seafood, and meat. It is absorbed primarily in the duodenum of the small intestine. The rectum and sigmoid colon can absorb magnesium. Forty percent of dietary magnesium is absorbed. Hypomagnesemia stimulates and hypermagnesemia inhibits this absorption.The body contains 21–28 grams of magnesium (0.864–1.152 mol). Of this, 53% is located in bone, 19% in non-muscular tissue, and 1% in extracellular fluid. For this reason, blood levels of magnesium are not an adequate means of establishing the total amount of available magnesium.The majority of serum magnesium is bound to chelators, including proteins and citrate. Roughly 33% is bound to proteins, and 5–10% is not bound. This "free" magnesium is essential in regulating intracellular magnesium. Normal plasma Mg is 1.7–2.3 mg/dL (0.69–0.94 mmol/L).
The kidneys regulate the serum magnesium. About 2400 mg of magnesium passes through the kidneys daily, of which 5% (120 mg) is excreted through urine. The loop of Henle is the major site for magnesium homeostasis, and 60% is reabsorbed.
Magnesium homeostasis comprises three systems: kidney, small intestine, and bone. In the acute phase of magnesium deficiency there is an increase in absorption in the distal small intestine and tubular resorption in the kidneys. When this condition persists, serum magnesium drops and is corrected with magnesium from bone tissue. The level of intracellular magnesium is controlled through the reservoir in bone tissue.

Diagnosis
Magnesium deficiency is not easy to directly measure. Typically the diagnosis is based on finding low blood magnesium levels (hypomagnesemia). Specifically by finding a plasma magnesium concentration of less than 0.6 mmol/L (1.46 mg/dL). Severe disease generally has a level of less than 0.50 mmol/L (1.25 mg/dL).Magnesium deficiency (or depletion) refers to low total body levels of magnesium which is usually determined by finding low blood levels (hypomagnesemia). Hypomagnesemia refers only to blood levels of magnesium. Either of magnesium deficiency and hypomagnesemia can be present without the other.

Electrocardiogram
The electrocardiogram (ECG) change may show a tachycardia with a prolonged QT interval. Other changes may include prolonged PR interval, ST segment depression, flipped T waves, and long QRS duration.

Treatments
Treatment of hypomagnesemia depends on the degree of deficiency and the clinical effects. Replacement by mouth is appropriate for people with mild symptoms, while intravenous replacement is recommended for people with severe effects.Numerous oral magnesium preparations are available. In two trials of magnesium oxide, one of the most common forms in magnesium dietary supplements because of its high magnesium content per weight, was less bioavailable than magnesium citrate, chloride, lactate or aspartate. Magnesium citrate has been reported as more bioavailable than oxide or amino-acid chelate forms.Intravenous magnesium sulfate (MgSO4) can be given in response to heart arrhythmias to correct for hypokalemia, preventing pre-eclampsia, and has been suggested as having a potential use in asthma.

Food
Food sources of magnesium include leafy green vegetables, beans, nuts, and seeds.

Epidemiology
The condition is relatively common among people in hospital.

History
Magnesium deficiency in humans was first described in the medical literature in 1934.

Plants
Magnesium deficiency is a detrimental plant disorder that occurs most often in strongly acidic, light, sandy soils, where magnesium can be easily leached away. Magnesium is an essential macronutrient constituting 0.2-0.4% of plants dry matter and is necessary for normal plant growth. Excess potassium, generally due to fertilizers, further aggravates the stress from magnesium deficiency, as does aluminium toxicity.Magnesium has an important role in photosynthesis because it forms the central atom of chlorophyll. Therefore, without sufficient amounts of magnesium, plants begin to degrade the chlorophyll in the old leaves