Skip to content

Latest commit

 

History

History
108 lines (75 loc) · 3.92 KB

File metadata and controls

108 lines (75 loc) · 3.92 KB

Plotting with Etchl

math.plot draws a curve from an equation. Use a standalone plot for curves in drawing coordinates, or put plots inside math.plane when several series share axes and data coordinates.

The language tour introduces both forms. This page concentrates on the sampler's reach and limits.

A shared vocabulary

Every plot uses the same bounded expression language: eighteen functions, pi, tau, e, arithmetic, and one independent variable. That is enough for classical curves, damped waves, implicit contours, and finite series.

Six classical curves drawn by the same constructor

For example, a superformula needs no special constructor:

use "etchl/math" as math

diagram "Superformula" {
  shape: math.plot {
    at = (200, 200)
    x = 110 * ((abs(cos(3*t/4))) ^ 8 + (abs(sin(3*t/4))) ^ 8) ^ -0.125 * cos(t)
    y = 110 * ((abs(cos(3*t/4))) ^ 8 + (abs(sin(3*t/4))) ^ 8) ^ -0.125 * sin(t)
    t in [0, tau]
    stroke = "#16a34a"
  }
}

The full gallery is in examples/curve-gallery.etchl.

What tolerance means

tolerance is the greatest permitted distance, in pixels, between a curve and the line Etchl draws. The sampler proves a bound for each span with interval arithmetic. If it cannot prove the requested tolerance within the point budget, compilation fails instead of returning an unchecked approximation.

A curve rendered at three tolerances

The property tests compare drawn segments with their source equations and exercise high-frequency curves, poles, discontinuities, and budget boundaries.

Finite fractal series

A finite Weierstrass series is an ordinary function of one variable, so it fits the plotting model even as higher terms add finer oscillations.

A Weierstrass curve at three truncation depths

The same applies to other finite series:

Blancmange, Riemann, and two lacunary loops

Iterated systems such as Koch, Sierpinski, Mandelbrot, and Julia constructions do not fit math.plot. They require iteration or complex state, neither of which belongs to the expression language. They should be expressed through a purpose-built abstraction, not hidden inside general expressions.

Dependency limits

Interval arithmetic treats repeated occurrences of a variable independently. Equivalent expressions can therefore differ in how tightly they can be bounded:

abs(u - round(u))
abs(asin(sin(pi * u))) / pi

Both compute distance to the nearest integer. The second form bounds tightly; the first may be rejected because the sampler cannot prove that the two uses of u move together. Rewriting an equation can help when increasing tolerance would lose too much detail.

Hard limits

A plot is rejected when it exceeds any of these safeguards:

  • 5,000 drawn points;
  • 512 expression terms or 64 nested expression levels;
  • the freehand coordinate-magnitude limit;
  • a finite interval proof, including poles and unbounded values.

A coarser tolerance is usually the right response to the point limit. Larger or structurally different computations belong in a dedicated constructor.

Curves remain diagram elements

A plot can be styled, connected, measured with along(...), or mixed with ordinary nodes.

Four connected stages with their signals drawn beneath

See examples/plot-flow.etchl for the complete source. The normative grammar and limits are in the language specification.

References