Skip to main content

PiGen : Generators For Digits of Pi

https://img.shields.io/pypi/v/pigen.svg https://img.shields.io/travis/stkterry/pigen.svg Documentation Status

Overview

A small collection of generators and functions for digits of pi. Maybe you’ve an art or math project and need to generate a few thousand to a few million digits of pi? This will help with that.

Generators

Spigot’s Algorithm | pigen.spigot_pi

  • spigot_pi is a generator function.

  • Useful when you only need a single digit at a time.

  • Not as fast as frac_pi but a classic…

from pigen import spigot_pi as spi

pi_gen = spi()
for _ in range(100): # Let's iterate through the first 100 digits of pi.
  digit = next(pi_gen)
  # do something with digit

Fractional Continuation | pigen.frac_pi

  • frac_pi is a generator function.

  • Useful when you only need a single digit at a time.

  • Fastest single digit generator currently in the package.

  • You can pass your own lambda functions for other well behaved irrational numbers!

  • You can specify the base for output as well, i.e., decimal, hex, etc.

from pigen import frac_pi as fpi

pi_gen = fpi()
for _ in range(100): # Let's iterate through the first 100 digits of pi.
  digit = next(pi_gen)
  # do something with digit

# We can pass lambdas to get different transcendental numbers.
# The golden ratio
phi_gen = fpi(lambda a: 1, lambda b: 1, base=10)
for _ in range(1000): # Let's iterate through the first 1000 digits of phi.
  digit = next(phi_gen)
  # do something with digit

Chudnovsky’s Binary Search | pigen.chudnovsky_pi

  • chudnovsky_pi is a regular function.

  • Useful if you need many digits at once.

  • The absolute fastest across the board. If you need a million

  • digits or more, this has got you covered.

  • You need only pass the number of digits you’d like to generate.

  • Makes heavy use of gmpy2 and the associated libs. Very fast but you may need to install other platform specific dependencies.

from pigen import chudnovsky_pi as cpibs
n = 1000000
n_pi_digits = cpi(n) # An integer `n` digits long containing digits of pi

Other

  • Free software: MIT license

  • TODO

    • CLI

    • Examples

Credits

  • The Chudnovsky’s BS Algorithm was pulled and updated from an example by Nick Craig-Wood.

History

0.1.2 (2020-01-27)

  • First release on PyPI.

  • Completely removed slower Chudnovsky function. It didn’t generate the correct sequence.

Metadata

Release files for pigen 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pigen 0.1.5
File Size Uploaded Provenance Actions
pigen-0.1.5.tar.gz 6.3 kB Without provenance Details for pigen-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pigen 0.1.5
File Interpreter ABI Platform Actions
pigen-0.1.5-py2.py3-none-any.whl Python 3, Python 2 none any Details for pigen-0.1.5-py2.py3-none-any.whl

Total release size: 11.6 kB

Release files / pigen-0.1.5.tar.gz

Download URL pigen-0.1.5.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
00a81f97cb106268c1f80df4add4440e6dbd264ec30d548a375fee423ab3435f
BLAKE2b-256 checksum
How to use checksums
05c7a983cabee8d92c098032f4b6446fbb8f9f69ba9a7c6f475541f08be78a8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

Release files / pigen-0.1.5-py2.py3-none-any.whl

Download URL pigen-0.1.5-py2.py3-none-any.whl
Size 5.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
caae9359d886a74ba8f1f200df860a0891b67da22a8b625904467bc05f0ba3ae
BLAKE2b-256 checksum
How to use checksums
753071b8f4e02eb910a02f72351a4cbdd64f39d567f2eaf6a9cfbafdd0309246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

Security for pigen 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page