foxpi 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- foxpi-0.1.0/LICENSE +21 -0
- foxpi-0.1.0/PKG-INFO +336 -0
- foxpi-0.1.0/README.md +325 -0
- foxpi-0.1.0/cli.py +115 -0
- foxpi-0.1.0/core/__init__.py +0 -0
- foxpi-0.1.0/core/algorithms.py +235 -0
- foxpi-0.1.0/core/visualize.py +25 -0
- foxpi-0.1.0/foxpi.egg-info/PKG-INFO +336 -0
- foxpi-0.1.0/foxpi.egg-info/SOURCES.txt +14 -0
- foxpi-0.1.0/foxpi.egg-info/dependency_links.txt +1 -0
- foxpi-0.1.0/foxpi.egg-info/entry_points.txt +2 -0
- foxpi-0.1.0/foxpi.egg-info/top_level.txt +2 -0
- foxpi-0.1.0/pyproject.toml +22 -0
- foxpi-0.1.0/setup.cfg +4 -0
- foxpi-0.1.0/tests/test_algorithms.py +116 -0
- foxpi-0.1.0/tests/test_cli.py +74 -0
foxpi-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fox Hackerz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
foxpi-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: foxpi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: High-precision terminal π explorer — Chudnovsky, Ramanujan, Machin, and BBP spigot algorithms.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Source, https://github.com/foxhackerzdevs/foxpi
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# 🦊 FoxPi
|
|
13
|
+
|
|
14
|
+
**High-precision π explorer and mathematical visualization toolkit for the command line.**
|
|
15
|
+
|
|
16
|
+
FoxPi is a Python-based CLI application for computing and exploring the digits of π using several famous algorithms. It provides fast high-precision computation, convergence visualization, benchmarking tools, and hexadecimal digit extraction via the Bailey–Borwein–Plouffe (BBP) formula.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Table of Contents
|
|
21
|
+
|
|
22
|
+
* [Features](#features)
|
|
23
|
+
* [Project Structure](#project-structure)
|
|
24
|
+
* [Installation](#installation)
|
|
25
|
+
* [Usage](#usage)
|
|
26
|
+
|
|
27
|
+
* Compute Digits
|
|
28
|
+
* Explore Convergence
|
|
29
|
+
* Compare Algorithms
|
|
30
|
+
* BBP Hexadecimal Digits
|
|
31
|
+
* [Algorithms Implemented](#algorithms-implemented)
|
|
32
|
+
* [Examples](#examples)
|
|
33
|
+
* [Dependencies](#dependencies)
|
|
34
|
+
* [Configuration](#configuration)
|
|
35
|
+
* [Troubleshooting](#troubleshooting)
|
|
36
|
+
* [Contributing](#contributing)
|
|
37
|
+
* [License](#license)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# Features
|
|
42
|
+
|
|
43
|
+
* Compute π to an arbitrary number of decimal digits.
|
|
44
|
+
* Multiple computation algorithms:
|
|
45
|
+
|
|
46
|
+
* Chudnovsky Algorithm
|
|
47
|
+
* Ramanujan Series
|
|
48
|
+
* Machin Formula
|
|
49
|
+
* Interactive convergence exploration.
|
|
50
|
+
* Benchmark algorithm performance.
|
|
51
|
+
* Extract hexadecimal digits directly using the BBP formula.
|
|
52
|
+
* Pure Python implementation using integer arithmetic for high precision.
|
|
53
|
+
* No third-party dependencies.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
# Project Structure
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
foxpi/
|
|
61
|
+
│
|
|
62
|
+
├── cli.py # Command-line interface
|
|
63
|
+
└── core/
|
|
64
|
+
├── algorithms.py # Mathematical algorithms
|
|
65
|
+
└── visualize.py # CLI visualization utilities
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
# Installation
|
|
71
|
+
|
|
72
|
+
Clone the repository:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone <repository-url>
|
|
76
|
+
cd foxpi
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Python 3.9+ is recommended.
|
|
80
|
+
|
|
81
|
+
No external packages are required.
|
|
82
|
+
|
|
83
|
+
Run with a subcommand:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
python cli.py digits 100
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`python cli.py` alone (with no subcommand) prints usage and exits with an error — a subcommand (`digits`, `explore`, `compare`, or `bbp`) is required.
|
|
90
|
+
|
|
91
|
+
or
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
python -m cli
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
# Usage
|
|
100
|
+
|
|
101
|
+
## Compute Decimal Digits
|
|
102
|
+
|
|
103
|
+
Compute π using one of the supported algorithms.
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
python cli.py digits 1000
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Specify the algorithm:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
python cli.py digits 5000 --method chudnovsky
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
python cli.py digits 1000 --method ramanujan
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
python cli.py digits 1000 --method machin
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Explore Convergence
|
|
126
|
+
|
|
127
|
+
Watch the approximation converge term by term.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python cli.py explore
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Choose an algorithm:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
python cli.py explore --method ramanujan
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
python cli.py explore --method chudnovsky
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Limit the number of displayed terms:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
python cli.py explore --terms 20
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Compare Algorithms
|
|
152
|
+
|
|
153
|
+
Benchmark the available implementations.
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
python cli.py compare
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Current benchmark compares:
|
|
160
|
+
|
|
161
|
+
* Chudnovsky
|
|
162
|
+
* Machin
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Extract Hexadecimal Digits (BBP)
|
|
167
|
+
|
|
168
|
+
Retrieve hexadecimal digits beginning at a specified position without computing previous digits.
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
python cli.py bbp 1
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Example:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
python cli.py bbp 1000
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Outputs the next 16 hexadecimal digits beginning at that position.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
# Algorithms Implemented
|
|
185
|
+
|
|
186
|
+
## Chudnovsky Algorithm
|
|
187
|
+
|
|
188
|
+
* Modern state-of-the-art series for computing π.
|
|
189
|
+
* Approximately **14 decimal digits per term**.
|
|
190
|
+
* Uses **binary splitting** for efficient large integer arithmetic.
|
|
191
|
+
* Suitable for very high precision.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Ramanujan Series
|
|
196
|
+
|
|
197
|
+
* Classic 1914 hypergeometric series.
|
|
198
|
+
* Extremely rapid convergence.
|
|
199
|
+
* Integer-scaled implementation for numerical stability.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Machin Formula
|
|
204
|
+
|
|
205
|
+
Uses
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
π = 4 × (4 arccot(5) − arccot(239))
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Advantages:
|
|
212
|
+
|
|
213
|
+
* Simple
|
|
214
|
+
* Educational
|
|
215
|
+
* Useful for comparison against faster modern methods
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Bailey–Borwein–Plouffe (BBP)
|
|
220
|
+
|
|
221
|
+
Supports direct extraction of hexadecimal digits of π.
|
|
222
|
+
|
|
223
|
+
Unlike traditional algorithms, BBP allows accessing hexadecimal digits beginning at an arbitrary position without computing all preceding digits.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
# Examples
|
|
228
|
+
|
|
229
|
+
Compute 100 digits:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
python cli.py digits 100
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Compute 5000 digits using Chudnovsky:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
python cli.py digits 5000 --method chudnovsky
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Visualize convergence:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
python cli.py explore --method chudnovsky --terms 15
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Benchmark:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
python cli.py compare
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Extract hexadecimal digits:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
python cli.py bbp 250
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
# Dependencies
|
|
262
|
+
|
|
263
|
+
Only Python standard library modules are used:
|
|
264
|
+
|
|
265
|
+
* argparse
|
|
266
|
+
* decimal
|
|
267
|
+
* pathlib
|
|
268
|
+
* sys
|
|
269
|
+
* time
|
|
270
|
+
* typing
|
|
271
|
+
|
|
272
|
+
No external dependencies are required.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
# Configuration
|
|
277
|
+
|
|
278
|
+
There are currently no configuration files.
|
|
279
|
+
|
|
280
|
+
Precision and algorithm selection are controlled through command-line arguments.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
# Troubleshooting
|
|
285
|
+
|
|
286
|
+
### Import errors
|
|
287
|
+
|
|
288
|
+
Ensure the project directory structure matches the expected layout:
|
|
289
|
+
|
|
290
|
+
```text
|
|
291
|
+
core/
|
|
292
|
+
algorithms.py
|
|
293
|
+
visualize.py
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
### Slow execution
|
|
299
|
+
|
|
300
|
+
Very large digit counts require significant CPU time.
|
|
301
|
+
|
|
302
|
+
For best performance:
|
|
303
|
+
|
|
304
|
+
* Prefer the Chudnovsky algorithm.
|
|
305
|
+
* Use Ramanujan for convergence exploration.
|
|
306
|
+
* Use Machin primarily for educational purposes and comparisons.
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
### Unexpected precision
|
|
311
|
+
|
|
312
|
+
Higher requested precision naturally requires more computation time and memory due to large integer arithmetic.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
# Contributing
|
|
317
|
+
|
|
318
|
+
Contributions are welcome.
|
|
319
|
+
|
|
320
|
+
Possible improvements include:
|
|
321
|
+
|
|
322
|
+
* Additional π algorithms
|
|
323
|
+
* Parallel binary splitting
|
|
324
|
+
* Progress bars
|
|
325
|
+
* Graphical convergence plots
|
|
326
|
+
* Export benchmark results
|
|
327
|
+
* Automated testing
|
|
328
|
+
* Packaging for PyPI
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
# License
|
|
333
|
+
|
|
334
|
+
No license information was provided in the source files.
|
|
335
|
+
|
|
336
|
+
Consider adding a `LICENSE` file (for example MIT, Apache-2.0, or GPL-3.0) before publishing the project.
|
foxpi-0.1.0/README.md
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# 🦊 FoxPi
|
|
2
|
+
|
|
3
|
+
**High-precision π explorer and mathematical visualization toolkit for the command line.**
|
|
4
|
+
|
|
5
|
+
FoxPi is a Python-based CLI application for computing and exploring the digits of π using several famous algorithms. It provides fast high-precision computation, convergence visualization, benchmarking tools, and hexadecimal digit extraction via the Bailey–Borwein–Plouffe (BBP) formula.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Table of Contents
|
|
10
|
+
|
|
11
|
+
* [Features](#features)
|
|
12
|
+
* [Project Structure](#project-structure)
|
|
13
|
+
* [Installation](#installation)
|
|
14
|
+
* [Usage](#usage)
|
|
15
|
+
|
|
16
|
+
* Compute Digits
|
|
17
|
+
* Explore Convergence
|
|
18
|
+
* Compare Algorithms
|
|
19
|
+
* BBP Hexadecimal Digits
|
|
20
|
+
* [Algorithms Implemented](#algorithms-implemented)
|
|
21
|
+
* [Examples](#examples)
|
|
22
|
+
* [Dependencies](#dependencies)
|
|
23
|
+
* [Configuration](#configuration)
|
|
24
|
+
* [Troubleshooting](#troubleshooting)
|
|
25
|
+
* [Contributing](#contributing)
|
|
26
|
+
* [License](#license)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Features
|
|
31
|
+
|
|
32
|
+
* Compute π to an arbitrary number of decimal digits.
|
|
33
|
+
* Multiple computation algorithms:
|
|
34
|
+
|
|
35
|
+
* Chudnovsky Algorithm
|
|
36
|
+
* Ramanujan Series
|
|
37
|
+
* Machin Formula
|
|
38
|
+
* Interactive convergence exploration.
|
|
39
|
+
* Benchmark algorithm performance.
|
|
40
|
+
* Extract hexadecimal digits directly using the BBP formula.
|
|
41
|
+
* Pure Python implementation using integer arithmetic for high precision.
|
|
42
|
+
* No third-party dependencies.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
# Project Structure
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
foxpi/
|
|
50
|
+
│
|
|
51
|
+
├── cli.py # Command-line interface
|
|
52
|
+
└── core/
|
|
53
|
+
├── algorithms.py # Mathematical algorithms
|
|
54
|
+
└── visualize.py # CLI visualization utilities
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
# Installation
|
|
60
|
+
|
|
61
|
+
Clone the repository:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git clone <repository-url>
|
|
65
|
+
cd foxpi
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Python 3.9+ is recommended.
|
|
69
|
+
|
|
70
|
+
No external packages are required.
|
|
71
|
+
|
|
72
|
+
Run with a subcommand:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
python cli.py digits 100
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`python cli.py` alone (with no subcommand) prints usage and exits with an error — a subcommand (`digits`, `explore`, `compare`, or `bbp`) is required.
|
|
79
|
+
|
|
80
|
+
or
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
python -m cli
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
# Usage
|
|
89
|
+
|
|
90
|
+
## Compute Decimal Digits
|
|
91
|
+
|
|
92
|
+
Compute π using one of the supported algorithms.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
python cli.py digits 1000
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Specify the algorithm:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
python cli.py digits 5000 --method chudnovsky
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
python cli.py digits 1000 --method ramanujan
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
python cli.py digits 1000 --method machin
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Explore Convergence
|
|
115
|
+
|
|
116
|
+
Watch the approximation converge term by term.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
python cli.py explore
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Choose an algorithm:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
python cli.py explore --method ramanujan
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python cli.py explore --method chudnovsky
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Limit the number of displayed terms:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
python cli.py explore --terms 20
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Compare Algorithms
|
|
141
|
+
|
|
142
|
+
Benchmark the available implementations.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python cli.py compare
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Current benchmark compares:
|
|
149
|
+
|
|
150
|
+
* Chudnovsky
|
|
151
|
+
* Machin
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Extract Hexadecimal Digits (BBP)
|
|
156
|
+
|
|
157
|
+
Retrieve hexadecimal digits beginning at a specified position without computing previous digits.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
python cli.py bbp 1
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Example:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
python cli.py bbp 1000
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Outputs the next 16 hexadecimal digits beginning at that position.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
# Algorithms Implemented
|
|
174
|
+
|
|
175
|
+
## Chudnovsky Algorithm
|
|
176
|
+
|
|
177
|
+
* Modern state-of-the-art series for computing π.
|
|
178
|
+
* Approximately **14 decimal digits per term**.
|
|
179
|
+
* Uses **binary splitting** for efficient large integer arithmetic.
|
|
180
|
+
* Suitable for very high precision.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Ramanujan Series
|
|
185
|
+
|
|
186
|
+
* Classic 1914 hypergeometric series.
|
|
187
|
+
* Extremely rapid convergence.
|
|
188
|
+
* Integer-scaled implementation for numerical stability.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Machin Formula
|
|
193
|
+
|
|
194
|
+
Uses
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
π = 4 × (4 arccot(5) − arccot(239))
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Advantages:
|
|
201
|
+
|
|
202
|
+
* Simple
|
|
203
|
+
* Educational
|
|
204
|
+
* Useful for comparison against faster modern methods
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Bailey–Borwein–Plouffe (BBP)
|
|
209
|
+
|
|
210
|
+
Supports direct extraction of hexadecimal digits of π.
|
|
211
|
+
|
|
212
|
+
Unlike traditional algorithms, BBP allows accessing hexadecimal digits beginning at an arbitrary position without computing all preceding digits.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
# Examples
|
|
217
|
+
|
|
218
|
+
Compute 100 digits:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
python cli.py digits 100
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Compute 5000 digits using Chudnovsky:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
python cli.py digits 5000 --method chudnovsky
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Visualize convergence:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
python cli.py explore --method chudnovsky --terms 15
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Benchmark:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
python cli.py compare
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Extract hexadecimal digits:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
python cli.py bbp 250
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
# Dependencies
|
|
251
|
+
|
|
252
|
+
Only Python standard library modules are used:
|
|
253
|
+
|
|
254
|
+
* argparse
|
|
255
|
+
* decimal
|
|
256
|
+
* pathlib
|
|
257
|
+
* sys
|
|
258
|
+
* time
|
|
259
|
+
* typing
|
|
260
|
+
|
|
261
|
+
No external dependencies are required.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
# Configuration
|
|
266
|
+
|
|
267
|
+
There are currently no configuration files.
|
|
268
|
+
|
|
269
|
+
Precision and algorithm selection are controlled through command-line arguments.
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
# Troubleshooting
|
|
274
|
+
|
|
275
|
+
### Import errors
|
|
276
|
+
|
|
277
|
+
Ensure the project directory structure matches the expected layout:
|
|
278
|
+
|
|
279
|
+
```text
|
|
280
|
+
core/
|
|
281
|
+
algorithms.py
|
|
282
|
+
visualize.py
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
### Slow execution
|
|
288
|
+
|
|
289
|
+
Very large digit counts require significant CPU time.
|
|
290
|
+
|
|
291
|
+
For best performance:
|
|
292
|
+
|
|
293
|
+
* Prefer the Chudnovsky algorithm.
|
|
294
|
+
* Use Ramanujan for convergence exploration.
|
|
295
|
+
* Use Machin primarily for educational purposes and comparisons.
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
### Unexpected precision
|
|
300
|
+
|
|
301
|
+
Higher requested precision naturally requires more computation time and memory due to large integer arithmetic.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
# Contributing
|
|
306
|
+
|
|
307
|
+
Contributions are welcome.
|
|
308
|
+
|
|
309
|
+
Possible improvements include:
|
|
310
|
+
|
|
311
|
+
* Additional π algorithms
|
|
312
|
+
* Parallel binary splitting
|
|
313
|
+
* Progress bars
|
|
314
|
+
* Graphical convergence plots
|
|
315
|
+
* Export benchmark results
|
|
316
|
+
* Automated testing
|
|
317
|
+
* Packaging for PyPI
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
# License
|
|
322
|
+
|
|
323
|
+
No license information was provided in the source files.
|
|
324
|
+
|
|
325
|
+
Consider adding a `LICENSE` file (for example MIT, Apache-2.0, or GPL-3.0) before publishing the project.
|