daamath
daamath is a cross-language math library specification. it is geared for scalar numerical computation, and provides various datatypes, functions, constants. it has implementations in various programming languages:
| python |
python -m pip install daamath
|
example
import daamath as dm
sin = dm.sin.binary64.nearesteven
pi = dm.archimedes.binary64.nearesteven
print(sin(pi))
# 1.2246467991473532e-16
rules
- no implicit type conversion
- no implicit return type
- no mathematical assumptions
- no object-oriented programming
- no impure functions/mutation/side effects
- no keyword arguments
- no optional arguments
- no stateful/contextual/environmental/variable behaviour
- functions are defined mathematically, not algorithmically
- names are snake_case and start with a letter
influences
- architecture is based on set theory, universal algebra, type theory
- IEEE 754 arithmetic
- conventions were taken from C and Python
- trig functions are based on DLMF and William Kahan
exclusions
- no linear algebra (vectors, matrices, …): there are other better specifications like BLAS, LAPACK
- no hypercomplex algebra besides ℂ since the field of complex numbers is algebraically closed
- no geometric algebra: too specialized for general-purpose computation
- no container datatypes (aarrays, sets, dictionaries, …): they are better specified algorithmically, not numerically
- no symbolic computation: there are other better tools like sympy
to do
- ≈ 50 / 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
- document each function
rant
my favourite thing about a computer is that its deterministic. it does exactly what you tell it to do. but when the computer starts making assumptions (like the ones that programmers make), it starts behaving unpredictably. thats why everything is so explicit. assumptions break the thing that make computers computer-y. thats also why theres no random module in daamath. its an algorithmic thing, and is also (ideally) deterministic. anyway, ye