I read Thinking, Fast and Slow last year and it touched on several things you seem to be experiencing. The author is Nobel Prize winning psychologist, and the book is thorough in its citing of studies and empirical data.
Fundamentally it came down to the fact that your brain only has so much energy. Pain tolerance draws from the same pool as self discipline and complex (slow) thought. And by "same pool" the evidence suggests it's not some nebulous concept but rather directly linked to sugars and components that make up neuro transmitters. Quoting directly from the text:
The evidence is persuasive: activities that impose high demands on
System 2 require self-control, and the exertion of self-control is
depleting and unpleasant. Unlike cognitive load, ego depletion is at
least in part a loss of motivation. After exerting self-control in one
task, you do not feel like making an effort in another, although you
could do it if you really had to. In several experiments, people were
able to resist the effects of ego depletion when given a strong
incentive to do so. In contrast, increasing effort is not an option
when you must keep six digits in short-term memory while performing a
task. Ego depletion is not the same mental state as cognitive
The most surprising discovery made by Baumeister’s group shows, as he
puts it, that the idea of mental energy is more than a mere metaphor.
The nervous system consumes more glucose than most other parts of the
body, and effortful mental activity appears to be especially expensive
in the currency of glucose. When you are actively involved in
difficult cognitive reasoning or engaged in a task that requires
self-control, your blood glucose level drops. The effect is analogous
to a runner who draws down glucose stored in her muscles during a
sprint. The bold implication of this idea is that the effects of ego
depletion could be undone by ingesting glucose, and Baumeister and his
colleagues have confirmed this hypothesis n ohypothesiin several
Several studies showed that physical exertion lead to lower math scores (when the tests quickly followed the exertion), and likewise difficult cognitive challenges resulted in lower pain tolerance and physical capacity.
There's a lot of research to show that exercise increases cognitive function, but those studies tend to be macro-scale, looking at longer term results. In the short term, I think any athlete can attest to the fact that during physical exertion you simply cannot think as much. Personally I actually find it difficult to do the math on barbell plates when I'm lifting heavy, and frequently have to write down simple addition problems that wouldn't be an issue at all during non-strenuous times.