To find out if you are deficient in magnesium, you can either measure levels of zinc in your red blood cells (erythrocytic magnesium) or if you are not willing or able to get a blood test you can measure your food intake over the course of three days (including one weekend day) or a whole week and try to calculate your dietary magnesium intake; for this
purpose, you can again use Wolfram
Alpha for free (albeit a bit tedious)
calculations.