Hi Bria,
Magnesium is one of the minerals found in nuts. There's also phosphorus, potassium, calcium and sodium as well as other nutrients. Nuts store these essential elements in a balanced way. Nuts also contain heart healthy fats.
Man made supplements are an option, but they are not natural and I wouldn't recommend them because you may have a deficiency in more than one mineral.
Some people get tested for blood elecrolytes when they get palpitations only to find that they fall within the norm. This may be the case, but minor changes in electrolytes can cause palpitations. We would never think to have such a test done if we weren't experiencing symptoms, so we don't usually know what our personal electrolyte levels should ideally be.
Nuts! Provided that you're not allergic, of course...
Chris