Home›Journal›This post

Domain Coloring: Paint Complex Functions on Canvas

Map complex phase and magnitude to a deterministic Canvas edition, expose zeros, poles, cuts, probes, and winding, then export its full visual contract.

JP
JP Casabianca
AI Engineer and Product Designer · full-stack delivery · Bogotá

A complex function maps a two-dimensional input to a two-dimensional output, so its ordinary graph wants four dimensions. Domain coloring keeps the input plane visible and assigns the output's phase and magnitude to color, producing images that are both analytical clues and art-directed fields. The color map, sampling grid, branches, and non-finite policy all belong in the edition receipt.

Why a complex graph needs another visual channel

A real graph maps one horizontal input to one vertical output. A complex function takes a two-dimensional input z = x + iy and returns a two-dimensional output f(z) = u + iv, so a literal graph wants four dimensions. Domain coloring keeps the input plane in place and assigns output phase and magnitude to visible channels instead.

The resulting complex function visualization is both analytical clue and art-directed field. Each Canvas pixel names an input coordinate. Its hue comes from the argument of f(z), while lightness and contour cadence come from magnitude. The image can suggest zeros, poles, winding, and discontinuities, but it is not proof that they exist.

Wegert's phase-plots paper explains the central mapping from f/|f| to color on the function's domain. The implementation contract still belongs to the author: choose a function from a safe catalog, bounds, sampling centers, branch convention, cyclic palette, magnitude transfer, non-finite policy, and edition receipt.

This article owns direct argument coloring. Mandelbrot orbit traps color iterative escape behavior instead, while domain coloring evaluates the selected complex function at each declared input point.

Domain-to-color pipelineAn input grid passes through a complex function then splits into argument and magnitude channels.THE COLOR MAP IS PART OF THE MODELz = x + iyf(z)atan2log |f(z)|
Phase and magnitude are separate declared mappings before they recombine as one pixel.
Domain sample
Pixel center maps to z = x + iy.
Function
A fixed catalog function returns f(z).
Argument channel
atan2(Im f, Re f) maps cyclically to hue and named sectors.
Magnitude channel
log |f(z)| maps to bounded lightness bands and contours.
Exceptional states
Zero, pole, cut, and non-finite values use explicit labels and patterns.

Map argument to a cyclic hue wheel

For a finite nonzero output w = u + iv, phase is atan2(v, u) in the interval from −π through π. Normalize that angle to a unit turn with (phase + π)/(2π), then wrap one back to zero. The palette must meet at the seam because −π and π describe the same direction.

Argument coloring also needs orientation. With y increasing upward in mathematics but Canvas rows increasing downward, pixel mapping must invert the row axis. Swapping the arguments to atan2 or forgetting that inversion mirrors the phase field and flips a winding diagnostic. The lab publishes both formulas and tests numeric probes rather than trusting an attractive gradient.

Hue alone is inaccessible and insufficient. Figures mark phase directions with arrows, formulas, and named sectors; the lab prints real and imaginary values plus phase in radians for every probe. A grayscale or forced-colors reader still receives the mapping through the semantic table.

The seam is declared along the negative real output direction for the chosen palette. A mutation that inserts another seam away from that boundary must fail. Cyclic continuity means the colors at angles just below π and just above −π approach each other, even though their normalized numbers sit at opposite ends of a unit interval. In domain coloring, that continuity is a correctness condition rather than a decorative gradient preference.

Map magnitude without losing zeros and poles

Magnitude |f(z)| supplies a second visual channel. A direct linear scale collapses either small or large structure, so the lab uses a named log-periodic transfer. It records log2 of magnitude, splits the value into integer bands and a fractional contour, then combines a bounded lightness base with a contour pulse.

Zero, pole, cut, and non-finite states bypass ordinary coloring. An exact zero receives a black marked pixel and a zero classification. A denominator at zero receives a white marked pole. Non-finite arithmetic becomes a warning pattern rather than a normal hue. Principal-log inputs on the declared negative-real-axis cut receive their own hatch state. Those policies stop visual polish from laundering undefined values.

