High-precision terminal ฯ explorer โ Chudnovsky, Ramanujan, Machin, and BBP spigot algorithms.
FoxPi is a pure-Python command-line toolkit for computing, exploring, benchmarking, and validating ฯ using several classical and modern algorithms.
It supports arbitrary-precision decimal computation with Chudnovsky, Ramanujan, and Machin, plus direct hexadecimal digit extraction using the BaileyโBorweinโPlouffe (BBP) formula.
The implementation uses integer-scaled arithmetic and includes an independent test suite that checks computed decimal and hexadecimal digits against reference values rather than merely comparing algorithms against themselves.
pyproject.tomlFoxPi requires:
pip for optional editable/package installationThe project declares no runtime third-party dependencies.
git clone https://github.com/foxhackerzdevs/foxpi.git
cd foxpi
python cli.py digits 100
Example output:
ฯ (100 digits) using Chudnovsky:
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
Time: 0.00xxs
python3 -m pip install foxpi
foxpi digits 100
git clone https://github.com/foxhackerzdevs/foxpi.git
cd foxpi
python -m pip install -e .
Current version: 0.1.4
# Compute 100 digits
python cli.py digits 100
# Use a specific method
python cli.py digits 1000 --method chudnovsky
python cli.py digits 1000 --method ramanujan
python cli.py digits 1000 --method machin
# Explore convergence
python cli.py explore --method chudnovsky --terms 15
# Benchmark
python cli.py compare
# Extract hexadecimal digits
python cli.py bbp 100
FoxPi exposes four commands:
foxpi
โโโ digits
โโโ explore
โโโ compare
โโโ bbp
digitsCompute a requested number of decimal digits of ฯ.
python cli.py digits COUNT [--method METHOD]
| Argument | Description |
|---|---|
COUNT |
Number of decimal digits requested |
--method |
chudnovsky (default), ramanujan, or machin |
python cli.py digits 50
python cli.py digits 1000 --method chudnovsky
python cli.py digits 1000 --method ramanujan
python cli.py digits 1000 --method machin
Negative digit counts are rejected.
exploreExplore the convergence of the Ramanujan or Chudnovsky series.
python cli.py explore [--method METHOD] [--terms N]
ramanujan30python cli.py explore
python cli.py explore --method ramanujan --terms 20
python cli.py explore --method chudnovsky --terms 10
compareBenchmark Chudnovsky and Machin at 1000 decimal digits.
python cli.py compare
bbpExtract 16 hexadecimal digits of ฯ starting at a given position.
python cli.py bbp POSITION
POSITION=1 is the first hexadecimal digit after the point.
python cli.py bbp 1
python cli.py bbp 25
python cli.py bbp 100
| Algorithm | Output | Primary purpose |
|---|---|---|
| Chudnovsky | Decimal | High-precision computation |
| Ramanujan | Decimal | Rapid convergence / exploration |
| Machin | Decimal | Classical formula / comparison |
| BBP | Hexadecimal | Direct digit extraction |
Binary-splitting implementation of the Chudnovsky series (~14 digits per term).
This is the default and recommended method for high-precision decimal computation.
python cli.py digits 10000 --method chudnovsky
Ramanujanโs 1914 hypergeometric series for 1/ฯ:
1/ฯ = (2โ2 / 9801) ร ฮฃ [ (4k)! ร (1103 + 26390k) / ((k!)โด ร 396โดแต) ]
Excellent for studying rapid convergence.
python cli.py digits 1000 --method ramanujan
python cli.py explore --method ramanujan --terms 20
Classical Machin formula:
ฯ = 4 ร (4 arctan(1/5) โ arctan(1/239))
python cli.py digits 500 --method machin
BaileyโBorweinโPlouffe formula allowing direct extraction of hexadecimal digits without computing preceding ones.
python cli.py bbp 1
# โ 243F6A8885A308D3
FoxPi uses scaled-integer arithmetic with internal guard digits.
No third-party arbitrary-precision library is required at runtime.
A custom NewtonโRaphson isqrt implementation is provided and covered by the test suite.
python -m unittest discover -s tests -v
Tests verify results against independently generated reference digits (mpmath, 250 decimal digits of working precision).
foxpi/
โโโ core/
โ โโโ algorithms.py
โ โโโ visualize.py
โโโ tests/
โ โโโ test_algorithms.py
โ โโโ test_cli.py
โโโ .gitignore
โโโ LICENSE
โโโ README.md
โโโ cli.py
โโโ pyproject.toml
git clone https://github.com/foxhackerzdevs/foxpi.git
cd foxpi
# Run directly
python cli.py --help
# Run tests
python -m unittest discover -s tests -v
# Editable install
python -m pip install -e .
foxpi --help
Chudnovsky with binary splitting is the recommended high-performance path.
Use python cli.py compare for a quick local benchmark.
Performance depends on Python version, CPU, and requested precision.
compare command uses a fixed 1000-digit workload.explore) intentionally recomputes for visualization and is not optimized for speed.Contributions are welcome. Suggested areas:
FoxPi is released under the MIT License.
Copyright ยฉ 2026 Fox Hackerz
See LICENSE for the full text.
Compute it. Explore it. Benchmark it. Verify it. ๐ฆ