Reference

Everything in the library

Numbers can be JS numbers (read by their shortest spelling, so 0.1 is 110\tfrac{1}{10}), bigints, strings such as "3/4" or "1.25", or Core Rationals. Functions marked R return a Refinement: .quick.value is the float sketch; .exact() or await .settle() give the certified result.

Viewports and Refinements

NameWhat it does
viewport({ x: [a, b], y: [c, d], width, height })Exact rational world rectangle over a pixel grid; dx, dy are exact.
Refinement, live(compute, onStage, { idleMs, sliceMs, onProgress })The fast-then-exact protocol shared with linalg and analytic; live wires it to input.
precisionFor(vp), columnRationals(vp, i)Working precision for a viewport; the exact x-interval of a pixel column.

Expressions

NameWhat it does
parse(text)Calculator notation to a plain AST (num var const op call).
num, v, op, callAST builders, for a calculator that has its own parser.
compileFloat, compileInterval, compileExactDoubles; certified interval enclosures; exact rationals for rational-only expressions.
freeVariables(ast), isRationalOnly(ast), toRational(x)Helpers.
derive(ast), format(ast)Symbolic derivative and printing, from @ratmath/analytic.

Graphs and features

NameExact value
graph(f, params, vp) Rquick: polyline; exact: cells frame { columns, tight, asymptotes, holes }
zeros(f, params, [a, b]) Rexact rationals, sign-change brackets, or possible
features(f, params, [a, b]) R{ zeros, poles, holes, undefined, endpoints, extrema, inflections }. poles are proven; undefined lists points with no value and no proven pole (sin(1/x) at 0)
parametric({ x, y }, params, [t0, t1], vp) R, polar(r, params, [t0, t1], vp) Rquick: polyline; exact: cells frame in which every point of the curve lies in a lit pixel
intersections(f, g, params, [a, b]) R, findIntersectionsThe zeros of f − g with the common value: { kind, at | lo, hi, value | valueLo, valueHi }
scatter(data, { join }), bars(data, { width, baseline }), histogram(values, { bins, range, density })Data frames in world coordinates
slopeField(f, params, vp, { spacing, length }), solutionCurve(spec, vp) RThe field of y′ = f(x, y), and one solution: an RK4 sketch, then cells that provably hold it
describe(f, params, [a, b], { digits, max }), describeFeaturesSentences built from the certified features, for alt text
logScale(f, { x, y })f rewritten for logarithmic axes (use with axes: { xScale: "log" })
findPoles, findHoles, findExtrema, findInflections, findEndpoints, findZerosThe same pieces, synchronously
sampleFloat, certifyGraph, floatZeros, floatFeatures, simplestBetweenLower-level stages

Implicit curves and regions

NameExact value
implicit(equation, params, vp) Rquick: marching-squares segments; exact: cells frame with sure (proven pixels)
region(condition, params, vp, { method }) Rquick: region sketch; exact: polygons frame when bounded by lines, conics frame (exact arcs, corners in closed form) when bounded by conics, else region frame { inside, boundary } of certified pixels
conicAtoms(tree, params), exactConicRegion(tree, atoms, vp), conicType(poly)The conic method's pieces: comparisons as polynomials of degree ≤ 2, the decomposition, a curve's name
parseCondition(text), atoms(tree), dnf(tree), negationFree(tree)Conditions as trees of comparisons F rel 0
linearForm(expr, params){ a, b, c } with expr = a·x + b·y + c, or null
linearPieces, exactLinearRegion, classify, sketchRegion, sketchImplicitLower-level stages

Calculus pictures

