A lightweight library for evaluating mathematical expressions and functions
Project description
pylytic Library
Description
pylytic is a lightweight and flexible Python library designed to facilitate evaluating mathematical expressions and performing calculations efficiently, the pylytic library is focused on the implementation of math methods and evaluation of complex arithemetic expressions. It leverages mathematical algorithms such as CORDIC, INV_CORDIC and Newton-Raphson methods to perform computations. This library is ideal for developers, researchers, and enthusiasts seeking optimized solutions for mathematical operations.
Library Structure
-
pylytic
-
evaluation
- eval.py
-
math_methods
- m_eval.py
-
storage.py
-
extras.py
-
eval.py Evaluates mathematical expressions
m_eval.py Contains mathematical functions
storage.py Stores Constants required for eval and m_eval
extras.py Includes decorator used to validate types passed as arguments to functions
Installation
To install pylytic, simply use pip:
pip install pylytic
eval.py
eval is a module in the pylytic library used to evaluate mathematical expressions.
Feature
- Mathematical expression evaluation: Accurate evaluation of mathematical expressions
Usage
Here is a quick example to get started:
from pylytic import eval
expr_result = eval.eval_complex(expr="1.725 * cosech(log(0.784 + atan(0.459)) + 4P(2)C(7) / 3!) + cot(40) * asec(9.5 * 7 - 5) - -(sinh(1.5) + 2 ^ ln(0.75))",
mode="deg", logarithmic_base=10)
print(expr_result)
expr: represents the expression to be evaluated, expression is strictly of type str
mode: represents the mode in which the expression to be evaluated, defaults to deg (as in degrees), also supports
rad (radians) and grad (gradians)
logarithmic_base: the base in which the expression is to be evaluated, defaults to base 10
m_eval.py
m_eval is a module in the pylytic library which contains mathematical functions
Features
- Trigonometric Evaluations: Efficient computation of sine, cosine, tangent, and their inverses using the CORDIC algorithm.
- Square Root Calculation: High-precision square root evaluation leveraging the Newton-Raphson method.
- Robust Error Handling: Gracefully handles invalid inputs and computational errors.
Usage
Here's a quick example to get started:
Computing Trigonometric Functions
from pylytic import m_eval
result = m_eval.sin(angle=45, mode="rad")
print("Result: ", result)
Computing Hyperbolic Functions
from pylytic import m_eval
result = m_eval.cosech(1.715)
print("Result:", result)
Computing Logarithmic functions
from pylytic import m_eval
logarithm = m_eval.log(x=0.857, base=2.7182818285)
natural_log = m_eval.ln(value=75.5)
print(logarithm, natural_log)
List of functions supported by m_eval
sin, cos, tan, sec, cosec, cot, asin, acos, atan, asec, acosec, acot, sinh, cosh, tanh, sech, cosech, coth, asinh, acosh, atanh, acosech, asech, acoth, log, ln, log10, power, factorial, perm, comb, abs
a: represents arc
perm represents permutation, the format for writing permutation is 5P(2) not 5P2
comb represents combination, the format for writing combination is 5C(2) not 5C2
Explanation of Core Algorithms
CORDIC Algorithm
The CORDIC (Coordinate Rotation Digital Computer) algorithm is a method used for calculating trigonometric functions, hyperbolic functions, and square roots. It operates through iterative rotations to converge on the desired result efficiently.
INV_CORDIC Algorithm
An inverse version of the CORDIC algorithm used for calculating inverse trigonometric functions like arcsine, arccosine....
Newton-Raphson Method
A root-finding algorithm used here for high-precision computation of square roots and more. The method iteratively refines an initial guess to converge on an accurate result.
License
Copyright (c) 2024-present, Adeleke Adedeji
Contributing
Contributions are highly welcomed! If you'd like to add new features or fix bugs, please fork the repository and submit a pull request.
Author
Adeleke Adedeji
Feel free to reach out with questions or feedback!
Contact details: aadeleke91618330@gmail.com.
Future Plans
- Extend support for additional mathematical functions.
- Improve performance for large-scale computations.
- Extension to evaluate matrix operations and vectors.
- Add visualization tools for computational workflows.
Acknowledgments
Special thanks to the mathematicians and computer scientists whose work inspired the algorithms used in this library.
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 pylytic-0.1.0.tar.gz.
File metadata
- Download URL: pylytic-0.1.0.tar.gz
- Upload date:
- Size: 35.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9d8ff2316d6d07d296a25060829533dda985a1e29655de892b3780ffc69e5be
|
|
| MD5 |
1b7a5cb2a2c6fb518e652a4e41efe6a8
|
|
| BLAKE2b-256 |
0e821006038da6732451e05123ba93da9159579f31e8bbe5309a16df554b9868
|
File details
Details for the file pylytic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pylytic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a9b490c2ea5b1d409dacf7996160bb38e9a5849382ad236e81b073b42a47e83
|
|
| MD5 |
9445103515b9d6c57d8d04ca36a36037
|
|
| BLAKE2b-256 |
265c584c6f9aa2825819e88cd4fe38758bc428203b841e8aec7c2d201ad06c27
|