I'm guessing the Magnesium they want you to use is a citrate or chelate? I've done a lot of research on magnesium and I swear by it. I personally have not found absorption issues with the easy to find magnesium oxide. As long as you don't take it with calcium or something with lots of calcium. I have TMJ and the magnesium really decreases my pain among many other things.
I will tell you my experience with brain fog. I lived with it my entire life. At age 30 I went to a doctor that treated for hypo thyroid based of symptoms rather than just the TSH. (Brain fog is a symptom of Thyroid problems so if you haven't had your TSH, T4 and T3 tested I would recommend it). My TSH was at the high end of normal. The brain fog disappeared within 2 weeks.
Fast forward to 9 months later. My TSH was 0.022, way too low. The dr was fine with this and I was having some memory issues. We have also been trying to conceive for several months without luck. So I decided to stop the thyroid meds. 6 weeks later the OB-Gyn tested and my TSH was 5.4. She sent me to an Endo. I went 6 weeks later and found my TSH to be 1.65 . Perfectly normal.
I have not had a return of the brain fog and I stopped taking the thyroid meds at the end of August. Still haven't had luck conceiving. There were two things I did since that first testing of my thyroid. I started taking a iodine supplement (iodoral) and I had my metal fillings replaced with the ceramic ones. Not sure what got me out of the fog and I really was expecting to fall back into it. I hope you can find your way out too.