cancel
Showing results for
Did you mean:

# Engine Works Blog

Under the hood of Alteryx: tips, tricks and how-tos.
###### #SANTALYTICS

We will be upgrading the Gallery to our 2019.4 release this Saturday, December 7th beginning at 9:00am MT. We expect the outage to take last approx. 2.5 hours.

## Generating fractals in Alteryx

Alteryx

Outside of Alteryx, my other full-time job is being a dad for my two young children.  My five year old daughter has been particularly ornery these days, especially at tooth brushing time.  The other night I went against the grain of the parenting books and pulled out the heavy artillery... bribery.  My bribe was simple, brush your teeth and we'll look at a special book together, a ~25 year old coffee-table fractal picture book.

To my delight, she was mesmerized by the computer-generated images, and admired their relationship with shapes she was familiar with such as leaves and mountains.  In the end, my simple bribe turned into a minor parenting victory!  And, since I'm a developer, it also got me thinking about Alteryx.

My challenge the next morning, of course, was to convince Alteryx to generate fractals.  I started with the Mandelbrot Set because the equation is devilishly simple to explain and solve.  Conceptually, for some number on the complex number plane, its membership in the Mandelbrot set is determined by the iterative equation:

Zn+1 = Zn2 + C

That is, the value of the (n+1)th iteration is the square of the value from the nth iteration plus a constant.  After each iteration, the computed value determines whether or not the point has stayed within the set's limits (with a maximum Euclidean distance of 2 from the origin), or escaped toward infinity.  The number of iterations required before a point escapes is a measure of how “close” a point is to the set, and can be used as the basis of color when rendering.

In Alteryx itself, the conceptual algorithm is as follows:

1. Collect user input for the region of exploration, either manually or via a Map Input tool
2. Generate a two-dimensional grid of cells in the X-Y plane and compute each cell’s center point
3. For each center point, iterate over the Mandelbrot equation up to a maximum number of iterations
4. Convert each center point to a spatial object
5. Render each point in a Report Map tool, shading each point based its iteration count

The Alteryx app package is attached for reference, and each of the five steps above is labeled accordingly.  I use an iterative macro to handle the looping, and after each iteration, records that are still “in” the Mandelbrot set are sent back into the macro for another iteration.  Records no longer in the set are marked with the number of iterations required to escape, and that value is used for coloring.  I'm happy with the first-pass soluton, especially using the Map Input tool to select an input region, and clearly there is room for improvement, particularly with the color map generation.

An example of the entire Mandelbrot set and a zoomed-in region:

This is another perfect example of how Alteryx can be used (abused?) to solve nearly any problem, regardless of the domain.  And, even though this is a solved problem (even in Alteryx! Take a look at an old post on Adam's blog), it was still a great exercise.  Not only was it a neat Alteryx challenge problem, it was the first time I showed my daughter what I do “at work”, tying the experience back to something she’d seen in a book just the night before.  Now that is cool.

Stephen Ahlgren

Steve is a principal developer at Alteryx on the Emerging Capabilities team, working largely in C++ but dabbling in other languages and technologies. His contributions include backend components of the Alteryx Server, Hadoop connectors (HDFS/Avro), JavaScript integration in both the Designer and Engine (CEF), and the new Spark Direct functionality.

Steve is a principal developer at Alteryx on the Emerging Capabilities team, working largely in C++ but dabbling in other languages and technologies. His contributions include backend components of the Alteryx Server, Hadoop connectors (HDFS/Avro), JavaScript integration in both the Designer and Engine (CEF), and the new Spark Direct functionality.