Celebrate the work done by several people over the years, including Sinha / Saha who found another inf. series to calculate pi that converges much quicker than the Madhava series.
They never claimed that it was an earth shattering new way to calculate digits of pi. And I can tell you it is not. I have struggled to get it to produce 2000 digits in a reasonable amount of time (~25 mins).
But the fact that they saw this side-effect of their research into aspects of string theory brings credence and validation to their work because they recognized this hidden jewel in the formula that was taking shape. In my opinion, it demonstrates the level of analysis and review was above and beyond.
And so, this project is dedicated to Aninda Sinha and Arnab Priya Saha for their contribution to our common pursuit of adding to the ways we consume π.
Good job, men!
This project was a crazy amount of fun. I dug deep into many things from WebAssembly, Bluefin and devcontainers, to testing wasm from zig build, to the math involved with the various algorithms to generate digits of π.
I found while profiling the Python code that it is certainly the right language to evaluate these kinds of series with simple syntax. In at least one of them (Gosper's), the individual terms were getting to ~4,000 integer digits long! Wow. I had no idea.
I have gained new appreciation for Python's int type.
And while I did not get to 1,000,000 digits of π with the Saha / Sinha algorithm, I learned a lot - including pochhammer mark (rising factorial) - something to which I had not been exposed before. A very cool byproduct of physics research, but too computationally complex for me to go much further than a couple thousand digits for a hobby project.
I greatly appreciate the fact that they shared that side-effect of the research they were doing. And I sincerely hope the weird reaction from the press that they experienced will not prevent them from sharing unexpected mathematical advancements in the future. Physicists and mathematicians working together - awesome!
-
Developed using devcontainer on:
-
Python use before and during build steps
-
Zig for wasm
-
SolidJS for ui
-
1,000,000 digits of pi
- visualize digits using color pallete like pi-day-2024-with-py for any algorithm
- compare accuracy between any 2 algorithms
- show histrograms - Sinha / Saha series, Gosper's Series, Tachus Pi (F. Bellard), BBP, baseline and also (for testing) random digits and ten_digits
- samples of algorithms are pre-generated and checked in as .zig source files.
See with-compose for the code before devcontainer was used.
The build and deployment process relies on Docker and a vscode devcontainer.
Just Open Folder in Container and run lets ui
in a terminal. Then open http://localhost:9000/ in a browser.
The build process takes a little less than 4 mins on my laptop. So be patient before clicking on the link above.
You will see output like the following when it is done building and is ready for the browser:
$ lets ui
...
VITE v5.4.11 ready in 224 ms
➜ Local: http://localhost:9000/
➜ Network: http://172.17.0.2:9000/
➜ press h + enter to show help
Hit CTRl-C in the terminal where lets ui
was executed to exit.
If you have no other docker images that you want to keep then run this to finish the clean up: docker system prune -af --volumes
.
Note that to run tests locally python, zig, wasmtime and pnpm also need to be installed. Installation of all dependencies is automated in the devcontainer, however.
In order to enable running tests from x86_64.wasm.* targets, zig now utilizes the bytecodealliance's wasmtime
.
Note that version v18+ of wasmtime is required to integrate with zig. And because of that a nightly 0.14 build of zig is required. All of this is automated in the
devcontainer
.
The ziglang project is moving towards a cap on download frequency in an effort to reduce their infrastructure costs.
In order to help with this, I have moved the devcontainer logic to use a local copy of zig-linux-x86_64-0.14.0-dev.*.tar.gz file. This temporary local dependency will be removed once 0.14.0 is officially released.
See the ZIGTAR variable declaration section near the top of vsc-install-zig.sh to determine the version expected.
To get this dependency setup, download the expected file and place it in the root of the local repo dir.
$ cd ~repo-root-dir~
$ wget -O zig-linux-x86_64-0.14.0-dev.1588+2111f4c38.tar.xz https://ziglang.org/builds/zig-linux-x86_64-0.14.0-dev.1588+2111f4c38.tar.xz
Then, Rebuild Container.
Please see klmcwhirter/oci-shared-images for instructions on building the fedora41-python-dx:latest
image used by the devcontainer.json.
- Appendix - Field Theory Expansions of String Theory Amplitudes - journals.aps.org
- Scientists Just Discovered A New Formula For Pi Accidentally - MindYourDecisions - 10 mins
- New Recipe for Pi - Numberphile - shows analysis of values for λ - 14 mins
- Pi-oneers (interview with Sinha & Saha) - Numberphile - 25 mins
- Digits of Pi - Up to 1 Million Digits
- Bellard's record breaking algorithm from 2009 - 2700 Billion digits of pi
- The software he built was named tpi which is short for Tachus Pi; where tachus is an ancient Greek word for fast.
- Wolfram MathWorld Pi Formulas - about a hundred (I didn't count them) formulas documented
- Compiling Python to Native Wasm using wasmer.io py2wasm - still produces large wasm files & requires Python 3.11 (not 3.12+) - wait for 3.12 support
- MDN Web - Canvas API Tutorial