Skip to main content

KCExpr for Python

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

Metadata

Release files for KCExpr 1.0.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 KCExpr 1.0.0
File Size Uploaded
KCExpr-1.0.0.tar.gz 8.9 kB Details

Built distribution (wheel)

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

Total release size: 16.5 kB

Release files / KCExpr-1.0.0.tar.gz

Download URL KCExpr-1.0.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1ef7d4dfa08b9fba3da4db8eda4359b06269c1622277060b26cb9702b8d78a21
BLAKE2b-256 checksum
How to use checksums
f9352481ed797071ee977f5559ec8ba92b2c6834a2eaf93c1d5537f3995186ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.7

Release files / KCExpr-1.0.0-py3-none-any.whl

Download URL KCExpr-1.0.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d4ae66e26878e57312dcfcfbcfdaf21ff7ea9a03dcd7e8dc8758a68851301e1
BLAKE2b-256 checksum
How to use checksums
b12329885f555c365712dcc63b48467fc4f7bd97846bc51923488a18486e1bdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.1

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