Generating Fractals with Postgres
At that point the result of the entire recursive CTE is the concatenation of the results of every query that ran as part of executing the CTE. With our new knowledge of recursive CTEs, we can now write a query that can test whether or not a given point is part of the Mandelbrot set. That looks something like the following query that makes use of complex arithmetic:
We can then test whether a point is part of the Mandelbrot set with the following predicate:
If you take the query for producing the Sierpinski triangle and replace the part for testing the bitwise AND with the test for the Mandelbrot set, you get the following query:
As it turns out there is a class of fractals based on this idea of repeatedly evaluating a function at each point in a space.
Source: malisper.me