Skip to content

Instantly share code, notes, and snippets.

@BenMcLean
Created June 26, 2026 19:39
Show Gist options
  • Select an option

  • Save BenMcLean/57bc13db1337a55429c856231b72f92f to your computer and use it in GitHub Desktop.

Select an option

Save BenMcLean/57bc13db1337a55429c856231b72f92f to your computer and use it in GitHub Desktop.
Mandelbrot set outline for Babbage Analytical Engine
Mandelbrot set outline
This program does not use precomputed points.
It samples the complex plane, runs the Mandelbrot
iteration z = z^2 + c at each sample, and plots
points in the sampled region, runs the Mandelbrot
iteration z = z^2 + c at each sample, and plots
every point that remains bounded after the chosen
iteration limit. This produces a dense image of
the set that fills the Curve Drawing Apparatus.
A set decimal places to 15
A write numbers with decimal point
Sampling window and resolution
N100 -2.20 . x start
N101 0 . x index
N102 0.025 . x step
N103 -1.20 . y start
N104 0 . y index
N105 0.025 . y step
N106 30 . max iterations
N116 130 . x sample count
N117 98 . y sample count
Constants
N107 0
N108 1
N109 2.0
N110 4.0
N111 0.575 . x centring offset
N112 0.615384615384615 . x plot scale
N113 0.816326530612245 . y plot scale
N114 10000000000 . plotter fixed-point scale
N115 0.010 . half-height of sample tick mark
Working storage
. N120 . c real
. N121 . c imaginary
. N122 . z real
. N123 . z imaginary
. N124 . z real squared
. N125 . z imaginary squared
. N126 . next z real
. N127 . next z imaginary
. N128 . magnitude squared
. N129 . iteration counter
. N130 . escaped flag
. N131 . inside flag
. N133 . current plot x
. N134 . current plot y
. N137 . x offset
. N138 . y offset
DC Blue
(?
c imaginary = y start + y index * y step
*
L104
L105
S138
+
L103
L138
S121
+
L107
L107
S101 . x index = 0
(?
c real = x start + x index * x step
*
L101
L102
S137
+
L100
L137
S120
Reset Mandelbrot iteration state for this point
+
L107
L107
S122 . z real = 0
S123 . z imaginary = 0
S129 . iteration counter = 0
S130 . escaped flag = 0
Iterate z = z^2 + c until escape or iteration limit
(?
-
L107
L130
{?
*
L122
L122
>
S124
*
L123
L123
>
S125
+
L124
L125
S128 . magnitude squared
-
L128
L110
{?
+
L108
L107
S130 . escaped = 1
}{
*
L122
L123
>
S127
*
L127
L109
>
S127
+
L127
L121
S127 . next z imaginary
-
L124
L125
S126
+
L126
L120
S126 . next z real
+
L126
L107
S122
+
L127
L107
S123
}
}
+
L129
L108
S129
-
L129
L106
)
A point is considered inside if it never escaped
-
L107
L130
{?
+
L108
L107
S131
}{
+
L107
L107
S131
}
Map the sampled complex-plane point into plotter space
+
L120
L111
S133
*
L133
L112
>
S133
*
L121
L113
>
S134
Plot every point classified inside the set as a short tick
-
L131
L108
{?
*
L133
L114
DX
-
L134
L115
S128
*
L128
L114
DY
D+
+
L134
L115
S128
*
L128
L114
DY
D+
D-
}
+
L101
L108
S101 . x index += 1
-
L101
L116
)
+
L104
L108
S104 . y index += 1
-
L104
L117
)
A write annotation Mandelbrot outline complete
A write new line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment