The Broccoli Equation

Rodrigo Setti
5 min readMar 2, 2020

--

The other day, I was grocery shopping and I stood for a while amazed by a particularly fascinating vegetable: the Romanesco Broccoli.

Also known as Roman Cauliflower, this edible flower bud of the species Brassica oleracea displays a beautiful self-similar pattern.

Self-similar structure close-up of the Romanesco Broccoli

I didn’t get any broccoli, but I did get an inspiration. What a marvelous example of natural fractal! Later that week, I started exploring a way to generate the pattern using math.

Spira mirabilis

The place to start was the Logarithm Spiral. Like many other natural patterns, the Romanesco vegetable also seems to follow the famous spiral. Discovered by René Descartes, and later studied extensively by Jacob Bernoulli, who called it Spira mirabilis (the marvelous spiral).

Examples for a=1, 2, 3, 4, 5

The intriguing property of the marvelous spiral, is that it looks the same no matter at what scale you look at it. It’s self-similar.

In polar coordinates (r, θ), the logarithm spiral can be written as:

r = a exp(b θ)

The logarithm spiral appears in disparagingly many natural phenomena, including Nautilus shells, the nerves of the cornea, bands of tropical cyclones, and spiral galaxies!

The Whirpool Galaxy, 23 million light-years away, is one example of spiral galaxy following the logarithm spiral pattern.

The Cone

Naturally, the broccoli we’re interested is not flat like galaxies, so we need to unwrap our spiral into the space. The shape I used is a cone. Although the Romanesco is not precisely a cone (it looks like more like a drop), but I thought a cone was a decent approximation for this exploration.

Conical spiral with a logarithm spiral as floor plan

So we’re going to unwrap a logarithm spiral around a cone, and along the spiral, grow the smaller broccoli buds. Naturally, a “bud” is just a structure that is similar to the whole, that is, self-similar, so we’ll repeat the entire process for each bud (unwrap the spiral around a cone), and keep going ad infinitum (or until we’re microscopic).

Wrapping cones around a conic logarithm spiral.

To do so, we need to move each cone to the right location (following the conic logarithm spiral equation), scale them so that they are smaller at the peak and larger at the bottom, and finally rotate them, so they all point outwards.

I accomplished that by three affine matrixes: T, S, and R, respectively — which I’ll describe in the next section.

The equation

I used constructive solid geometry to combine millions of cones together, in this framework, there’s algebra for combining solids, and all you need to know is that you can get the union of solids (with the ∪ operator).

The Broccoli equation is recursive, that is, it evokes itself, so we can get the self-similarity pattern we expect.

Here it is:

Where a = 1/2, and b=1/100.

The Broccoli solid is constructed as the union of a unit cone (Cone) and many other buds (note Broccoli appearing recursively in it’s own equation) around a logarithm spiral.

There are four transformation matrixes that plays important roles in this equation.

  • The matrix S1 scales down the entire union of buds, to a tenth of its size, to fit the unit cone.
  • The matrix S2 scales each bud so that they grow as the buds gets closer to the cone’s base (and smaller as they get closer to the cone’s peak).
  • The matrix R rotates each bud so they face outwards, pointing away from the center of the cone.
  • Finally, the matrix T translates each bud, according to the conic logarithm spiral so they all fit in the right place across the cone.

I played around with the values of a, and b constants, eventually landing in 1/2 and 1/100, respectively, as well as tweaked the coefficients of the matrix to find something aesthetic, but didn’t put too much effort to reach natural precision.

Because the equation is recursive, mathematically, there are infinite levels of details, but of course in computers, like in nature, we have to reach an approximation.

I implemented the equation in Povray, limiting the levels of self-similarity from 1 to 4:

Level 1: started with a simple cone.
Level 2: wrap cones around the initial cone (using the conical logarithm spiral)
Level 3: wrap cones around each of the previous cones.
Level 4: repeat.

Unfortunately due to the limitations of my computer I couldn’t compute further than four levels of self-similarity. The number of cones grows exponentially large as I go deeper, following the equation:

Where n is the number of self-similarity levels. Therefore, the Romanesco in the picture above with 4 levels, has close to 160 billion cones (5 levels will yield 100 trillion cones).

Image Credits

--

--

Rodrigo Setti

I’m a software engineer at Google, living in San Francisco. I have broad interests, and I like to write here occasionally about them.