Lesson goal: Times Tables & Cardioid Mandalas

Previous: The cycloid and rolling wheel | Home | Next: Lissajous curves and harmonics

What happens when elementary school multiplication tables collide with geometry? You get breathtaking geometric art!

Imagine arranging $N$ numbered points ($0, 1, 2, \dots, N-1$) evenly around the perimeter of a circle, just like hours on a clock face.

Now choose a multiplier $M$ (for example, $M = 2$):
  1. For each point $k$, calculate $(k \times M)$.
  2. Wrap the number around the circle using clock arithmetic (modulo $N$): $$\text{target} = (k \cdot M) \pmod N$$
  3. Draw a straight line segment connecting point $k$ to its target point.


Even though every single stroke is a straight line, the collection of hundreds of lines collectively outlines a smooth glowing curve called an envelope:
  • $M = 2$ produces a Cardioid (heart shape)—the exact same shape found at the center of the famous Mandelbrot fractal, and in caustic light patterns reflecting off the rim of a coffee mug!
  • $M = 3$ produces a Nephroid (a 2-lobed kidney shape).
  • $M = 4$ produces a 3-lobed epicycloid.
  • In general, an integer multiplier $M$ generates an epicycloid with $(M - 1)$ cusps!


In this lesson, we use gif_circle(0, 0, R, color) and gif_line(x1, y1, x2, y2, color) to animate multiplier $M$ continuously and watch cardioids and nephroids morph smoothly before our eyes!
gif_line(x1,y1,x2,y2,color)
Move the mouse over a dotted box for more information.

Now you try. Try increasing N to 150 or 200 for ultra-sharp caustics, or try stepping M in finer intervals!

Type your code here:


See your results here: