Is there an equation to describe regular polygons?

For example, the square can be described with the equation $|x| + |y| = 1$. So is there a general equation that can describe a regular polygon (in the 2D Cartesian plane?), given the number of sides required?

Using the Wolfram Alpha site, this input gave an almost-square: PolarPlot(0.75 + ArcSin(Sin(2x+Pi/2))/(Sin(2x+Pi/2)*(Pi/4))) (x from 0 to 2Pi)

This input gave an almost-octagon: PolarPlot(0.75 + ArcSin(Sin(4x+Pi/2))/(Sin(4x+Pi/2)*Pi^2)) (x from 0 to 2Pi)

The idea is that as the number of sides in a regular polygon goes to infinity, the regular polygon approaches a circle. Since a circle can be described by an equation, can a regular polygon be described by one too? For our purposes, this is a regular convex polygon (triangle, square, pentagon, hexagon and so on).

It can be assumed that the centre of the regular polygon is at the origin $(0,0)$, and the radius is $1$ unit.

If there's no such equation, can the non-existence be proven? If there are equations, but only for certain polygons (for example, only for $n < 7$ or something), can those equations be provided?


Solution 1:

Any polygon (regular or not) can be described by an equation involving only absolute values and polynomials. Here is a small explanation of how to do that.

Let's say that a curve $C$ is given by the equation $f$ if we have $C = \{(x,y) \in \mathbb{R}^2, \, f(x,y) = 0\}$.

  • If $C_1$ and $C_2$ are given by $f_1$ and $f_2$ respectively, then $C_1 \cup C_2$ is given by $f_1 . f_2$ and $C_1 \cap C_2$ is given by $f_1^2 + f_2^2$ (or $|f_1| + |f_2|$). So if $C_1$ and $C_2$ can be described by an equation involving absolute values and polynomials, then so do $C_1 \cup C_2$ and $C_1 \cap C_2$.

  • If $C = \{(x,y) \in \mathbb{R}^2, \, f(x,y) \ge 0\}$, then $C$ is given by the equation $|f|-f$.

Now, any segment $S$ can be described as $S = \{(x,y) \in \mathbb{R}^2, \, a x + b y = c, \, x_0 \le x \le x_1, \, y_0 \le y \le y_1\}$, which is given by a single equation by the above principles. And since union of segments also are given by an equation, you get the result.

EDIT : For the specific case of the octagon of radius $r$, if you denote $s = \sin(\pi/8)$, $c = \cos(\pi/8)$, then one segment is given by $|y| \le rs$ and $x = rc$, for which an equation is

$$f(x, y) = \left||rs - |y|| - (rs - |y|)\right| + |x-rc| = 0$$

So I think the octagon is given by

$$f(|x|,|y|) \ f(|y|,|x|) \ f\left(\frac{|x|+|y|}{\sqrt{2}}, \frac{|x|-|y|}{\sqrt{2}}\right) = 0$$

To get a general formula for a regular polygon of radius $r$ with $n$ sides, denote $c_n = \cos(\pi/n)$, $s_n = \sin(\pi/n)$ and

$$f_n(x+iy) = \left||rs_n - |y|| - (rs_n - |y|)\right| + |x-rc_n|$$

then your polygon is given by

$$\prod_{k = 0}^{n-1} f_n\left(e^{-\frac{2 i k \pi}{n}} (x+iy)\right) = 0$$

Depending on $n$, you can use symmetries to lower the degree a bit (as was done with $n = 8$).

Solution 2:

Here's a parametric equation I have made for a regular $n$-gon, coded in R:

n=5;
theta=(0:999)/1000;
r=cos(pi/n)/cos(2*pi*(n*theta)%%1/n-pi/n);
plot(r*cos(2*pi*theta),r*sin(2*pi*theta),asp=1,xlab="X",ylab="Y",
main=paste("Regular ",n,"-gon",sep=""));

And picture:

5-gon

The formula I used is

$$\displaystyle r=\frac{\cos\left(\frac{\pi}{n}\right)}{\cos\left(\left(\theta \mod \frac{2\pi}{n}\right) -\frac{\pi}{n}\right)} \; .$$

This equation is actually just the polar equation for the line through the point $(1,0)$ and $(\cos(2\pi/n),\sin(2\pi/n))$ which contains one of the edges. By restricting the range of the variable $\theta$ to the interval $[0,2\pi/n[$, you will in fact just get that edge. Now, we want to replicate that edge by rotating it repeatedly through an angle $2\pi/n$ to get the full polygon. But this can also be achieved by using the modulus function and reducing all angles to the interval $[0,2\pi/n[$. This way, you get the polar equation I propose.

So, using polar plots and the modulo function, it's pretty easy to make regular $n$-gons.

Solution 3:

Here is another parametric equation for a regular $n$-gon with unit radius:

$$\begin{align*}x&=\cos\left(\frac{\pi}{n}\right)\cos\left(\frac{\pi}{n}(2\lfloor u\rfloor+1)\right)-(2u-2\lfloor u\rfloor-1)\sin\left(\frac{\pi}{n}\right)\sin\left(\frac{\pi}{n}(2\lfloor u\rfloor+1)\right)\\y&=\cos\left(\frac{\pi}{n}\right)\sin\left(\frac{\pi}{n}(2\lfloor u\rfloor+1)\right)+(2u-2\lfloor u\rfloor-1)\sin\left(\frac{\pi}{n}\right)\cos\left(\frac{\pi}{n}(2\lfloor u\rfloor+1)\right)\end{align*}$$

for $0 \leq u \leq n$.

The provenance of this set is a bit more transparent if we switch to matrix-vector notation:

$$\begin{pmatrix}\cos\left(\frac{\pi}{n}(2\lfloor u\rfloor+1)\right)&-\sin\left(\frac{\pi}{n}(2\lfloor u\rfloor+1)\right)\\\sin\left(\frac{\pi}{n}(2\lfloor u\rfloor+1)\right)&\cos\left(\frac{\pi}{n}(2\lfloor u\rfloor+1)\right)\end{pmatrix}\begin{pmatrix}\cos\left(\frac{\pi}{n}\right)\\(2u-2\lfloor u\rfloor-1)\sin\left(\frac{\pi}{n}\right)\end{pmatrix}$$

and we see that the construction involves rotating and copying the line segment joining the points $(\cos\left(\frac{\pi}{n}\right),\pm\sin\left(\frac{\pi}{n}\right))$ $n$ times around a circle.


Here's sundry Mathematica code:

GraphicsGrid[Partition[Table[
  ParametricPlot[Through[{Re, Im}[
        (Cos[Pi/n] + I (2u - 2 Floor[u] - 1)Sin[Pi/n])*
         Exp[(I Pi/n) (2 Floor[u] + 1)]],
     {u, 0, n}], {n, 3, 11}], 3]]

regular polygons, 3-11

Solution 4:

The following is probably not in the spirit of the game, but what about a parametric equation? If we are willing to use complex numbers to represent points in the plane, we could use $$z=t\exp(2\pi ik/n) +(1-t)\exp(2\pi i(k+1)/n),\qquad 0 \le t<1,\quad k=0, 1, \dots, n-1$$

Solution 5:

Simply enough:

r(θ) = sec(θ%(π/n')-π/n)

When n' = n/2 and % is the modulus operator.

It would work just as well with cosecant as with secant.

Also the apothem would be 1 and the radius sec(-π/n).