Switch `xrange` => `range` for ultimate python3 compatibility.

Also: some fixes to the docs, to render those equations nicely.