NameWhat it gives
tangent(f, x0, params), secant(f, a, b, params)Slope, point, line, equation and layers; exact or certified
areaUnder(f, [a, b], params, vp), areaBetween(f, g, [a, b], params, vp) RAn area frame with integral: a float, then exact or a certified interval; improper ends allowed
riemannSum(f, [a, b], n, params, { rule })Rectangles or trapezoids as a frame, with the sum
taylorPolynomial(f, c, n, params)Coefficients and an expression to graph
vectorField([P, Q], params, vp), gradientField(F, params, vp)An arrows frame
gradientAt(F, [x, y], params)The certified gradient, an arrow and the level line
contours(F, levels, params, vp)One implicit curve (R) per level
featureLabels(features), withAlgebraicForms, radicalTeX, rationalFormLabels in closed form (2\sqrt2 rather than 1.414…) for zeros, extrema, inflections and intersections; the pieces behind them

Three dimensions

NameWhat it does
surface(f, params, { x, y, grid }) Rz = f(x, y): a float grid, then certified heights with error
parametricSurface([x, y, z], params, { u, v, grid }) R, spaceCurve([x, y, z], params, { t, samples }) RThe same for parametric surfaces and curves
points3d, segment3d, arrow3d, tangentPlane(f, [x0, y0])Marks, and the tangent plane with its normal
camera({ azimuth, elevation, distance, zoom }), orbit(cam, dx, dy), spaceViewport(w, h)The view, a drag, and a viewport that fits the scene
project3d(cam, items, { box, axes, light })One mesh frame for drawScene and every exporter

Animation

NameWhat it does
animate(draw, { from, to, steps, duration, loop, bounce, onSettle })Plays a parameter through exact values; returns play, pause, toggle, seek, stop
parameterSteps(from, to, n)The n + 1 exact values
animationSVG(vp, frames, options), animationPNG(vp, frames, options)Frames as one animated SVG (a string) or animated PNG (bytes, a Promise)

Exact numbers and geometry

NameWhat it does
surd(a), surd(a, b, d), sqrt(q), Surda+bda + b\sqrt{d}: add, subtract, multiply, divide, sign, compareTo, bounds(bits), toNumber, toTeX
point, line, segment, ray, polygon, circleImmutable objects with toString() and toTeX()
intersect(A, B)Exact intersection list for any pair
midpoint, project, reflect, parallel, perpendicular, bisector, circumcircleConstructions
dist2, distance, area (simple polygons only), isSimple, signedArea, centroid, orientation, locate, convexHullMeasurements and predicates, exact

Drawing

NameWhat it does
drawScene(ctx2d, vp, layers, { axes, scale, background, colors })Draw layers on a canvas; returns the primitives
sceneSVG(vp, layers, { axes, background, tex })A standalone SVG string
sceneTikZ(vp, layers, { axes, width, height, standalone, background, pt })A LaTeX tikzpicture in world coordinates, labels as real TeX (Exporting)
scenePGFPlots(vp, layers, { axes, width, height, standalone, axisOptions })A PGFPlots axis: its own axes and ticks, curves as \addplot
scenePNG(vp, layers, { axes, scale, background, engine })PNG bytes (a Promise): canvas in browsers, built-in renderer elsewhere
scenePDF(vp, layers, { axes, background, pt })A one-page vector PDF (bytes)
sceneASCII(vp, layers, { axes, cols, rows, mode, border, color })The scene as text: ASCII, Braille or block characters
label(at, tex, { anchor, color, size })A TeX label at a world point
mountLabels(container, vp, prims, { katex })Typeset labels in an HTML layer over a canvas
primitives, axesPrimitives, paint, svgElements, texToText, niceStep, PALETTEThe pieces under drawScene and sceneSVG
tikzElements, tikzAxes, simplifyPolyline, asciiElements, asciiText, rasterize, encodePNG, pdfContent, pdfTextRunsThe pieces under the exporters
drawCanvas, drawAsymptotes, toSVG, drawMarkers, markerList, shadeSingle-frame drawing for graphs, and feature markers

Pictures for the Shelf

Figures

