A rat study has found that increased levels of magnesium in the brain improved many aspects of learning and memory in both young and old rats. Because it is difficult to boost brain magnesium levels with traditional oral supplements, the researchers developed a new magnesium compound, magnesium-L-threonate (MgT). The cognitive improvements were associated with an increase in synapses and improved synaptic plasticity. It’s important to note that the control rats had a normal diet which is widely accepted to contain a sufficient amount of magnesium; thus the observed effects were due to elevation of magnesium to levels higher than provided by a normal diet. It is also estimated that half the population of industrialized countries has a magnesium deficit, which increases with aging. See here for a list of magnesium-rich foods.
(2010). Enhancement of Learning and Memory by Elevating Brain Magnesium.
Neuron. 65(2), 165 - 177.