Skip to content

jakevossen5/pi-generator-from-blocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-generator-from-blocks

Demo

This is a way to generate digits of pi by using elastic collisions between an object 100^N larger than the other with a wall and counting the number of collisions.

Inspired by this video by 3Blue1Brown, technical paper.

Usage

From Homebrew

You can install the executable from my homebrew tap by running brew install jakevossen5/taps/pi-generator-from-blocks then running pi-generator-from-blocks in your terminal.

From Source

This program is written in Rust, primarily for speed. First, clone the repository using git clone https://github.com/jakevossen5/pi-generator-from-blocks.git or by downloading and extracting the zip.

Then, install Rust from the offical rust guide.

Compile the program using RUSTFLAGS="-C target-cpu=native" cargo build --release. Then you can run the program using the executable found in the target/release/ folder. By default, it will start with 1 digit, then 2, then 3, etc, until you cancel the program. You can modify the starting value by change n in the source and recompiling.

Notes

I found that 9 is about the limit a modern computer can calculate in a reasonable time (about 10 seconds on my 2018 Macbook Pro, and similar speeds on other computers). It gets very hard to calculate numbers above 10.

Also, the weight of the small block is the smallest possible floating point number. This is to try to prevent oveflow, which will happen if you start with a small block of mass 1. Eventually there is going to be an overflow somewhere because the numbers are so big, but it would take hours to generate that number anyway.

Each increase in n will take almost exactly 10 times longer to complete than the previous n, making this approxemently a O(10^N) algorithm. For example:

example.

About

Generate pi in a ridiculous way using elastic collisions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages