Skip to main content

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)

Source distribution for infnum 0.2.0
File Size Uploaded
infnum-0.2.0.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for infnum 0.2.0
File Interpreter ABI Platform
infnum-0.2.0-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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