Finite caps protect the whole numerical path. Coordinates are limited to −20 through 20, parameter magnitudes to 20, resolution to 512 by 512, and supersampling to 2. Before allocating the raster or evaluating the function, the lab adds width × height × supersampling², four fixed probes, and windingSamples + 1 into one budget capped at 1,048,576 evaluations. Classification reuses the first supersample instead of evaluating each pixel center again. A rejected configuration never produces a partial “successful” edition.

Magnitude must be computed from f(z), not from z. The two coincide for the identity function, so domain coloring tests also use translated zeros, poles, and a rational fixture. Canvas dithering can reduce a finished palette later; it must not replace the mathematical magnitude transfer. The resulting complex plane art remains tied to the output of the declared function.

Read identity, zeros, poles, and winding

For f(z)=z, the probe at 1+i returns 1+i, magnitude √2, and phase π/4. A circle centered on the origin accumulates approximately one positive turn. For f(z)=z², the same contour accumulates approximately two turns. For f(z)=1/z, it accumulates approximately one negative turn.

Farris's domain-coloring and argument-principle essay connects color winding with zeros and poles. The lab calls its result a diagnostic, not a proof. Sampling density, contour radius, branch choices, and a singularity touching the contour can invalidate the estimate.

The winding algorithm first compares catalog-known pole coordinates with the declared circle. A reciprocal pole at a or rational pole at b exactly on the radius is labeled known-pole-on-contour by geometry, even when its angle lies between discrete samples, and no ordinary estimate is reported. Only after that gate does the lab sample the bounded circle, compute output phase with atan2, unwrap each adjacent delta into (−π, π], and divide the accumulated change by 2π. It also rejects a non-finite sampled point. Changing the sign of those deltas must flip the result and fail the independent oracle.

A translated zero f(z)=z−a moves the black center to a. A translated pole 1/(z−a) moves the white center to the same parameter and reverses winding. Numeric probe rows keep those facts readable without relying on the colored raster. Circle inversion art offers a geometric transformation study; this phase plot instead visualizes a complex map evaluated on its input plane.

Zero pole and branch-cut triptychIdentity reciprocal and principal logarithm share one domain and mapping.SAME DOMAIN · THREE DIFFERENT STRUCTURESz · winding +11/z · winding −1Log z · declared cutblack dot = zero · white dot = pole · dashed ray = branch cutnumeric labels carry the meaning beyond color and position
Zeros poles and a declared principal-log cut remain named beyond their colors.
Numeric probe expectations
FunctionInputOutputPhaseStateDiagnostic
z1+i1+iπ/4finitewinding ≈ +1
1/z1+i0.5−0.5i−π/4finitewinding ≈ −1
principal log−1+0i0+iππ/2 in outputcutcut is declared
Reading rule
Read each row across its named columns; the text carries the diagram's exact values.
  • Color and position reinforce the comparison but never replace its labels.

Declare branches before drawing logarithms

The complex logarithm cannot be single-valued everywhere away from zero without choosing a branch. The lab selects the principal logarithm: log|z| + i Arg(z), with Arg in (−π, π]. Its cut lies on the nonpositive real axis, and the origin is a singularity.

Pixels immediately above and below that axis can have similar magnitude but imaginary outputs near +π and −π. The discontinuity is not a palette bug. It is the chosen branch convention, so the renderer classifies and labels the cut instead of smoothing it away.

The negative real probe is tested explicitly. Hiding the cut behind a normal pixel fails even if the surrounding image looks more continuous. The receipt names principal-log-v1 and the cut policy so an edition can be interpreted after a palette refactor.

Branch structure also limits winding interpretation. A contour crossing a declared cut is not treated like an ordinary analytic loop. The lab reports warnings and sample states; it never infers a theorem from the picture. Domain coloring can make a branch choice memorable, but only the function definition makes it meaningful.

Render deterministic domain coloring pixels

Determinism begins at pixel centers. For column c of width W, x = xmin + (c + 0.5)(xmax−xmin)/W. For row r of height H, y = ymax − (r + 0.5)(ymax−ymin)/H. The half-step prevents the image from changing when a renderer happens to sample a cell edge.

Aspect ratio must match the declared domain. A rectangular coordinate window rendered into a square bitmap stretches geometry; the validator checks the domain ratio against W/H. Supersampling evaluates a fixed grid inside each output pixel and averages display channels while preserving explicit exceptional-state precedence.

