# Chaos game and fractal polygons

Let $$V=\{v_1,v_2,\cdots,v_n\}$$ the set of $$n$$ vertices of a regular polygon. For $$n=3$$ the chaos game implies that with an arbitrary point on the plane $$x_0$$, and by applying the recursive relation $$x_{k+1}=\frac{x_k+v_r}{2}$$ where $$1\le r\le n$$ is a random integer at each step, then $$x_k$$ will ultimately lie on a Sierpiński triangle for sufficiently large $$k$$.

Without any prior knowledge about the technical terms and proofs (and just as a fun way of passing time), I tried to generalize this formula for $$n$$-polygon, i.e. $$x_{k+1}=(x_k+v_r)/c(n)$$ where $$c(n)$$ is a constant depending on $$n$$. It is evident that $$c(n)$$ has some kind of a "threshold value" for which if a lesser value is applied then the polygons will overlap on each other and vice versa. This picture illustrates my point:

After a lot of trial and error, I came up with this formula: $$c(n) =\begin{cases} a/\tan(a\pi/n)+1, & \text{if }\; n\equiv 0 \mod 4 \\ a/\sin(a\pi/n)+1, & \text{otherwise} \end{cases}\tag{*}\label{*}$$ where $$a=\frac12$$ for odd $$n$$ and $$1$$ if $$n$$ is even. I tested this for $$n$$ up to $$20$$ and it looks like a precise estimate of the threshold value of $$c(n)$$. Here is a simple Mathematica code for testing the results:

coeff[n_Integer]:= With[{f = If[#~Divisible~4, Tan, Sin]&, a = 2^-Mod[n, 2]},
a/f[n][a Pi/n]+ 1.];
iterate[polygon_List]:= With[{c = coeff@Length[polygon]}, (#1 + #2)/c &];
pointset[polygon_List, n_: 10^6]:= With[{f = iterate[polygon]},
NestList[f[RandomChoice@polygon, #]&, RandomReal/@CoordinateBounds[polygon], n]];

With[{set = pointset[CirclePoints[5]]}, (* n = 5 in this case *)
Graphics[{AbsolutePointSize[1/2], Blue, Point[set]}, ImageSize -> Large]]


#### Question

I have no idea whether $$\eqref{*}$$ is correct in general. If so, can it be proven? I checked the wikipedia page for $$n$$-flake and it does mention some formulas unrelated to this, but I couldn't find anything similar to the one I came up with.

Let the length of one side of the $$n$$-sided regular polygon be 1. By the scaling transformation, the polygon must be shrunk by factor $$s$$ (for your notation, $$c(n) = 1 / s$$).

For $$n=3$$, $$s = 1 /2$$ as you can see $$2s = 1$$ in the following figure:

From $$n=5$$, $$s \cos (2\pi / n)$$ should be taken into consideration ($$2\pi / n$$ is the exterior angle):

At $$n=9$$, another contribution $$s \cos (4\pi / n)$$ starts to appear:

In general, for $$n \ge 3$$, $$$$2 \left[ s + \sum_{k=1}^\infty s \cos\biggl( \frac{2\pi k}{n} \biggr) \Theta\biggl( \frac{2\pi k}{n} \le \frac{\pi}{2} \biggr)\right] = 2 s \left[ 1 + \sum_{k=1}^{\lfloor n/4 \rfloor} \cos\biggl( \frac{2\pi k}{n} \biggr) \right] = 1,$$$$ where $$\Theta(b)$$ is $$1$$ if $$b$$ is true and otherwise $$0$$, or $$$$c(n) = \frac{1}{s} = 2 \sum_{k=0}^{\lfloor n/4 \rfloor} \cos\biggl( \frac{2\pi k}{n} \biggr) = 1 + \frac{\sin\Bigl(\frac{\pi}{n} \bigl(1+2\lfloor \frac{n}{4} \rfloor \bigr)\Bigr)}{\sin\Bigl(\frac{\pi}{n}\Bigr)}.$$$$ Though it seems a bit tedious to prove your equation is equivalent to the above formula, Mathematica can check it for you up to a certain $$n$$:

coeff[n_] := With[{f = If[#~Divisible~4, Tan, Sin]&, a = 2^-Mod[n, 2]}, a/f[n][a Pi/n]+ 1];
coeff2[n_] := 1 + Sin[Pi / n (1 + 2 Floor[n / 4])] / Sin[Pi / n];
Table[{n, coeff[n] == coeff2[n]}, {n, 3, 100}] // FullSimplify // MatrixForm  (* all True *)

• Yes I figured myself it's a bit tedious to prove the formula. But +1 for the first part Jun 9, 2022 at 18:22