Magnesium deficiency seems to cause rapid heart rate since magnesium is involved in muscular relaxation. Magnesium deficiency prevents the heart muscles from going through a complete relaxation phase so the heart rate accelerates. Potassium depletion not only causes irregular heart rate, but it seems to cause water to enter the cells and stay there, causing the body to swell up with edema. If you are swelling up, then you are probably potassium deficient, so take more potassium than magnesium. If you are losing weight, then probably magnesium is more deficient than potassium, so take more magnesium than potassium.
Zinc depletes potassium and cadmium depletes magnesium.
Copper assists magnesium metabolism and potassium seems essential to enable copper to get into the cells. The interactions are probably more complex than described, but the important message is that a deficiency of one mineral has wide-ranging repercussions on the balances of other minerals. The key deficiencies are copper and its large collection of assisting nutrients, magnesium, and potassium. Potassium is the strangest to replenish because all the supplements available are limited to 99 mgs. Our daily requirement is about 3000 mgs, so taking one or two tablets doesn't do much.