(This post originally appeared in Huffington Post’s Science section, and later on Princeton Press’ blog.)

Did you know that you can create beautiful flowers with an equation? Read on to find out how.

Before I tell you what that equation is, let me convince you first. The picture below shows a particular graph of this equation (on the left) along with an actual flower (on the right).

Pretty neat, huh? But wait, there’s more! Let’s change just one number in this equation and see what happens.

A fourth petal! (And yes, I’ve also changed the color.) Thus far there is one clear takeaway: These “mathematical flowers” are strikingly similar to the real thing. Let me give you one last example:

So, what’s the equation that can seemingly duplicate many of the pretty flowers we see around us, and what is the number that controls how many petals are generated? The equation is

and by changing *n* we control the number of petals. But to generate recognizable flowers we need to choose *n* to be a natural number (1,2,3,…). In that case the equation above produces the “mathematical flowers” in the three pictures you saw. For example, in the first picture *n*=3, in the second picture *n*=2 (not 4), and in the third picture *n*=5. When *n* is not a natural number, you get curves that don’t look anything like flowers. For example, here’s the peanut-like curve you get for *n*=1/6:

I produced all of these graphs on my computer, but you don’t have to have special software to do it yourself. You can now share the joy of receiving “mathematical flowers” with the moms in your life by using the widget I wrote that produces several of these virtual flowers. Here it is (it’s free to use).

I’m sure mom will be as surprised as you were to see just how realistic these mathematical flowers look. And if your mom is a math enthusiast, or would just like to understand how the *r*-equation produces those flowers, read on and you’ll be able to explain it to her.

First, have a look at the diagram below.

Here I’m showing you two different ways to plot a point, in this case (*a*,*b*). In the method we’re most familiar with you move *a* units to the right from the origin (the point where the two axes intersect) and *b* units up from there. That’s called graphing in *Cartesian coordinates*. But you can also graph the same point in *polar coordinates*. To do so, you first move *r* units away from the origin, and then rotate counter-clockwise by the angle in the picture (the Greek letter “theta”).

One quick way to generate lots of points is to graph an equation, like *y*=*x*^{2}. This rule tells us that the *y*-value is the square of the *x*-value. For example, when *x*=1 we get*y*=1, and when *x*=2 we get *y*=4. Therefore, the points (1,1) and (2,4) (in Cartesian coordinates) are on the graph of *y*=*x*^{2}.

Our “mathematical flowers” are just the graphs of the cosine equation above, but where each point is plotted in the polar coordinate system. For example, when the angle theta is zero we get *r*=1, meaning that the point (1,0) is on the graph of every mathematical flower, regardless of what *n* is. As theta ranges from 0 to 360 degrees, the graphs generate the flower-like curves I showed you in the first three pictures. (I took the extra steps of shading in the graphs and putting them on a nice background.)

Now that you know how those “mathematical flowers” were generated, let me leave you with an interesting thought. Instead of creating curves with an equation and then comparing the results to real flowers, we could reverse this reasoning and come to a much more interesting possibility: Maybe flowers follow mathematical laws as they grow! For many flowers, and indeed many other examples of natural phenomena, this is indeed true. This surprising fact is just another example of hidden mathematics all around us.

Happy Mother’s Day!