Does an equation exist to describe a square? What about any polygon?

Yesterday I saw some awesome Mr Men Math posters created by @solvemymaths ( and have already stuck some of them up in the corridor at school. Mr Astroid particularly caught my eye as one of the interesting Mr Men shapes.

mr astroid 3 You can see, and understand intuitively, that the equation is a variation on a circle. In fact, the shape of the astroid looks quite close to a square. This got me thinking…does a function exist to describe any given polygon? So here goes…

Using Scratch: Year 7-9 Way of Creating a Polygon

So the standard way to create a polygon via programming is to get on a programme, such as hopscotch, logo or scratch – and create a mini-script to move and then rotate (by the exterior angle) and move and then rotate, etc. until you get back to where you started. Obviously you need to use values for the rotation angle (exterior angle) that are factors of 360 degrees in order to make a connected shape. Using 90 degrees as the rotation angle you get a square.


Using GeoGebra: Year 10-11 Way of Creating a Square

It occurred to me that, by increasing the power of the astroid equation to make it closer to one, it would approximate the linear function x + y = 1 and so the curve would approximate a square. The slider, n, in the picture below represents the numerator of the fraction and the denominator is n+1. The slider must increment by two in order to keep the numerator even. Can you figure out why this has to be the case? (Click the picture to go the GeoGebra File)


The next step in the journey was to realise that I was actually approximating the function below: astroideqn

GeoGebra didn’t like this so I put it in Desmos:

desmos astroid

Polar Coordinates in Desmos: Year 12-13 Way of Creating a Polygon Function

After I reached the modulus function above, I decided that polar coordinates might help with going further but couldn’t think of how this might work – decided to look it up. I found what I was looking for (see this post – thank you to the people who posted) but thought I’d describe the first part in a bit more detail so that students can understand the base of the function and then play around with second part which is fun and interesting. There’s no way I could’ve come up with this but by playing around on Desmos I’ve built up an understanding of why each cog in the function exists.

If you haven’t come across polar coordinates before, go and look up the standard mathematics and then observe the picture below. I decided to stick with a square for the example but could have chosen any polygon for this example.


The x co-ordinate of the right side of the square is x = cos(45). If it were any polygon with n sides, it would be x = cos(180/n), or in radians, x = cos(pi/n) (1).

Since in general with polar coordinates, x = rcos(theta) (2), with r in this case being the distance from the origin to an edge, combining equations (1) and (2) gives:


This is the equation for one side of a polygon. It’s the base function for any polygon with theta between -pi/n and pi/n. To get this base function for the first side to break off into the next side, you need the distance from the origin to stay the same as the equivalent point on the first side. This is very well explained in the link above so go ahead and play with/analyse the second part of the function to find out why it works. The entire function for any polygon is given by:


Click the picture to go to the Desmos File. The floor( ) function rounds a number down to the closest integer. It’s interesting to try the equation above without the floor( ) to see what happens and check this with different values. Indeed, without the floor we have                     r = cos(pi/n)/cos(-pi/n) .

Thanks for inspiring some new learning @solvemymaths!


This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

2 Responses to Does an equation exist to describe a square? What about any polygon?

  1. love the desmos file – never used the site before – so just signed up!

  2. Lee Khiy Wei says:

    This topic will help me alot define square shape. Do you have any reference for this topic you wrote? Thank you very much for your sharing.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s