On this page

Deterministic chaos

A Lorenz trajectory, drawn as continuous vector strokes. Inklet 3.0.

Deterministic chaos

What this figure shows

The trajectory is integrated with fourth-order Runge–Kutta, using a fixed initial state and time step. Consecutive segments share endpoints. Colour indicates elapsed integration time.

Run the example

Install the rendering extras from the release checkout. This example does not require Blender or downloaded assets. See installation for the release checkout and showcase setup for independent PDF previews.

python -m pip install -e '.[render,images]'
python tools/showcase_gallery.py --only attractor --quality final

Open out/showcase/attractor/figure.html to review the result. The same folder contains figure.svg, figure.pdf and figure.png.

Adapt it

Change the data definition, ranges or colours in the attractor() builder. This is the function used by the gallery recipe:

import math
import inklet as i


def attractor():
    def f(p):
        x,y,z=p
        return (10*(y-x), x*(28-z)-y, x*y-8*z/3)
    p=(1.,1.,1.);points=[]
    for step in range(6500):
        dt=.01;k1=f(p);k2=f(tuple(a+dt*b/2 for a,b in zip(p,k1)))
        k3=f(tuple(a+dt*b/2 for a,b in zip(p,k2)));k4=f(tuple(a+dt*b for a,b in zip(p,k3)))
        p=tuple(a+dt*(b+2*c+2*d+e)/6 for a,b,c,d,e in zip(p,k1,k2,k3,k4))
        if step>=500:points.append(p)
    panel=i.panel(137,85,x=(-22,22),y=(0,52))
    ramp=i.ramp(['#19355f','#25899b','#64b9b1','#d9bb71','#d85e45'])
    # Small consecutive segments retain an entirely vector trajectory.
    for start in range(0,len(points)-1,30):
        segment=points[start:start+31]
        panel.line([(x,z) for x,y,z in segment],stroke=ramp(start/(len(points)-1)),stroke_width=.20)
    panel.axes(x='x',y='z')
    return panel.build()

Figure source · Scene builders · Back to the gallery

Search documentation

Type to search guides, examples and the API.