Look it up yourself but I've heard of countless people taking both. A close friend is one.
Honestly I can't imagine that you would not use magnesium as part of your support combo against the anxiety and racing pulse!
Mg tends to be lacking in our diet.
With your symptom I'd start on Mg even before testing cortisol. If low Mg or poor retention of it are involved, it would likely contribute to poor stress tolerance. This might be one of the factors causing low cortisol in a person who can't keep up production of it. Maybe your body then tries to make extra adrenaline to try to kick start production of additional cortisol.
Continue to read and learn. You'll read about these issues.
I'm not discouraging testing of cortisol or providing adrenal support, however you want to also address sources of stress or reasons for anxiety. Maybe low GABA is involved.
I don't want to oversimplify but also don't want to discourage you either. The good news that there is much for you to consider. You are not in a hopeless situation.