Page MenuHomeDevCentral
Authored By
dereckson
Feb 24 2020, 07:42
Size
816 B
Referenced Files
None
Subscribers
None
WITH RECURSIVE
-- Grid of points for which the Mandelbrot set will be approximated
xaxis(x) as (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x < 1.2),
yaxis(y) as (VALUES(-1.0) UNION ALL SELECT y+0.10 FROM yaxis WHERE y < 1.0),
-- Mandelbrot iterations
m(iter, cx, cy, x, y) AS (
SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis
UNION ALL
SELECT iter + 1, cx, cy, x*x - y*y + cx, x*y*(x+y) + cy FROM m
WHERE (x*x + y*y) < 4.0 AND iter < 28
),
m2(iter, cx, cy) AS (
SELECT max(iter), cx, cy FROM m GROUP BY cx, cy
),
-- ASCII representation line per line
a(t) AS (
SELECT group_concat(substr(' .+*#', 1 + min(iter/7, 4), 1), '')
FROM m2 GROUP BY cy
)
-- All lines
SELECT group_concat(rtrim(t), x'0a') FROM a;

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
368561
Default Alt Text
raw.txt (816 B)

Event Timeline