(What I can remember from working with Peter-Pike Sloan) Here's some sample maths: \(sin(x^2)\), and \(x_t\) and some more: $$ a^2 + b^2 = c^2 $$ And something more interesting?! Rotation: $$ \begin{align} C_{n+1} & = xC_{n} - yS_{n} \\ S_{n+1} & = xS_{n} + yC_{n} \end{align} $$ $$ \begin{align} C[0] & = 1 \\ S[0] & = 0 \\ C[1] & = X \\ S[1] & = Y \end{align} $$ $$ Y_l^m = \begin{cases} \sqrt{2}Re(Y_l^m), & m > 0 \\ \sqrt{2}Im(Y_l^m), & m < 0 \\ Y_l^0 & m = 0 \end{cases} $$ increment \(l\) in the inner loop, \(m\) in the outer loop.
for (m = 0; m < MAX_ORDER; m++) {
    for (l = m; l < MAX_ORDER; l++) {
        ...
$$ \begin{array}{c|c|c|c|c|c} m = & 0 & 1 & 2 & 3 & \dots \\ \hline P_{mm} = & 1 & -1 & -3 & & \\ C_m = & 1 & x & x^2 - y^2 & & \\ S_m = & 0 & y & 2xy & & \\ \end{array} $$ $$ \begin{align} P_0^0 & = 1 \\ P_1^0 & = (2m + 1)zP_0^0 \\ P_2^0 & = {(2l - 1)zP_1^0 - (l + m -1)P_0^0 \over l - m }\\ \hline \\ P_1^1 & = (1 - 2m)P_0^0 \\ P_2^1 & = (2m + 1)zP_1^1 \\ \hline \\ P_2^2 & = (1 - 2m)P_1^1 \end{align} $$