docs: update README to describe Chudnovsky algorithm and threads note

This commit is contained in:
2025-12-28 00:47:54 -05:00
parent 6d183a5526
commit 3bea3d532a

View File

@@ -1,10 +1,10 @@
# Pi Calculator # Pi Calculator
This is a multi-threaded Rust program that calculates the first n digits of Pi using the BaileyBorweinPlouffe (BBP) formula. It uses arbitrary-precision arithmetic (rug) and parallelism (rayon). This is a multi-threaded Rust program that calculates the first n digits of Pi using the Chudnovsky algorithm with binary splitting. It uses arbitrary-precision arithmetic (rug) and parallelism (rayon).
## Improvements in this branch ## Improvements in this branch
* Parallelized BBP summation with rayon for better thread control and load balancing. * Parallelized Chudnovsky binary-splitting with rayon for better thread control and load balancing.
* Safer argument validation and error handling (avoids unwraps on runtime errors). * Safer argument validation and error handling (avoids unwraps on runtime errors).
* Optional output-to-file support. * Optional output-to-file support.
* Added CI workflow to run formatting, clippy, tests and build on push/PR. * Added CI workflow to run formatting, clippy, tests and build on push/PR.
@@ -30,7 +30,7 @@ Arguments
Options Options
* `-t`, `--threads <THREADS>`: Number of threads to use (default 4). * `-t`, `--threads <THREADS>`: Number of threads to use (default 4). Note: this implementation performs parallel binary splitting and the threads option is kept for compatibility but may be ignored.
* `-o`, `--output <FILE>`: Write output to FILE instead of stdout. * `-o`, `--output <FILE>`: Write output to FILE instead of stdout.
* `-h`, `--help`: Print help. * `-h`, `--help`: Print help.
@@ -44,4 +44,4 @@ Calculate 1000 digits using 8 threads and write to a file:
Notes Notes
For very large numbers of digits, using a decimal-friendly algorithm such as Chudnovsky (with binary splitting) will be far faster and more memory-efficient than BBP; consider switching to Chudnovsky for production-grade large computations. This program uses the Chudnovsky algorithm (binary splitting), which is suitable for high-precision Pi computation. For extremely large computations, further optimizations (tuning precision, memory usage, or linking to specialized big-integer libraries) may be required.