John Wallis was a mathematician who found/discovered/invented the Wallis function (or Wallis product as its friends call it).
The Wallis function is the most used method to calculate pi.
As you have probably figured from the name of this repo I'm not the biggest fan of his function.
This repo is meant to show how horrible the Wallis function is and to ask every developer in the world to demolish it.
I implemented a better function to calculate pi, the code in the repo is running the function, and comparing it to the Wallis function.
Instead of going through all this trouble you can just view the Online Demo (press the "Run" button if needed)
git clone https://github.com/donno2048/Anti-wallis
cd Anti-Wallis
You can also install every requirement (sudo apt update && sudo apt install gcc python3 nodejs golang-go -y
) and run the interactive session (bash main.sh
)
C
sudo apt update
sudo apt install gcc -y
gcc c/main.c c/test.c c/pi.c -o main -lm
./main
Python
sudo apt update
sudo apt install python3 -y
python3 py/main.py
JavaScript
sudo apt update
sudo apt install nodejs -y
(--experimental-modules
is only needed for node version <= 12
)
node --experimental-modules js/main.mjs
Go
sudo apt update
sudo apt install golang-go -y
go run go/main.go go/pi.go go/test.go
Rust
sudo apt update
sudo apt install rustc -y
rustc rust/main.rs
./main
If you're wondering why so few digits of pi take so much time to evaluate note these two facts:
- To benchmark the functions I'm running them
100
times - Not all the evaluated digits are being printed, simply because of the language itself or the properties of string formating in it