Math and Code in a Blog

Writing a blog about math and programming requires some special considerations with regards to formatting to look and read correctly.  I'm going to use this post to describe how I plan to achieve this, and use it as a way to test that things look right.

Since I'd like to write proper math throughout my blog, I will need the ability to write inline math expressions.  We can accommodate this using MathJax.  We import their hosted script into the Ghost header which should allow me to write $$\Delta s \geq 0$$ inline.

Sometimes I will want to emphasize an equation.  In such cases, I will want to display the expression in a larger font on it's own line.  Luckily, MathJax provides this for us using standard LaTeX syntax:
$G = \sum_{t=0}^T \gamma^t r_t$

Cool, so what about syntax highlighting?  Apparently, this theme also offers syntax highlighting, but it looks like this is also offered by Ghost itself:

import numpy as np

T = 10
r = np.random.rand(T)
gamma = 0.99

G = 0
for t in range(T):
G += r[t] * gamma**t

In any case, it looks like we can describe our math both symbolically and in code, so we should be able to talk about whatever it is we need to.

One last thing: writing static code is cool and all, but what about embedding some "runnable" code?  Google Colab is quickly becoming an essential tool for online code collaboration, and I'm all in on it.  It's gotten a lot better since it was first released, and sharing it is becoming exceedingly easy:

And that's about it.  We can describe some math, write some code, and even embed some examples for users to try out.