a mathematician's spellbook
Project description
daamath
a mathematician's spellbook: cross-language math library specification, with implementations across various programming languages
install
| python | python -m pip install daamath |
| c | … |
| c++ | … |
| javascript | … |
| julia | … |
| … | … |
why?
"does integer division do floor rounding or trunc rounding?"
"why does pow(2, 3) return a float? i expected an int"
"why do i have to know powf, pow and powl in C? cant they just make one pow?"
"i know my int is even so i divide it by 2. why did you promote it to a float? its still supposed to be an int!"
"i wish i could translate my math code from C to Python but it gives me different results"
"why is there no log(num, base) in C?"
"but log(-1) is defined in the complex numbers. you mean i have to use clog for that? log should be able to do that if i pass a complex number"
"why is it log(num, base) in python but log(base, num) in julia?"
"why were my calculations wrong? is log base 10 or base e?"
"where is acot(x)??? how do i make acot from atan??"
"where is nand(x, y)? not (x and y) is so unnecessary"
"i wish this math library had the golden ratio constant"
this is very ugly to me. so i made daamath.
features
- cross-language consistency: daamath is designed to behave the same across languages.
- true functions: faithful to the mathematics, you can define the domain, codomain, and mapping of functions. for example, an integer divided by an integer can be set to return either an integer or rational number
- complete function sets: hyperoperations to n=4, trigonometry in all 2 non-degenerate geometries, all non-degenerate boolean gates to arity 2, all 16 derived functions per relation, 12 rounding functions, …
- clean namespace: no aliases, datatype naming conventions, underscore-binding, …
- unicode characters: math-related unicode characters, presented in an elegant tree
- mathematical constants: e, π, τ,
- documentation website
examples
for our python examples, first import daamath as dm
# by default, daamath does complex arithmetic in f64:
dm.log(-5, 2)
# 4.532360141827194j
# you can do integer arithmetic with floats
dm.context.div.codomain = dm.domains.INTEGER
dm.div(5, 2)
# CodomainViolation: div(float 5, float 2) returned float 2.5 ∉ INTEGER
# create your own domains
NONZERO_REAL = lambda x: dm.REAL(x) and x != 0
NONZERO_REAL(1.0)
# True
NONZERO_REAL(0)
# False
# you can do matrix arithmetic naturally:
dm.context = dm.contexts.matrix
dm.mul([1,2,3], [2,3,4])
# 20
you also have cool tidbits like this:
dm.PI_F64 - dm.PI_F32
#
dm.symbols.lowercase.tau
# τ
dm.symbols.infinity + dm.symbols.not.in.right + dm.symbols.latin.doublestruck.uppercase.r
# ∞ ∉ ℝ
Project details
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 daamath-0.5.2.tar.gz.
File metadata
- Download URL: daamath-0.5.2.tar.gz
- Upload date:
- Size: 368.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74c7f1927871101a51f7231b0989928de2d6e8df8b3939d299cbd46c06f514c4
|
|
| MD5 |
983aa0c3d2cbe2c84a1559563b5cc821
|
|
| BLAKE2b-256 |
ffc8eeff502739b3264d6c72f5f09cb2a443a90dc04857a8e245e1135217830f
|
File details
Details for the file daamath-0.5.2-py3-none-any.whl.
File metadata
- Download URL: daamath-0.5.2-py3-none-any.whl
- Upload date:
- Size: 54.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a14661e910c4e1d62983986307bb6257424d3122a1b02fa9ee22f54f9d3f9713
|
|
| MD5 |
70b27c9e890ed183b7999aaa5b0c5f1d
|
|
| BLAKE2b-256 |
ca1e49586e75ba49e2d6fd277067fcf052ae9dce594e5adf3be7b613c7cd4fa3
|