WIP equation helper

Hi :wave: Just floating a utility I made over the weekend out there. It functions a bit like a drop-in replacement for the tex helper. The motivation is that I recently implemented math plots and found it tedious to write the equations in tex, then write them in JS, then write conversion functions to zip up the data for input into Observable Plot. What I really wanted to do was just write the function once and view it as tex along with a plot.

So I wrote a basic component here: eqn-basic / Ricky Reusser / Observable and connected it to the math library of the Stdlib project and added some documentation here:

I think this opens up quite a few possibilities short of pursuing a full computer algebra solution. For example, it’s relatively easy to implement automatic differentiation so that you could directly compute the derivative of entered equations. You could output to GLSL for much fancier rendering (e.g. complex plots or even just x-y plots evaluated in a shader). You could connect to a generics interface and process arrays. You could implement simplification or other operations on the AST with lots of possibilities there. (It uses the Spidermonkey AST format, so there are probably good utilities for manipulating the AST?) I don’t know. The tex-serialization and plotting interface is a bit rough, but it feels like the parse() interface in particular is pretty straightforward, minimal and powerful.

It’s a bit loose and experimental and I’m stretched a bit thin on time to really explore variations of the API, so any ideas, feature requests, or general feedback are welcome!


That’s really cool.

1 Like

Oh, other main feature is that you can view function docs by clicking on operators (it’s a bit tricky; can’t do hover due to cell/execution UI layering):