The WHATWG Canvas specification defines the bitmap and export surface and requires equivalent fallback content. The lab keeps a visible function summary, mapping definition, warnings, probe table, and winding result outside Canvas. The bitmap is never the sole explanation.

Export includes a PNG and canonical JSON with function parameters, domain, resolution, sampling rule, palette, transfer version, contour settings, probes, winding estimate, non-finite count, function/domain hash, and pixel hash. The hash covers the actual RGBA buffer, so repeated domain coloring editions can be compared exactly.

Art-direction contact sheetOne rational function keeps its numeric contract while palette and contour cadence change.CHANGE THE EDITION · KEEP THE FUNCTION RECEIPTpalette A · 4 bandspalette B · 4 bandspalette A · 8 bandssoft transferhigh-contrast transfersame function, domain, and probesnew palette or transfer → new pixel hash
A contact sheet changes one authored visual control while mathematical inputs remain frozen.
Edition matrix
PanelFunction/domainPaletteTransferContoursNumeric probes
Afixedcyclic Alog-v14unchanged
Bfixedcyclic Blog-v14unchanged
Cfixedcyclic Alog-v18unchanged
Dfixedcyclic Asoft-log-v14unchanged
Efixedcyclic Acontrast-log-v14unchanged
Reading rule
Read each row across its named columns; the text carries the diagram's exact values.
  • Color and position reinforce the comparison but never replace its labels.

Art-direct the field without erasing evidence

A palette is part of the diagram. It establishes orientation, contrast near the seam, and whether equal phase directions are visually comparable. A magnitude transfer establishes which zeros, poles, and bands dominate. Neither is neutral, so both belong in the receipt.

The lab exposes three bounded, named magnitude transfers. In domain coloring, these profiles are authored parts of the edition rather than post-processing presets. log-v1 uses a 0.38 lightness base with a 0.28 contour pulse; soft-log-v1 raises the base to 0.46 and narrows the pulse to 0.16; contrast-log-v1 lowers the base to 0.30 and widens the pulse to 0.38. They share the same log2 band coordinate and exceptional-state colors. Unknown transfer IDs fail before allocation or evaluation.

Create contact sheets by freezing function, parameters, domain, resolution, probes, and contour path, then changing one palette or transfer setting at a time. The numeric probe table and function/domain hash must remain unchanged while the pixel hash changes. That separation turns taste into a controlled edition decision.

Contour density should remain legible at article size and at 200% zoom. A dense micro-grid can become visual noise or moiré after social compression. Use labels, line patterns, zero/pole shapes, and a semantic matrix so meaning survives grayscale, forced colors, or a reader who cannot inspect the raster.

WebGPU generative art is an option when a production piece needs GPU-scale exploration. This bounded Canvas lab favors inspectable CPU math and reproducible pixels. Its beauty is an invitation to investigate, not evidence that every classification or winding estimate is correct.

Publish the domain-coloring edition receipt

A complete edition freezes the safe function ID, bounded parameters, domain, bitmap, supersampling, pixel-center rule, palette, magnitude transfer, contour cadence, branch convention, exceptional-state policy, probes, winding diagnostic, and hashes. It contains no executable formula string and never calls eval or Function.

Reject zero-sized images, dimensions over 512, supersampling over 2, combined render/probe/winding evaluation plans above 1,048,576, non-finite values, inverted bounds, parameters outside 20, and contours that touch a known or sampled singularity. Rejections are part of the interface, not blank canvases.

Revisit this domain coloring guide on 2027-03-15, or earlier if Canvas color-space or export behavior changes, or if the renderer's mapping contract changes. Re-run identity, translated zero/pole, winding, branch-cut, pixel-center, and deterministic-hash fixtures before republishing an edition.

The durable conclusion is that the color map belongs to the model. Publish it with the same care as the function and sampling grid, and the artwork can remain expressive without pretending to be a proof.

Runnable local artifact — A sampled raster and winding estimate are numerical illustrations, not proof of analyticity, multiplicity, zero or pole count, or branch structure.

Plain text1 line
Select a fixed complex function, map pixel centers through declared phase and magnitude transfers, preserve cuts and non-finite states, and export PNG plus a hashed edition receipt.