CodingTrain / CodingTrain/Suggestion-Box

Pi Day 2023 - Visualization of Pi via the Chaos Game

Open
#1,782 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

Hello,
I know it is kind of early for $\pi$ day, but here is my suggestion for a short challenge on it: visualize $\pi$ via the Chaos Game. It is another way to show (visually) that its digits are actually random. I have made a version of it [with p5js](https://editor.p5js.org/silvas/full/zllj1loyg) using only 50k digits.
![pi_visualized](https://user-images.githubusercontent.com/18087952/214307705-ad5e348d-c1c1-4629-9514-ba95b6a75f96.png)

The great Shiffman made videos on the Chaos Game in the past (Coding Challenge 123 [part 1](https://youtu.be/7gNzMtYo9n4) and [part2](https://youtu.be/A0NHGTggoOQ)), so it shouldn't be new to the fans, but I will provide a short explanation of what you see above.

You start with 10 equally spaced points on a circle that represent the digits {0,1,2,3,4,5,6,7,8,9}. Pick also another point in the plane (in the picture above, if you look closely you can see I started at the center of the circle). In the Chaos Game you will then ***randomly*** choose one of those points on the circle, move a certain distance towards it, and repeat indefinitely. However, this time, we will choose the point on the circle following the digits of $\pi$: we will first move towards the point representing $1$, then towards $4$, then $1$, then $5$, then $9$, and so on. You may ask how much should we move towards each point? whatever we want! I used $(\sqrt{5}-2)$, so at every step we move approximately $0.236$ of the distance between the current and the target point. I calculated this number using a formula that guarantees just-touching shapes [^1]. The fact that we obtain the same final picture following either method, shows that there is no discernible pattern in the digits of $\pi$, i.e. they are random.

## Further variations

What if we read the digits of $\pi$ two at a time? That is we have a two-digit number $14$, $15$, $92$, etc. instead of $1$, $4$, $1$, $5$, $9$, $2$, etc. Should we use 100 equally spaced points on the circle? Sure, but since 100 is divisible by 4 and 5, we can group the two-digits into 4 or 5 groups or take them modulo 4 or 5. Therefore we could use only 4 or 5 equally spaced points on the circle.

*What shape should we expect to obtain?*

[^1]: Refer to [Larry Riddle at Agnes Scott College](https://www.larryriddle.agnesscott.org/ifs/pentagon/ngondet.htm) or the article by **Schlicker and Dennis**, "*Sierpinski n-gons*", Pi Mu Epsilon Journal, **10** (1995), No. 2, 81-89.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.