Expressions
Writing maths a graph can plot, and the parameters a reader can move.
#Writing an expression
Wherever a graph wants a function, it takes a math expression in x: curve(expression: x^2 - 2x + 1), sin(a * x), 100 - 4.9x^2. Powers use ^, the usual functions are available by name, and multiplication may be implicit — 4.9x^2, 2(x + 1) and (m - px) / q with multi-letter parameter runs all parse.
x is the only free variable, with one exception: the surface marks contour and heatmap plot a function of the plane, so y is legal alongside it there and nowhere else.#Parameters
A parameter declares a single-letter variable and hands the reader a slider for it. Every expression in the pane that mentions that letter re-evaluates as it moves, which is what makes a curve something to play with rather than something to look at.
canvas.graph{
parameter#m(var: m; range: [0, 5]; default: 2)
curve#f(expression: m * x)
point(x: 1; y: m; label: $m$)
}#Where expressions are accepted
Any attribute whose type carries parametised- takes an expression where a plain value would otherwise stand — a point's coordinates may be (a, 2a), a curve's domain [0, b], an integral's bound from: m - s. The attribute types page lists each of them and what it accepts; every reference page names the type of each of its attributes.