63

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?

12 Answers12

48

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$).

Joel Cohen
  • 9,289
38

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.

Raskolnikov
  • 16,108
14

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

9

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$$

André Nicolas
  • 507,029
  • Parametric equations are fine. We can broaden the scope so that if a few equations are needed, that's still fine. But only as many as needed. For example, in 2D Cartesian, if 2 equations can completely represent a polygon (probably corresponding to x and y), then it's still usable. – Vincent Tan May 29 '11 at 15:21
4

A more general formula exists, for star polygon too and its smoother variations:

$$1=\frac{\sqrt{x^2+y^2} \cos \left(\frac{2 \sin ^{-1}\left(k \cos \left(n \tan ^{-1}(x,y)\right)\right)+\pi m}{2 n}\right)}{\cos \left(\frac{2 \sin ^{-1}(k)+\pi m}{2 n}\right)}$$

or, with polar coordinates:

$$\rho = \frac{\cos \left(\frac{2 \sin ^{-1}(k)+\pi m}{2 n}\right)}{\cos \left(\frac{2 \sin ^{-1}(k \cos (n \phi ))+\pi m}{2 n}\right)}$$

where

$\phi$ - angle;
$\rho$ - radius;
$n$ - number of convex vertices;
$m$ - determines how many vertices the sides will lie on one straight line;
$k$ - hardness - for $k=0$ we get a circle regardless of other parameters, for $k=1$ - a polygon with straight lines, with intermediate values from $0$ to $1$ - intermediate figures between the circle and the polygon.

For more details see this paper (at russian)

sample image sample image

E.Sokol
  • 91
  • 3
2

$\arcsin \left(\sin \left(\left[\sin \left(60\cdot \frac{\pi }{180}\right)\left(\frac{\sqrt{3}}{3}\cdot x+y\right),x\right]\right)\right)+\left(\frac{1}{3}\right)\cdot \arcsin \left(\sin \left(\left[\cos \left(30\cdot \frac{\pi }{180}\right)\left(x-\frac{\sqrt{3}}{3}y\right),y\right]\cdot \sqrt{3}\right)\right)=0$

https://www.desmos.com/calculator/yptmqucuwl

I came up with this to plot a hexagon tessellation in desmos....the [list] funct "hides" the overlay ...so it isn't really a single EQ.....actually there was very little info on this.....took me weeks....enjoy

JoeB
  • 21
1

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).

0

A cheap trick: Take an equation that represents the union of the extensions of the polygon’s sides and add a domain-limiting term to both sides.

For example, the equation $$(x-C)(x+y-\sqrt2C)(y-C)(x-y+\sqrt2C)(x+C)(x+y+\sqrt2C)(y+C)(x-y-\sqrt2C)+\sqrt{1-x^2-y^2}=\sqrt{1-x^2-y^2}$$ with $C=\cos{\frac\pi8}$ describes a regular octagon. For a regular polygon with an even number of sides, you can pair up opposite sides to halve the number of terms: $$(x^2-C^2)((x+y)^2-2C^2)(y^2-C^2)(x-y+\sqrt2C)((x-y)^2-2C^2)+\sqrt{1-x^2-y^2}=\sqrt{1-x^2-y^2}.$$

This obviously generalizes to polygons that are affine images of cyclic polygons, i.e., one whose vertices all lie on an ellipse.

amd
  • 53,693
0

In the context of this question you may define for a given number $n$ some (Fourier) coefficients by these sensible equations (as you have asked for):

$a^{(n)}_k \sim \begin{cases} +k^{-2} & \text{ for } k \equiv 1 \pmod n\\ +k^{-2} & \text{ for } k \equiv (n-1) \pmod n\\ 0 & \text{ otherwise } \end{cases}$

$b^{(n)}_k \sim \begin{cases} +k^{-2} & \text{ for } k \equiv 1 \pmod n\\ -k^{-2} & \text{ for } k \equiv (n-1) \pmod n\\ 0 & \text{ otherwise } \end{cases}$

Then you calculate the functions $a^{(n)}(t)$ and $b^{(n)}(t)$ like this:

$a^{(n)}(t) \sim \sum_{k=0}^\infty a^{(n)}_k\cos(kt)$

$b^{(n)}(t) \sim \sum_{k=0}^\infty b^{(n)}_k\sin(kt)$

Finally you draw the curve $t \mapsto a^{(n)}(t) + ib^{(n)}(t)$ in the complex plane – and get your desired regular $n$-gon.

As an example for $n=4$:

enter image description here

See more examples in the gallery here.

0

Depends what you accept as "a general equation" and what is "a plot". For example, under the $l_1$ metric, the equation of what is perceived as a circle ( points having the same distance to a center) ends up looking like a square. Now would that count as genuine plot? Or, are we only allowed the Euclidean metric for plotting? Also, is an answer containing a limit acceptable? For example $$x^{2n}+y^{2n}=r^{2n} \lim_{n \to +\infty}$$ is a square ( or is it? ) see this for $n=18$

Also is the equation implicit in x and y or polar and parametric plots are also allowed?

jimjim
  • 9,675
0

Reposted from PolymathProgrammer.com, my answer to my own initial query. Generated mostly on my own after some initial help from a friend (Jason Schmurr) and my dad (Russell Gmirkin)


I believe I've solved my own inquiry. The following are functions that, when graphed in polar coordinates render lovely polygons.

