Skip to content

Math

Math can be written directly in MDX. Use it near the prose and executable cells that depend on the notation so readers do not have to jump between pages.

Inline math uses single dollar signs. In the logistic map, the state is xn∈[0,1]x_n \in [0, 1] and the parameter is r∈[0,4]r \in [0, 4].

Subscripts and superscripts also work together: xn+x2x_n + x^2.

Block math uses double dollar signs:

xn+1=rxn(1−xn)x_{n+1} = r x_n (1 - x_n) xn+x2x_n + x^2 A=[123456789]A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}

A display equation wider than the page scrolls horizontally inside itself, so the rest of the page keeps its width. The equation can be focused with the keyboard and scrolled with the arrow keys.

∑k=0n(nk)xkyn−k=xn+nxn−1y+n(n−1)2xn−2y2+n(n−1)(n−2)6xn−3y3+n(n−1)(n−2)(n−3)24xn−4y4+⋯+yn\sum_{k=0}^{n} \binom{n}{k} x^{k} y^{n-k} = x^{n} + n x^{n-1} y + \frac{n(n-1)}{2} x^{n-2} y^{2} + \frac{n(n-1)(n-2)}{6} x^{n-3} y^{3} + \frac{n(n-1)(n-2)(n-3)}{24} x^{n-4} y^{4} + \cdots + y^{n} f(x)=x2+2x+1=(x+1)2\begin{aligned} f(x) &= x^2 + 2x + 1 \\ &= (x + 1)^2 \end{aligned}

Use an executable cell when readers should verify or vary a formula.

Python + Pyodide

Calculate a quadratic with Python

Cell actions
Cell inputs
y = x**2 + 2*x + 1
print(f"f({x}) = {y}")

Run the cell to show its output.