Explain. Explore. Experience.

Mathterpiece

A language for math you can touch.

  1. Declare what the figure is, does, and looks like.
  2. The compiler typechecks every possible state.
  3. The runtime makes it accessible and interactive.

Your next paper, talk or course

Drop a Mathterpiece figure into any web-based paper, slide deck, set of notes or page.

A figure in a web-based paper that readers can explore, next to the claim that it shows.

Readers drag u or v, or point at a side of the inequality, and check the claim for themselves.

Every one of these pages holds its figure the same way: load the runtime, load the compiled figure, and place a view of it.

<script type="module" src="mathterpiece.js"></script>
<mtp-model id="cs" src="schwarz.mtpc"></mtp-model>
<mtp-canvas model="cs" name="c"></mtp-canvas>

Accessible, interactive, portable by default

Every Mathterpiece figure gets these from the runtime, with no extra code.

  • KeyboardSliders, buttons and players work from the keyboard, and Tab reaches every control.
  • Screen readersEach control and each canvas carries a label written in the source.
  • TouchEvery drag also works by tapping, so a figure works on a phone as well as with a mouse.
  • Light and darkEach color has a light and a dark value, and the figure follows the reader’s setting.
  • Reduced motionAnimations follow the reader’s setting for reduced motion, with no extra code in the figure.
  • Any page or frameworkFigures draw as SVG in standard web components, so they work in HTML, React, Vue or Svelte.

Typesafe figures

Mathterpiece figures never break in the reader’s browser: the compiler rejects any figure that could draw something undefined.

  1. 1Write the figure
    (real k -1 (>= -1) (<= 1))(real r (sqrt (- k)))(scene parabola  (line_ (from [-2 0]) (to [2 0]) (stroke 'gray'))  (parametric p (for t -2 2) [t (+ (* t t) k)] (stroke 'teal'))  (circle lo (r 0.1) (pos [(- r) 0]) (fill 'crimson'))  (circle hi (r 0.1) (pos [r 0]) (fill 'crimson')))(canvas c parabola)(slider shift (move k (from -1) (to 1)) (label 'k'))(readout says $'roots at ±{r:.2f}')
  2. 2The compiler rejects it

The error says what to change, so a person or a coding agent can fix the figure.

  1. 3Say what happens when there are no roots
    (real k -1 (>= -1) (<= 1))(real|none r (sqrt (- k)))(scene parabola  (line_ (from [-2 0]) (to [2 0]) (stroke 'gray'))  (parametric p (for t -2 2) [t (+ (* t t) k)] (stroke 'teal'))  (circle|none lo (r 0.1) (pos [(- r) 0]) (fill 'crimson'))  (circle|none hi (r 0.1) (pos [r 0]) (fill 'crimson')))(canvas c parabola)(slider shift (move k (from -1) (to 1)) (label 'k'))(readout says (or? $'roots at ±{r:.2f}' 'no real roots'))
  2. 4Every value of k draws

    Move k above 0. The roots disappear, and nothing breaks.

Make your first Mathterpiece

Install mtp, declare a figure in a few lines, and put it on any page.