infnum
infnum is a Python library that provides infinite and infinitesimal numbers using the Levi-Civita Field. It uses JAX under the hood.
Installation
You can install infnum via pip:
pip install infnum
Usage
Creating Levi-Civita Numbers
The main constructor expects a dictionary with numerical keys and values. The keys represent the exponents and the values the coefficients. In the following example, note that ε⁻³ is an infinite number.
from infnum import LeviCivitaNumber
# Create a Levi-Civita number from a real number
num = LeviCivitaNumber.from_number(5.0) # 5.0
print(num) # Output: 5.0
# Create a Levi-Civita number with infinitesimal parts
num = LeviCivitaNumber({0: 1.0, 1: 2.0, 2: 3.0, -3: 4.0}) # -4.0ε⁻³ + 1.0 + 2.0ε + 3.0ε²
print(num) # Output: -4.0ε⁻³ + 1.0 + 2.0ε + 3.0ε²
Operations
Levi-Civita numbers support arithmetic operations like addition, subtraction, multiplication, and division. Division is truncated to 8 terms by default since it may result in an infinite series, but the higher terms are infinitesimal with respect to the lower terms.
You may compare Levi-Civita numbers using the <, <=, >, >=, ==, != operators, which considers the lexicographical order of the coefficients.
Testing
Levi-Civita numbers come with unit tests to ensure correctness. You can run the tests using:
python -m unittest discover tests
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the Apache 2 License.
TODO
- add complex number support
- support non-integer powers for non-pure terms
Metadata
Release files for infnum 0.2.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 | Actions |
|---|---|---|---|---|
| infnum-0.2.0.tar.gz | 14.4 kB | Without provenance | Details for infnum-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| infnum-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for infnum-0.2.0-py3-none-any.whl |
Total release size: 20.2 kB
Release files / infnum-0.2.0.tar.gz
| Download URL | infnum-0.2.0.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c3beb47712349f5558434df0d588be2406aac60461b3307e52fcc5fdec9b4cb
|
|
BLAKE2b-256 checksum How to use checksums |
83ef4de2d178520660747c82d590a3808501bb9a766abc122b303a690ed267fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / infnum-0.2.0-py3-none-any.whl
| Download URL | infnum-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8493656814be2bb2cc1176b55c59fd398c79fd80eae6256e4a135330e34a3ba
|
|
BLAKE2b-256 checksum How to use checksums |
61cc6235ee0af2bef815e01fe81515ff3a2e66d2b0597c17809bf4da5394bfe3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for infnum 0.2.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.
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.