daamath
daamath is a cross-language math library specification, with implementations in various programming languages:
| python |
python -m pip install daamath
|
examples
import daamath as dm
sin = dm.sin.binary64.nearesteven
pi = dm.archimedes.binary64.nearesteven
approx = dm.tilde_tilde
print(dm.ellinika.lower.pi, approx, pi)
# π ≈ 3.141592653589793
print(sin(pi), approx, 0)
# 1.2246467991473532e-16 ≈ 0
features
it provides four useful things in math:
- characters: +, −, ×, ÷, =, %, …
- constants: π, e, φ, √2, i, γ, …
- datatypes: binary64, int32, uint8, bool, complex128, decimal64, …
- functions: sin, log, abs, pow, sqrt, round, …
since it must behave the same in different programming languages, it has some rules:
- no hidden assumptions
- no object-oriented programming
- no impure functions/mutation/side effects
- no keyword arguments
- no optional arguments
- no stateful behaviour
- functions are defined mathematically, not algorithmically
- names are snake_case and start with a letter
to do
- ≈ 25 / 100 math constants implemented
- rename each constant's nearest and residual to nearesteven and residual
- document datatypes
- analyze numerically favourable formulae for complex trig functions
- explore unicode for more interesting characters