Your paper (the first one is as far as I got) is much better, since it just states a simple equation which is typeset separately ("in display mode", in LaTeX-speak) with the derivation for the equation in a sidebar and a note inline in the text pointing it out.

This reads like a normal human speaking, who was asked a question and elaborated. That's fine.

The problem with the OP's article was that I couldn't skim read it, because the code didn't make obvious sense in a "reading aloud" kind of way. It would have worked much better if the footnote had replaced, or been included as padding around the code. The skim readers would still have been happy, especially if there was a carefully placed paragraph break so they could "skip over the details," and I/we would have been happy too.

Also, two code snippets out of context are anything but real code, at least in my brain :)