In fact, I’ve got 3 versions (6 if you consider rotation a factor; to either align a vertex or the midpoint of a side with $\theta=0$). One with circumradius = 1 (as vertices $\to \infty$, polygons expand outward toward the circumscribed circle), one with apothem = 1 (as vertices $\to \infty$, polygons collapse inward toward the inscribed circle) and one with the midpoint between circumradius & apothem = 1 (as vertices $\to \infty$, both the maxima and minima, thus the circumscribed and inscribed circles, collapse toward that ‘midpoint radius’).

I’d be interested to know whether this approach, describing the radius of a polygon as a periodic function, has any precedent (has anyone else done this, or am I the first)? I’ve been working on this idea for some time (on and off for years), but just recently overcame some stumbling blocks with a little help from a friend and my dad. Most of the legwork was my own, though.

The relatively final form(s) appear to be:

(n-gon, circumradius=1, unrotated)
1/(((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[(v*x)/4]]+((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(Pi/2)]]-((Sec[pi/v]-1)/(Sec[Pi/4]-1))+1)

(n-gon, circumradius=1, rotated $-\pi/4$)
1/(((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(Pi/4)]]+((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(3Pi/4)]]-((Sec[pi/v]-1)/(Sec[Pi/4]-1))+1)

(n-gon, function centered around unit circle, unrotated)
((Sec[Pi/v]+1)/2)/(((Sec[Pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)]]+((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(Pi/2)]]-((Sec[pi/v]-1)/(Sec[Pi/4]-1))+1)

(n-gon, function centered around unit circle, rotated $-\pi/4$)
((Sec[Pi/v]+1)/2)/(((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(Pi/4)]]+((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(3Pi/4)]]-((Sec[pi/v]-1)/(Sec[Pi/4]-1))+1)

(n-gon, apothem=1, unrotated)
Sec[Pi/v]/(((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[(v*x)/4]]+((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(Pi/2)]]-((Sec[pi/v]-1)/(Sec[Pi/4]-1))+1)

(n-gon, apothem=1, rotated $-\pi/4$)
Sec[Pi/v]/(((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(Pi/4)]]+((Sec[pi/v]-1)/(Sec[Pi/4]-1))Abs[Cos[((v*x)/4)-(3Pi/4)]]-((Sec[pi/v]-1)/(Sec[Pi/4]-1))+1)

Don’t know whether they simplify at all to something less complicated… Even if not, they’re beauties!

Examples:

3-gon: here

4-gon: here

5-gon: here

If it's a unique solution and I'm first to it, I submit these as the Gmirkin Polygon Radius Function(s) (or some suitably nifty sounding name that’s not too cumbersome). *Smile* Heh.

I may write them up formally for publication at some point, once a few previous engagements clear up, assuming they’ve not previously been published or some directly correlated function has already been published elsewhere. (If so, I’d like to know when, where and by whom; for academic curiosity’s sake.)

It is my belief that a similar function exists for describing 3D Polyhedrons of some description(s). Though, I have not yet even attempted such a case and will probably stick to 2D cases for now. I can also tell you that if you vary the phase shift of the denominator [Abs[Cos[]]] terms by differing amounts (though not both by some multiple of $\pi/4$, $\pi/2$, etc.), you can also reproduce rectangles, isosceles triangles, etc. In some cases you can also generate diamond shapes by varying some other parameters. It's s surprisingly robust solution, as I'd hoped. Lord knows it's taken me a few years of false starts to get at the correct combination of functions. Though, I learned plenty along the way, much of which helped me generalize to all polygons from the square case a friend solved at my behest a week or two ago.

Here's hoping this is an interesting, unique new solution that's viable and notable. (One can hope!)

Sorry the post is a bit lengthy... ;)

Best,
~Michael Gmirkin


Edit:

Sorry. Jumped the gun slightly.

I retract the above equations. At the behest of someone on another site, I checked in Wolfram Alpha at a few data points. While it appears to work for the Square case (where the coefficients and corrective term basically cancel out), it doesn't work for other cases, but is slightly off. I think I've got the coefficients wrong. Will have to poke around a bit more in the maths to see if it's possible to get a technically correct exact solution.

The graphs were so close as to fool me into thinking they were exact for all cases. Will get back to you if/when I get a technically correct solution. 'Til then... I still believe there is a valid function, since the Square case is technically correct @ 1/(Abs[Sin(x)]+Abs[Cos[x]]) or 1/(Abs[Cos[x]]+[Abs[Cos[x-(Pi/2)]]]). Just need the technically correct coefficient... will work on it as I've got some time. But, for now, the incorrect versions are darned close! ;o) Enough to fool most people (including me, apparently).

0

How's this (Mathematica code)? It gives the n-gons inscribed in the unit circle, with vertices at the nth roots of unity.

Manipulate[PolarPlot[Cos[Pi/n] Sec[(2/n) ArcTan[Cot[(n t/2)]]], {t, 0, 2 Pi}], {n, 3, 40, 1}]

NJS
  • 1
  • I finally got this to work: polarplot [ cos(Pi/7)/cos( | (t mod (2Pi/7)) - (2Pi/(2*7)) | ) , {t,0,2Pi}] Replace "7" with the number of sides you want. Read the explanations of how I got that equation here: http://polymathprogrammer.com/2014/01/29/regular-polygon-equation-solved/ – Vincent Tan Feb 18 '14 at 11:12
  • You're basically using $\arctan \cot x$ here as your sawtooth… :) – J. M. ain't a mathematician Aug 17 '15 at 07:54