Topic

Implicit curves

Curves given by an equation F(x,y)=0F(x, y) = 0 rather than as y=f(x)y = f(x): circles, ellipses, cubics, lemniscates, the folium of Descartes.

How it is certified

The viewport is split into boxes of pixels. For each box, the exact xx- and yy-intervals go through interval arithmetic. If the enclosure of FF over the box excludes 0, the curve misses the whole box and it is dropped. Otherwise the box is split, down to single pixels and then a few levels below. A pixel that survives may contain part of the curve; a pixel that does not survive certainly contains none.

Some pixels are better than possible. If FF is defined and continuous on a pixel (no square root of a negative, no division by an interval containing 0) and has opposite proven signs at two of its corners, then by the intermediate value theorem the curve passes through that pixel. Those are listed in sure and drawn darker above. Where the curve crosses itself or touches without crossing, as at the node of y2=x3−2x+1y^2 = x^3 - 2x + 1 when the parameter makes one, pixels stay possible: no sign change proves them.

const vp = viewport({ x: [-4, 4], y: [-3, 3], width: 400, height: 300 });
const c = implicit("x^2/4 + y^2 = 1", {}, vp);
c.quick.value;           // marching-squares segments, immediate
const cells = c.exact(); // { kind: "cells", columns, sure }
cells.sure.count;        // pixels proven to hold part of the curve

The equation can be written with anything on either side (y^2 = x^3 - x), or as a bare expression meaning = 0. The quick sketch uses marching squares on a grid every 2 pixels, so it can miss small loops and join branches that cross; the certified frame cannot miss anything.

Parameters

Names other than x and y are parameters, given as exact rationals. The demo wires them to sliders with live, exactly as for graphs.

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