Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 122 additions & 3 deletions libmath/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ We support the following functions and special functions:
- `++factorial`, $!$ factorial
- `++abs`, $\text{abs}$
- `++exp`, $\exp$
- `++expm1`, $\exp - 1$
- `++sin`, $\sin$
- `++cos`, $\cos$
- `++tan`, $\tan$
Expand All @@ -35,9 +36,9 @@ Logical functions:
- `++gte`, $\geq$ (also `++geq`)
- `++equ`, $=$
- `++neq`, $\neq$
- `is-close`
- `all-close`
- `is-int`
- `++is-close`
- `++all-close`
- `++is-int`

Constants (to machine accuracy):

Expand Down Expand Up @@ -67,3 +68,121 @@ It would be nice to have the following special functions as well:
We do not envision including the Bessel functions and other more abstruse functions.

We use naïve algorithms which are highly reproducible. We special-case some arguments to make them tractable without catastrophic cancellation.

---

# `/lib/unum` for Urbit

A library for universal numbers (posits, quires, and valids) per the Gustafson (2019) formulation and the 2022 Posit Standard.

- $\text{posit}<8,0>$
- $\text{posit}<16,1>$
- $\text{posit}<32,2>$

## Posit Standard Compliance

Two interfaces are maintained for `/lib/unum`: one to hew to the `/lib/math` and `/lib/saloon` interface, and another to alias in the 2022 Posit Standard requirements. The names are slightly modified from the standard to adhere to Hoon name requirements.

### Basic functions of one posit value argument

- `++negate` ← `(sub 0 val)`
- `++abs` ← no change
- `++sign` ← `++sgn`
- `++nearest-int`
- `++ceil`
- `++floor`
- `++next`
- `++prior`

### Comparison functions of two posit value arguments

- `++compare-equal` ← `++equ`
- `++compare-not-equal` ← `!(equ val)`
- `++compare-greater` ← `++gth`
- `++compare-greater-equal` ← `++gte`
- `++compare-less` ← `++lth`
- `++compare-less-equal` ← `++lte`

### Arithmetic functions of two posit value arguments

- `++addition` ← `++add`
- `++subtraction` ← `++sub`
- `++multiplication` ← `++mul`
- `++division` ← `++div`

### Elementary functions of one posit value argument

- `++sqrt` ← no change
- `++rsqrt` ← TODO
- `++exp` ← no change
- `++exp-minus-1` ← `++expm1`
- `++exp2` ← no change
- `++exp2-minus-1` ← `++exp2m1`
- `++exp10` ← no change
- `++exp10-minus-1` ← `++exp10m1`
- `++log` ← no change
- `++log-plus-1` ← `++logp1`
- `++log2` ← no change
- `++log2-plus-1` ← `++log2p1`
- `++log10` ← no change
- `++log10-plus-1` ← `++log10p1`
- `++sin` ← no change
- `++sin-pi` ← `(sin (mul pi val))`
- `++cos` ← no change
- `++cos-pi` ← `(cos (mul pi val))`
- `++tan` ← no change
- `++tan-pi` ← `(tan (mul pi val))`
- `++arcsin` ← no change
- `++arcsin-pi` ← `(arcsin (div val pi))`
- `++arccos` ← no change
- `++arccos-pi` ← `(arccos (div val pi))`
- `++arctan` ← no change
- `++arctan-pi` ← `(arctan (div val pi))`
- `++sinh` ← no change
- `++cosh` ← no change
- `++tanh` ← no change
- `++arcsinh` ← no change
- `++arccosh` ← no change
- `++arctanh` ← no change

### Elementary functions of two posit value arguments

- `++hypot` ← `(sqt (mul val-1 val-1) (mul val-2 val-2))`
- `++pow` ← no change
- `++arctan2` ← ??? complex
- `++arctan2-pi` ← `(div (arctan2 val) pi)`

### Functions of three posit value arguments

- `++fmm` ← `:(mul val-1 val-2 val-3)`

### Functions of one posit value argument and one integer argument

- `++compound` ← `(pow (add val 1) int)`
- `++root-n` ← `(pow val (div 1 int))`

### Functions involving quire value arguments

- `++p-to-q`
- `++q-negate`
- `++q-abs`
- `++q-add-p`
- `++q-sub-p`
- `++q-add-q`
- `++q-sub-q`
- `++q-mul-add`
- `++q-mul-sub`
- `++q-to-p`

### Conversions between different precisions

- `++p8-to-16`
- `++p8-to-32`
- `++p16-to-8`
- `++p16-to-32`
- `++p32-to-8`
- `++p32-to-16`

### Conversions between posit format and decimal format

### Conversions between posit format and IEEE 754 format
Loading