A small mathematics package including an expression parser
Project description
KCExpr allows for the parsing of mathematical expressions as strings. KCExpr currently supports 27 mathematical functions, such as summation, products, and trigonometric functions, as well as supporting 37 mathematical constants, such as pi, e, and the golden ratio.
In all cases of KCExpr, the implementation structure is relatively similar. Firstly, declare an object of the KCExpr() class. Next, set the expression of that object. Finally, parse the object. The code blocks below highlight this process, both for single and multiple objects.
Basic implementation
import KCExpr.KCExpr as kce
p = kce.KCExpr()
p.set_expr("1 + 2")
result = p.parse()
print(result) # prints "3" to the console
Further implementation
import KCExpr.KCExpr as kce
p1, p2 = kce.KCExpr(), kce.KCExpr()
p1.set_expr("1")
p2.set_expr("2")
p3 = p1 + p2
result = p3.parse()
print(result) # prints "3" to the console
Mathematical functions parsable by KCExpr
The syntax for functions can be found in the docs folder (see GitHub). The following is a list of functions included in the KCExpr class.
abs, sqrt, root, ncr, npr, sigma, pi, ln, log, sin, sina, csc, sinh, csch, sinha, cos, acos, sec, cosh, sech, cosha, tan, atan, cot, tanh, coth, tanha.
Using mathematical constants in KCExpr
The syntax for mathematical constants can be found in the docs folder (see GitHub). The following is a list of constants included in the KCExpr class.
Constant |
Code |
---|---|
Pi |
pi |
Euler’s Number |
e |
Euler–Mascheroni constant |
em |
The golden ratio |
golden |
Meissel-Mertens constant |
mm |
Bernstein’s constant |
bernstein |
Gauss-Kuzmin-Wirsing constant |
gkw |
Hafner-Sarnak-McCurley constant |
hsm |
Omega constant |
omega |
Golomb-Dickman constant |
gd |
Cahen’s constant |
cahen |
The twin prime constant |
tp |
The laplace limit |
laplace |
Embree-Trefethen constant |
et |
Landau-Ramanujan constant |
lr |
Brun’s constant for prime quadruplets |
brunpq |
Brun’s constant for prime twins |
brunpt |
Catalan’s constant |
catalan |
Viswanath’s constant |
viswanath |
Apéry’s constant |
apery |
Conway’s constant |
conway |
Mills’ constant |
mills |
The plastic number |
plastic |
Ramanujan-Soldner constant |
rs |
Backhouse’s constant |
backhouse |
Porter’s constant |
porter |
Lieb’s square ice constant |
lieb |
Erdős–Borwein constant |
eb |
Niven’s constant |
niven |
The universal parabolic constant |
upc |
Feigenbaum’s α constant |
feigenbauma |
Feigenbaum’s δ constant |
feigenbaumd |
Sierpinski’s constant |
sierpinski |
Khinchin’s constant |
khinchin |
Fransén–Robinson constant |
fr |
Lévy’s constant |
levy |
The reciprocal Fibonacci constant |
rf |
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
File details
Details for the file KCExpr-1.0.0.tar.gz
.
File metadata
- Download URL: KCExpr-1.0.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ef7d4dfa08b9fba3da4db8eda4359b06269c1622277060b26cb9702b8d78a21 |
|
MD5 | 5b777a83a6b7a081a580db77d8028338 |
|
BLAKE2b-256 | f9352481ed797071ee977f5559ec8ba92b2c6834a2eaf93c1d5537f3995186ad |
File details
Details for the file KCExpr-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: KCExpr-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d4ae66e26878e57312dcfcfbcfdaf21ff7ea9a03dcd7e8dc8758a68851301e1 |
|
MD5 | 4d35ffdc2760b2fda02537de3cb621cb |
|
BLAKE2b-256 | b12329885f555c365712dcc63b48467fc4f7bd97846bc51923488a18486e1bdd |