Algorithmic Art

CSE 143 is one of the most foundational and divisive computer science courses at the University of Washington. The lecturer, Stuart Reges, is credited as one of the founding fathers of the contemporary UW CSE department. As a student of the honors school, I had the incredible opportunity to enroll in the honors section of CSE 143.

The experience in the honors section was, as the case in many other honors courses, less focused on rote knowledge and testing but more so on the academics. The section was similar in feel to the reading and seminar courses that I would later take during my Master’s program. Each week, we would complete task out of class and return to discuss it during the next meeting.

One week we read chapters about Ada Lovelace, whom many consider to be one of the first “programmers” due to her work on one of the first general purpose computational devices ever devised, Charles Babbage’s Analytical Engine. Another, we were tasked by the lovely TA and lecturer Alex Miller to create art with algorithms. We fawned over digital artistry ranging from the procedurally generated and fractals to the interactive.

I created a program that produces a cube. This simple cube, however, is a slice (or I suppose 6 slices), of an infinite mathematical space. The idea is relatively simple:

  • There exists a cube with side of length 22 centered at (x,y,z)=(0,0,0)(x, y, z) = (0, 0, 0)
    • Every point on this cube has 1x,y,z1-1 \le x, y, z \le 1
  • The color of a given point (x,y,z)(x, y, z) on the cube is given as (r,g,b)=(fr(x,y,z),fg(x,y,z),fb(x,y,z))(r, g, b) = (f_r(x,y,z), f_g(x,y,z), f_b(x,y,z))
  • fr,g,b:[1,1]3[1,1]f_{r,g,b}:[-1,1]^3 \mapsto [-1,1]
    • Each function takes in three values in [1,1][-1, 1] and produces one value in [1,1][-1, 1]

For example, we could have the functions:

fr(x,y,z)=xfg(x,y,z)=0fb(x,y,z)=1\begin{align*} f_r(x,y,z) &= x\\ f_g(x,y,z) &= 0\\ f_b(x,y,z) &= 1 \end{align*}

With these definitions, we’d get a cube that is purple and blue with a smooth gradient from blue to purple as xx increases in each plane not normal to the xx axis. This is due to the constant green component of 00, the constant blue component of 11, and the red component which ranges in [1,1][-1, 1] linearly with xx.

This is well and good, but it’s boring. In fact, too boring to show you here. Let’s kick it up a notch. My algorithmic art generates recursive color component functions. Each of the functions above are L0L_0 functions in that they have no recursion. Other L0L_0 functions include 0,1,n:n[1,1],x,y,z0, 1, n:n\in [-1,1], x, y, z.

An L1L_1 function requires 1 level of recursion and these start to produce more interesting results. These include:

cosπxsinπyx+z2zx\begin{align*} \bullet\quad& \cos \pi x\\ \bullet\quad& \sin \pi y\\ \bullet\quad& \frac{x + z}{2}\\ \bullet\quad& zx \end{align*}

This produces exponentially explosive complexity as we increase the level of recursion. For example, here is a L3L_3 formula:

L3(x,y,z)=sin(πx)+cos(πz)+cos(πy)2.02.0L_3(x,y,z) = \frac{\sin(\pi x) + \frac{\cos(\pi z) + \cos(\pi y)}{2.0}}{2.0}

As we increase complexity, we also exponentially increase runtime. Computing level 9 and 10 cubes take several hours. Thankfully, I’ve pre-generated cubes for multiple levels and placed them below for you to enjoy. As you look through the cubes across the levels, drag the cube to rotate it and note how the patterns change across various faces.