Infinite and infinitesimal numbers for JAX
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file infnum-0.1.0.tar.gz.
File metadata
- Download URL: infnum-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e00c140c73bb402db3c96cbf2518dc83a354bbbdd1161c00fd20c25df0dbcf5c
|
|
| MD5 |
e69f377508a86752f4847a7aff64cf8f
|
|
| BLAKE2b-256 |
d08a2840b02b2499e2507de68c6627b48ac99e7a31849abd248a2049232b5f31
|
File details
Details for the file infnum-0.1.0-py3-none-any.whl.
File metadata
- Download URL: infnum-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfc63b30d24ba66e26bee32c290696de4ecd1b58b4dce47ffec7e300fa8abb52
|
|
| MD5 |
9e639814b3c6c083d6cde4f5e0c90bfd
|
|
| BLAKE2b-256 |
5abc28e6ff04a6d1c58b7b2bf62af4decc1f57d259ce07e49f6898a2a7045dfc
|