vangle: reactive documents with formulas

A modern take on Bret Victor's Tangle. You write HTML with a few custom elements, readers drag the numbers in it, and everything that depends on them updates, KaTeX formulas included. One ES module, no dependencies, no build step.

This project is reactive. In short, that means that a change doesn't redraw the whole page. Each variable remembers which variables it read, and only the ones that read a changed variable run again. Here, count adds one to a counter every time a variable runs. See What recomputes for how it's built.

1 + 2 = , ran .

× 3 = , ran .

This is plenty useful, especially when you combine it with widgets like the maths formula.

\tangle{P} \cdot \left(1 + \frac{\tangle{r}}{100}\right)^{\tangle{t}} = \val[%,.2f]{P * (1 + r / 100) ** t}

You can combine widgets with other widgets. And everything just reacts!

A 2×2 matrix moves every point of the plane, and its two columns say where the arrows î and ĵ end up. See Matrix transformations for how it's built.

\begin{pmatrix} \tangle{a} & \tangle{b} \\ \tangle{c} & \tangle{d} \end{pmatrix} \qquad \det = \val[%.2f]{det} \qquad \text{area} = \val[%.2f]{Math.abs(det)}
î ĵ

The nice thing about these widgets is that agents are also really good at working with them. They click together like HTML legos but can still be made custom with javascripts.

f(x) = \tangle[a]{a}\,x^2 + \tangle[b]{b}\,x + \tangle[c]{c}

With , and the parabola opens and has :

x = \frac{-(\tangle{b}) \pm \sqrt{\val[%.2f]{disc}}}{2 \cdot \tangle{a}} \quad\Rightarrow\quad x_1 = \val[%.2f]{(-b - Math.sqrt(disc)) / (2 * a)}, \; x_2 = \val[%.2f]{(-b + Math.sqrt(disc)) / (2 * a)}
plot script (the JS escape hatch)

There are even some fancy features like scopes!

Alice runs 5 km at 5.5 min/km, which takes minutes.

Bob runs 10 km at 6 min/km, which takes minutes.

There is plenty to learn and play with, so feel free to explore all the demos!