Attractor: Guide and examples
Attractor is a tool to generate and animate images based on iterated functions of complex numbers.
Program
The Program pane is where you define a function that will be iterated.
- You specify mathematical expressions that define the function, using one of three modes (details below).
- All values are complex numbers.
- Builtins:
()
+
-
*
/
^
i
pi
exp
log
sqrt
sin
cos
- Variables appearing in expressions become program parameters that can be used as independent variables for plots.
-
Under “Stop on”, you configure conditions under which we'll stop iterating and declare
xn to be the program’s result.
Plots
A plot shows how the program's result depends on the value of a selected program parameter
as that parameter varies within a region of the complex plane.
- Add a plot by clicking the + button in the bottom right.
- Configure or delete a plot using its controls in the bottom left.
- Drag/pinch/scroll to adjust the plot region (like a map).
To render a plot, the app runs your program at each pixel (with the help of WebGL and your graphics hardware) and
interprets the result as a color.
-
The value used for the varying parameter is determined by the pixel's coordinates in the image.
-
Non-varying parameters are set to their reference values from the Parameters pane.
- You can drag the parameter indicators to change the reference values.
-
The procedure for converting a program result to a color is explained below.
Example: Crown - two plots, one for each program parameter.
-
Drag the parameter indicators around and notice that the color in the square indicator is always the same on both plots.
This color represents the program result when the reference values are used for all parameters.
-
Notice that the visual features at the a indicator on the b plot
match those at the b indicator on the a plot.
Why is this?
Coming soon (maybe): plots with multiple varying parameters;
non-axis-parallel slices of parameter space,
continuous “crossfading” between different independent parameters.
Automation
The Parameters pane is where you set reference values for your program parameters.
You can control a parameter indirectly by enabling automation for it ("☋" button).
-
An automation expression determines
either the parameter's value (p = …)
or its rate of change (p′ = …).
Specifying rates of change produces animated plots.
-
Rates of change are with respect to the time in seconds
(subject to global speed and direction controls, which appear above the program pane when animations are present).
-
You can introduce new variables in automation expressions,
creating automation parameters that can also be automated.
-
Example: express a parameter as a function of t
and then set t′=1 to animate it.
-
Automation only operates on reference values and is not part of the program used in plots.
For example, if a and b are program parameters
and you automate b=1-a,
a plot versus a will still hold b fixed
(to one minus the reference value of a).
-
I intend to rework/clarify this behavior as part of building multi-varying-param plots. Design input welcome!
Examples:
Program modes
Arbitrary map
You specify a function that maps
xn to xn+1,
and we iterate it.
Example: The Mandelbrot set and associated Julia sets,
arising from the map x ↦ x2 + c.
Newton's method
You specify a function and we iterate
Newton's method on it.
Internally, the app differentiates your expression to obtain an exact expression for the Newton's method step.
Examples:
Newton's method (ODE)
You specify a polynomial by giving its derivative and a single point value, and we iterate Newton's method on it.
All three expressions can contain parameters.
This mode enables direct manipulation of
critical points,
which correspond to the flower-like "centers" in the state-space fractal
(as observed by Tatham under "dissection").
Internally, the app converts your polynomial to standard form
(using an "expression FFT": substituting roots of unity for x
and recombining the results to obtain expressions for the coefficients),
then integrates it symbolically to get f(x) in standard form.
Examples:
Coloring
Program results are mapped to colors as follows:
-
Start with a color derived from the ending value xn
using a smooth, periodic coloring of the plane
(a hardcoded combination of red, green, and blue “waves” going in different directions).
- For an escape result, use 0 as the ending value (maps to white).
-
For a cycle result (where the program converged to a repeating cycle of values),
select a cycle member based on the pixel’s image coordinates
so as to produce diagonal stripes in regions where the limit cycle varies smoothly.
-
Darken based on n, the number of iterations that happened. More iterations = darker.
- This is scaled based on the configured iteration limit, so a higher limit yields a brigher image.
-
Iteration counts for fixed-point and escape results are smoothed by comparing the final step to the termination threshold
using Tatham's heuristic (under "decoration").
Coming soon (maybe): customizable coloring, some kind of automatic white balance.
About
Made by Karl Dray in 2020
with funding from dookie cough,
San Francisco's leading canine wardrobe consultancy and venture anticapitalism firm.
Make a sweet fractal? Have feedback on the app? Want to contribute? Want to work on other math-related web apps?
E-mail me.