{"id":22375875,"url":"https://github.com/stylewarning/hypergeometrica","last_synced_at":"2026-01-06T14:08:55.528Z","repository":{"id":51312299,"uuid":"204378290","full_name":"stylewarning/hypergeometrica","owner":"stylewarning","description":"Livin' like it's 1813 (or 1988).","archived":false,"fork":false,"pushed_at":"2024-02-26T10:22:50.000Z","size":287,"stargazers_count":32,"open_issues_count":28,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T23:34:10.458Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stylewarning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-26T02:14:10.000Z","updated_at":"2025-02-13T05:11:24.000Z","dependencies_parsed_at":"2023-01-17T20:05:52.838Z","dependency_job_id":null,"html_url":"https://github.com/stylewarning/hypergeometrica","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stylewarning%2Fhypergeometrica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stylewarning%2Fhypergeometrica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stylewarning%2Fhypergeometrica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stylewarning%2Fhypergeometrica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stylewarning","download_url":"https://codeload.github.com/stylewarning/hypergeometrica/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245708990,"owners_count":20659625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T21:28:04.665Z","updated_at":"2026-01-06T14:08:55.488Z","avatar_url":"https://github.com/stylewarning.png","language":"Common Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hypergeometrica\n\nHypergeometrica aims to democratize the calculation of pi to trillions of digits. As of March 2020, the software used to break world-record computations has remained closed source. This has been a 20+ year trend, and includes famous software such as y-cruncher, TachusPI, PiFast, and SuperPi. \n\nPlease watch this [introductory video](https://www.youtube.com/watch?v=XanjZw5hPvE).\n\n```\nCL-USER\u003e (asdf:load-system :hypergeometrica)\nCL-USER\u003e (in-package :hypergeometrica)\n#\u003cPACKAGE \"HYPERGEOMETRICA\"\u003e\nHYPERGEOMETRICA\u003e (compute-pi/ramanujan 100)\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679\nHYPERGEOMETRICA\u003e (compute-pi/chudnovsky 100)\n31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679\nHYPERGEOMETRICA\u003e (compute-e 100)\n27182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274\n```\n\n**Unfortunately**, Hypergeometrica cannot yet calculate pi in a completely *competent* way. What you see above does actually compute pi, but is taking a few very inefficient shortcuts. In order to be efficient, Hypergeometrica needs some additional key routines to eliminate these inefficient shortcuts.\n\n\n## What is the most efficient way to calculate pi with Hypergeometrica?\n\nThe call `(MPD-PI b)` for $b$ bits of precision is the fastest way to compute pi with Hypergeometrica. Here is a call to calculate at least $b=100$ bits of pi.\n\n```\nCL-USER\u003e (in-package :hypergeometrica)\nHYPERGEOMETRICA\u003e (mpd-pi 100)\n\nterms = 4\n[0 Δ0] split\n[0 Δ0] sqrt\n[4 Δ4] recip\n[8 Δ4] final\n#\u003cMPD {10160AD883}\u003e\n```\n\nThis output can be interpreted as:\n\n- `terms = 4` means 4 terms of the Chudnovsky series were calculated.\n- `[x Δy] thing` means `x` milliseconds have elapsed since the start of the computation, and `thing` took `y` milliseconds since the last step\n- `#\u003cMPD {...}\u003e` is the object returned. Currently there is no base conversion routine to actually show this. One can use `mpd-mpfr` to convert it into an MPFR object for viewing or checking (as is done in `hypergeometrica-tests::test-pi`).\n\n\n## What is it?\n\nHypergeometrica is a Lisp library for performing extremely fast, extremely high-precision arithmetic. At the heart of it all are routines for doing fast multiplication. Hypergeometrica aims to support:\n\n- Fast in-core multiplication using a variety of algorithms, from schoolbook to floating-point FFTs.\n\n- Fast in-core multiplication for extremely huge numbers using exact convolutions via number-theoretic transforms. This is enabled by extremely fast 64-bit modular arithmetic.\n\n- Fast out-of-core multiplication using derivatives of the original Cooley-Tukey algorithm.\n\n- Implementation of dyadic rationals for arbitrary precision float-like numbers.\n\n- Elementary automatic parallelization when reasonable.\n\nOn top of multiplication, one can build checkpointed algorithms for computing a variety of classical constants, like pi.\n\n\n## How is it implemented?\n\nIt's a Lisp library that takes advantage of assembly code via SBCL's VOP facilities.\n\nIt would probably be easier to get higher performance quicker in C or C++, but there's a lot of non-hot-loop code (such as calculating suitable primes) that are better served without the baggage of a low-level language.\n\n\n## What works and what doesn't?\n\nThere's a test suite, I recommend looking at that to see what (should be) working. In any case, a short list of features:\n\n- Basic bigint (`MPZ`) routines.\n\n- Basic dyadic rational (`MPD`) routines.\n\n- Code to compute \"suitable primes\" for number-theoretic transforms.\n\n- An in-core number-theoretic transform employing tricks for fast modular arithmetic.\n\n- Binary-splitting for the computation of arbitrary hypergeometric series.\n\n- Out-of-core/disk-based number representation and automatic upgrading, with specialized algorithms.\n\n- In-core computation of pi, with basic asymptotically fast algorithms for division, square root, or inversion.\n\n\nAn implementation of disk-backed bigints exists, but it's not vetted and I'm not sure it's a good architecture.\n\nThere's also a broken implementation of out-of-core multiplication called the \"matrix Fourier algorithm\" following Arndt. Some corner case isn't working, and I'm not even sure this is the best way to do out-of-core multiplication.\n\n\n## Can I contribute?\n\nPlease, yes. Even if it's just telling me to document something. File an issue!\n\n\n## I know a lot about {I/O, disks, computer arithmetic, assembly, SBCL, ...} but I'm not really interested in rolling up my sleeves for this project.\n\nPlease contact me so I have somebody to ask questions to!\n\n\n## Where can I learn more about arbitrary precision arithmetic?\n\nI'm keeping a [list of references](REFERENCES.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstylewarning%2Fhypergeometrica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstylewarning%2Fhypergeometrica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstylewarning%2Fhypergeometrica/lists"}