Colorful Mathematical Pascal Mandalas

March 12, 2024
Colorful Mathematical Pascal Mandalas

Visualizing Pascal's Triangle

In this Observable notebook project, I explore the intersection of combinatorics and generative art by creating colorful, hexagonal mandalas based on Pascal's Triangle and modular arithmetic.

Try the interactive Observable Notebook here!

The Mathematics of Combinations

The core of the visualization relies on the binomial coefficient, nCk (or "n choose k"), which represents the number of ways k objects can be selected from a set of n objects where order doesn't matter.

For example, looking at row 4 of Pascal's Triangle (1, 4, 6, 4, 1), we see that given a box of four crayon colors, there is 1 way to select 0 crayons, 4 ways to select 1 crayon, 6 ways to select 2 crayons, 4 ways to select 3 crayons, and 1 way to select all four crayons.

Mathematically, any number in the triangle can be generated by adding the two numbers directly above it.

The Generative Algorithm

To generate these mandalas, you select three different integer moduli. The algorithm then builds three separate Pascal's Triangles, one for each modulus.

The color of each cell in the final triangle is determined by its divisibility:

  • If the cell's value is evenly divisible by all three moduli, it is colored white.
  • If it is not evenly divisible by any of the three moduli, it is colored black.

The notebook features different color rendering modes:

  • True Color Mode: The red, green, and blue (RGB) components of each cell's color are uniquely determined by the remainder when the cell's value is divided by the first, second, and third modulus, respectively.
  • Palette Modes: Three distinct bits are computed depending on whether the cell's value is evenly divisible by each of the moduli. These three bits are then used to index into a predefined color palette.

Finally, to create the mandala shape, this uniquely colored Pascal's Triangle is copied and rotated six times around a central point, yielding a stunning, complex hexagonal pattern!