NameWhat it does
figure({ layers, x, y, axes, equal, status, title, notes })A picture with its window and a status: exact, certified, estimated or simulated (Figures)
figureSVG, figurePNG, figurePDF, figureTikZ, figureASCII (fig, { width, height })Draw a figure; figureViewport and figureSize give the viewport and the size hint
framesSVG, framesPNG (frames, { duration, loop })Frames ({ kind: "frames", frames }) as one animated file
shapes, path, dot, arrow, textA frame of styled shapes in world coordinates
image({ x, y, width, height, cells })A grid of coloured cells, row 0 at the bottom
toNumber, extentOf, rampColor, divergingColor, CATEGORYHelpers: numbers and text such as "1/5" as doubles, extents, colour scales
polygonsFigure(polygons, { colorBy })Filled polygons coloured by sides or key
solidFigure(vertices, faces, { cam, colors })A lit polyhedron in a proportional box
stepsFigures(steps)A construction step by step, the newest step highlighted

Charts for statistics and finance

NameWhat it does
fiveNumbers(values), boxPlot(groups)Tukey's hinges, whiskers to 1.5 IQR, outliers (Charts for statistics)
histogramFigure(values, { bins, distribution })Counts, or density bars with a curve
densityFigure(dist, { range, shade })A density with P(a ≤ X ≤ b) shaded and stated
qqPlot(values, dist), scatterFit(points, { fit, band })Quantile plot with its quartile line; data with a line and a band
lineChart(series), powerCurve(curves, { level }), legendLines with a legend; power against effect
samplingBuildUp(values, { bins, steps })Frames of a sampling distribution building up (simulated)
amortisationChart(loan), balanceChart(loan)Interest and principal per period; the balance (Charts for finance)
fanChart(simulation)Percentile bands over time (simulated)
yieldCurveFigure(curve), payoffFigure(strategy, { range })Spot rates by maturity; payoff and profit, exact through the kinks

Graph drawing and logic diagrams

NameWhat it does
graphData(g)A Graph, automaton, Kripke model or { vertices, edges } as plain data
circleLayout, gridLayout, bipartiteLayout, layeredLayout, treeLayout, springLayoutPositions as a Map (Drawing graphs)
tutteLayout(g, { outer, faces })Exact barycentric drawing with an exact crossing check
countCrossings(g, positions)Crossing pairs of any drawing, in floats
drawGraph(g, { layout, colours, highlight, edgeLabels })A graph as a figure
automatonFigure(a), kripkeFigure(k)Automata and Kripke models
proofTreeFigure(d), truthTreeFigure(t), treeLayoutOf(root, { width, children })Gentzen trees and truth trees (Logic diagrams)
vennFigure(sets, { shade, marks })Venn diagrams of up to three sets

Dynamics and analysis

NameWhat it does
cobwebFigure(f, x0, n), orbitFigure, returnMapFigureIteration pictures (Pictures of dynamics)
bifurcationFigure(diagram, { marks })Long-run values against a parameter
escapeFigure(grid)Inside, outside and undecided pixels kept apart (certified)
pointCloudFigure, attractor3d, segmentsFigure, spacetimeFigure, lifeFigure, parameterFramesAttractors, L-systems, automata, animation in a parameter
phasePortrait([f, g], { x, y, orbits })Arrows, nullclines, orbits, proved equilibria (Phase portraits and curvature)
solutionFrames(u, times), zeroContour(F, x, y)Solutions in time; marching squares
frameAlongCurve(r, t), frameFrames(r, ts)Tangent, normal and osculating circle, certified
curvatureSurface(xyz, { u, v, which }), curveOnSurface, equalBoxSurfaces coloured by Gaussian or mean curvature
newtonFigure, interpolationFigure, quadratureFigureTangents, interpolants and Runge, quadrature pieces (Pictures of numerical methods)
stabilityRegion(R), convergenceFigure(rows)Where |R(z)| ≤ 1; observed order on log axes
Try itEdit the code and run it with @ratmath/graphics and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math, and SHOW(svg) draws a picture.
Ctrl/⌘ + Enter runs