PiProject — High-precision π computation and independent verification
Chudnovsky algorithm · Binary splitting · GMPY2 · BBP spot checks
PiProject computes π (pi) to millions of digits using the Chudnovsky algorithm with binary splitting and GMPY2 arbitrary-precision arithmetic, and verifies results through an independent verification engine that never trusts the computation engine.
PiProject uses the Chudnovsky algorithm, one of the fastest known methods for computing π:
Equivalently:
where P, Q, T come from binary splitting
over the Chudnovsky series — each term yields roughly 14 correct digits.
flowchart TD
A["Input: digit count"] --> B["Chudnovsky binary splitting"]
B --> C["Compute P, Q, T integers"]
C --> D["Integer square root of 10005"]
D --> E["Assemble pi = 426880 * sqrt(10005) * Q / T"]
E --> F["Format digits & guard-digit trim"]
F --> G["Independent verification"]
G --> H["Save pi_N.txt"]
style A fill:#e2e8f0,stroke:#334155
style H fill:#10b981,stroke:#047857,color:#fff
- 🎯 High-precision calculation of π (millions of digits)
- ⚡ Chudnovsky algorithm + binary splitting
- 🔢 GMPY2 arbitrary-precision integer arithmetic
- 🔍 Independent verification engine with explicit statuses
- 🧮 BBP hexadecimal spot checks (algorithmically independent)
- 📄 Streaming output to
pi_<digits>.txt - 🖥️ Professional CLI:
piproject calculate/verify/benchmark/inspect/hash - 🧪 77 automated tests, CI on every push
git clone https://github.com/zomop/PiProject.git
cd PiProject
pip install -r requirements.txt
pip install -e . # install the `piproject` commandpiproject calculate --digits 1000000 --output pi_1000000.txtOptions:
| Option | Meaning |
|---|---|
--digits N |
number of decimal digits of π to calculate |
--output FILE |
output file (default: pi_<digits>.txt) |
piproject verify --input pi_1000000.txt --reference reference.txtOptions:
| Option | Meaning |
|---|---|
--input FILE |
calculated pi file to verify |
--reference FILE |
reference file for full digit-by-digit comparison |
--bbp POSITIONS |
BBP spot-check positions (comma-separated, e.g. 1,10,100) |
piproject benchmark --digits 1000000 --repeats 3piproject inspect --input pi_1000000.txtpiproject hash --input pi_1000000.txtPiProject uses explicit, unambiguous verification statuses:
| Status | Meaning |
|---|---|
CALCULATED |
Value computed; no verification |
STRUCTURE_VALID |
Passes format/length/digit checks |
PREFIX_VERIFIED |
Matches known reference for checked prefix only |
FULLY_VERIFIED |
Every digit compared against a trustworthy reference |
INDEPENDENTLY_VERIFIED |
Confirmed by an independent algorithm (BBP) |
VERIFICATION_FAILED |
A mismatch or error was detected |
Never FULLY_VERIFIED from a prefix check alone.
| Digits | Authoritative Check | Status |
|---|---|---|
| ≤ 1,000 | All digits | FULLY_VERIFIED (built-in reference) |
| > 1,000 | First 1,000 digits | PREFIX_VERIFIED (built-in) |
| Any | All digits vs. external reference | FULLY_VERIFIED (with --reference) |
The built-in reference covers the first 1,000 decimal digits. For full
verification at scale, provide an external reference file with --reference.
Independently cross-checked against decimal/Machin computation and the IonicaBizau/pi-decimals reference:
| Digits | SHA-256 (decimal digits) | Method |
|---|---|---|
| 1,000 | 808b01bd…2292bd |
decimal/Machin + Chudnovsky match |
| 10,000 | 7406a2be…507ab5 |
decimal/Machin + Chudnovsky match |
| 100,000 | 5ebe8007…482bc2 |
decimal/Machin + Chudnovsky match |
| 1,000,000 | 7806ee47…bbf7069 |
IonicaBizau/pi-decimals reference match |
docs/architecture.md— System architecturedocs/algorithms.md— Chudnovsky, binary splitting, BBPdocs/verification.md— Verification methodologydocs/reproducibility.md— Benchmarks & SHA-256 fingerprints
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m "Add amazing feature" - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is open source. A LICENSE file has not yet been added —
the license terms are pending the repository owner's decision.
Made with ❤️ by [zomop](https://github.com/zomop)