arctans
arctans is a library for manipulating arctans to generate Machin-like formulae and other formulae involving arctans.
Installing arctans
Installing from PyPI using pip
The latest release of arctans can be installed by running:
pip3 install arctans
Installing from source using pip
arctans can be installed by running:
pip3 install git+https://github.com/mscroggs/arctans.git
Testing arctans
To run the arctans unit tests, clone the repository and run:
python3 -m pytest test/
Using arctans
arctans can be used to represent arctans and sums of arctans symbolically and generate arctan sums equivalent to a given set of sums.
For example, Machin's formula for pi (pi = 16arctan(1/5) - 4arctan(1/239)) can be created with:
from arctans import arctan, Rational
pi = 16 * arctan(Rational(1, 5)) - 4 * arctan(Rational(1, 239))
print(pi)
print(float(pi))
Or equivalently:
from arctans import arccotan
pi = 16 * arccotan(5) - 4 * arccotan(239)
print(pi)
print(float(pi))
As arccotangents of integers commonly appear in formulae for pi, when printing
formulae represented using arctans, the shorthand notation [n] will be used
to represent arccotan(n).
Once a formulae is expressed, new formulae that have the same value can be generated
using the generate function, for example:
from arctans import arccotan, generate
pi = 16 * arccotan(5) - 4 * arccotan(239)
formulae = generate([pi])
for f in formulae:
print(f)
This will print a number of different arctan sum formulae, including
16*[4] + -16*[21] + -4*[239] (ie pi = 16arctan(1/4) - 16arctan(1/21) - 4arctan(1/239)).
Further documentation
More detailed documentation of the latest release version of arctans can be found on
Read the Docs. A series of example uses
of arctans can be found in the demo folder or viewed on
Read the Docs.
Getting help
You can ask questions about using arctans by using GitHub Discussions. Bugs can be reported using the GitHub issue tracker.
Contributing to arctans
Reporting bugs and suggesting enhancements
If you find a bug in arctans and want to report it, or if you want to suggest a new feature or an improvement of a current feature, please open an issue on the issue tracker.
Submitting a pull request
If you want to directly submit code to arctans, you can do this by forking the arctans repo, then submitting a pull request. If you want to contribute, but are unsure where to start, have a look at the issues labelled "good first issue".
On opening a pull request, unit tests and ruff and mypy style checks will run. You can click on these in the pull request to see where (if anywhere) there are errors in your code.
Code of conduct
We expect all our contributors to follow the Contributor Covenant. Any unacceptable behaviour can be reported to Matthew (arctans@mscroggs.co.uk).
Metadata
Release files for arctans 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| arctans-1.0.0.tar.gz | 13.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| arctans-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / arctans-1.0.0.tar.gz
| Download URL | arctans-1.0.0.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
592fa1ebd802a2d1c7c194e6001f9ffc4695693bb10f697da38b3d6515052971
|
|
BLAKE2b-256 checksum How to use checksums |
5474e21aa6534d472a17cde7132be60e6d56a37da31cd76d0fcaf9499df4a5f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 16, 2025.
Transparency logRelease files / arctans-1.0.0-py3-none-any.whl
| Download URL | arctans-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1eeab8e5f264c9669ee858a3e90cb4f7a0c1b4776e29776c5f77cde0b5d444a4
|
|
BLAKE2b-256 checksum How to use checksums |
72770c15db4ae23d1ed4d17f15c42a476a4df4df368bdc6c0df172b559108c10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 16, 2025.
Transparency logSecurity for arctans 1.0.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for arctans-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 16, 2025.
Transparency logA 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.