Skip to main content

Crate rustymath_core

Crate rustymath_core 

Source
Expand description

Maths in plain Rust. Its float functions take f16, f32 and f64, each within 4 units in the last place (ulps) of the correctly rounded result. The README lists the functions with wider bounds. The crate also has APL’s tolerant comparison, exact rationals, linear algebra, number theory and polynomials. Its Python functions evaluate eagerly and return Rustymath arrays or Python scalars.

Re-exports§

pub use slice::Arg;
pub use slice::Binary;
pub use slice::CHUNK;
pub use slice::Flipped;
pub use slice::KernelItem;
pub use slice::Results;
pub use slice::Ternary;
pub use slice::Unary;
pub use slice::Wrapped;
pub use slice::pairs;
pub use half;
pub use num_complex;

Modules§

agreement
Broadcasting: pairing the axes of two layouts, and reading each argument’s items in the order of the result.
array
Borrowed array storage, layouts and positional reads.
buffer
Compact buffers: owned items of one element type, borrowed views of them, and the DType that names each. Booleans take one byte each. Integers come in four widths, floats in three and complex numbers in two, named by the width of their parts. Source reads an item of one element type as another.
characters
Character arithmetic uses ordinary numerical kernels on borrowed Unicode code points. Numbers order before characters.
convert
Conversions between floats and integers whose loops vectorize on every target. AVX2 and wasm have no vector instruction for converting between f64 and a 64-bit integer. AArch64 converts bytes to floats two lanes at a time. A loop that converts such types with as runs one item at a time on those targets. int and float convert them through a float’s bits. They use the conversion instruction for types that every target converts in vector form, and for 64-bit integers where the target can. count writes runs of whole numbers as floats. Where the target can’t convert 64-bit integers in vector form, it converts one item in 8. saturated also converts big integers and u64s, saturating them at an integer type’s range.
derivative
Partial-derivative recipes shared by Formula rows. They use Ops on the original arguments and result. Slope presents a selected partial as another formula. A masked case keeps discarded intermediate values finite before selecting the slope.
distribution
Probability distributions. Each has a density, a cumulative distribution, a quantile function and a sampler. The first three are also function objects, Pdf, Cdf and Quantile, which hold the distribution. Their slice forms choose the distribution’s formulas once, outside the loop, so the loops of the closed-form distributions vectorize. Their one-item forms run the slice forms on one item. An item of a slice form fails where its result is NaN and its argument isn’t, as for a quantile of p outside 0 to 1. A discrete distribution’s density is its mass at a whole x, and its quantile function and sampler give whole numbers.
domain
What a kernel computes over: a call’s dtype and overflow policy (Variant), and the values that an argument or a result can take (Range). Formulas (facts), recipes and kernels read both.
error
Errors from rustymath’s functions on arrays. Each error has a kind, and a message that says what went wrong.
events
Producer events shared by BPL’s •explain and rustymath’s Python explain. Capture is process-wide, including workers, with nesting on one thread. Payloads own their diagnostic data and never retain runtime values.
exact
Exact numbers: rationals of any integer type, such as BigRational, which is Ratio<BigInt>. These functions give exact results, where the float functions round. linalg::exact solves matrices of them, polynomial evaluates polynomials with them, and number_theory works on whole numbers.
facts
Shared function definitions for numerical frontends. Each Formula row owns its kind and character policies, numerical body, validity and repair predicates, ranges, identities, partial derivatives and exact cases. rustymath::operation::Kernel erases the arity for execution. facts! lists typed product pairs and Python names.
fused
rustymath’s functions with mla fused, whatever the target’s FUSED. Code compiled with FMA enabled for itself, such as an AVX2 version of a loop chosen when the program runs, calls these on a target whose baseline lacks FMA.
gather
Copying the items of a slice into a buffer by position: repeating each, keeping those a mask selects, taking them at indices, walking an n-dimensional pattern of offsets over them, and writing them at offsets. positions writes the positions that a mask selects. Each applies a conversion to each item it writes, so a caller can widen items as it gathers them. Most are generic and #[inline], so they compile in the caller, with the caller’s types and conversion. walk and scatter_walk instead compile their walk once for each item type, and run any other conversion as a separate contiguous pass. Their fixed-width loops move Units, which compile once for each size of item. Booleans and integers convert into f64 through fixed-width loops of their own as they write (Item::cells_from).
hashing
The hash maps and sets rustymath uses. Hashing is foldhash’s fast hasher with its fixed seed (FixedState), with hash_one marked #[inline(always)]. With one seed in every process, maps hash and iterate alike between runs, and instruction counts repeat. hashbrown 0.17 hashes every key through BuildHasher::hash_one, and core’s default body for it has no inline hint, so incremental builds can call it out of line on every lookup.
integer
Functions of i64s: greatest common divisor, least common multiple, binomial coefficients, powers, square roots and residues. Each gives None where its result isn’t an i64. Their function objects are the ones that floats and complex numbers use: Gcd, Lcm and Residue from tolerant, whose integer forms ignore the tolerance they hold, and Binom and Pow. A slice form appends results to a vector and reports whether every item fitted. Divisor divides many integers by one, with multiplications in place of division instructions. Where every item has the same divisor, Residue’s slice form divides through FloatDivisor, which multiplies by the divisor’s reciprocal in f64 and vectorizes, for divisors and dividends below 2⁵¹ in magnitude. At types of 16 bits or fewer it multiplies 32-bit integers instead, and it takes Divisor for 64-bit dividends of 2⁵¹ or more.
interrupt
The process’s interrupt check. Long computations call check between steps, about every BETWEEN_CHECKS items, and stop with its error. A frontend installs its check with install: basedpl’s stops the running evaluation at an interrupt or a passed deadline, and rustymath’s Python bindings’ raise the exception of a pending signal. Until a frontend installs one, check passes.
layout
Array shapes, axis keys and names, and their limits.
linalg
Inner products of row-major matrices. The inner product f.g of an m×k matrix a and a k×n matrix b is the m×n matrix whose item at row i and column j folds f over g(a[i][p], b[p][j]) for each p. +.× is the matrix product. The specialized pairs have associative f, and their loops combine its steps in whatever order suits them. A float result can therefore differ in its last bits from a fold taken in order. inner_with runs other native pairs through bounded term blocks and a caller’s right fold, which preserves the association of non-associative functions.
memory
The process’s memory guard. A binary that registers Guard as its global allocator counts the bytes it holds in large allocations, of at least LARGE bytes each. The process’s limit is half of physical memory, unless set_limit sets another. The guard refuses an allocation that would take its count past the limit. It writes one line to stderr naming the limit. Rust then aborts the process, before the machine runs out of memory. Before a function makes an array, generated_len asks admit, which gives a Limit error where the array would pass the limit. peak_held gives the most bytes that a call held at once, which the speed tests count in a case’s footprint. On Linux, the guard also asks the kernel for transparent huge pages for each allocation of at least 4 MiB. The kernel gives them where /sys/kernel/mm/transparent_hugepage/enabled is madvise or always. Without huge pages, each 4 KB page of a new block pays a page fault on its first write. On some hosts those faults take several times as long as the elementwise work that fills the block. basedpl’s bpl, Python extension, browser build, reference test and speed test register the guard, as do rustymath’s Python extension and speed test. set_checks turns on test-only checks: of the size that each free of a large block passes, and, in basedpl’s reference and speed tests, of held after each case. A binary that doesn’t register it counts nothing. There, admit refuses only an array that alone would pass the limit.
number_theory
Number theory on unsigned integers: primality, factorisation, next and previous primes, Euler’s totient, and the enumeration and counting of primes.
optimize
Minimizing a function of several variables, and solving equations, nonlinear or linear.
parallel
Splitting work across threads. [pieces] cuts a call’s items into pieces of the sizes its caller gives, and ranges into as many pieces as the time of its first unit justifies. The pieces run on a Rayon pool with Rayon’s default number of threads: RAYON_NUM_THREADS where it’s set, and otherwise one for each core. set_threads changes that number for the whole process. A call made on one of a pool’s threads, such as a function that another call’s piece runs, doesn’t split again. In the browser build, which has no threads, every call runs its pieces in turn on the calling thread.
polynomial
Polynomials of one variable. A polynomial is the slice of its coefficients in ascending order, so c stands for c[0] + c[1]x + c[2]x² + …. Trailing zero coefficients don’t count towards the degree. evaluate therefore never multiplies an infinite x by one of them. from_roots, derivative, value and factored check for an interrupt between roots, or between groups of BETWEEN_CHECKS coefficients or roots, and return its error as soon as they get one, as linalg::exact’s functions do. A call too short for a second group makes no check, so evaluating a short polynomial at each of many points costs no checks.
random
Random sampling from counter streams. Each call reads one ChaCha8 stream selected by a key and stream number. Item k reads its first w words at position k*w, and rejection sampling uses that item’s separate region. Floats, rolls and distribution samplers share this word addressing.
recipe
Formulas that rustymath’s kernels compute and basedpl’s JIT compiles, each written once over the operations it uses (Ops): tolerant closeness, comparison (each item, or through the range of floats equal to one number), floor, ceiling and the residue; Mathish division, sign, the reciprocal and π’s two forms; and the powers that Exponent routes off the general route, with the square root they take for halves. Floats runs a recipe on floats, as the kernels do. A compiler’s Ops records the same operations as steps, so both routes round alike, step for step.
reduce
Reductions and scans over a contiguous slice: sums, products, maximums and minimums, and their running versions. Each compiles inside rustymath once for each item type. A float sum or product may combine the items in any order, which lets its loop vectorize, so its last bits can differ from a sum taken item by item. Beside NaN, a float maximum or minimum gives NaN or the greatest or least of the items that aren’t NaN, and never any other number. Which of the two it gives can depend on the target and the loop. An empty slice gives -∞ or ∞. f16 items compute in f32. Their sum or product is an f32 total. An integer sum or product computes at i64, or at u64 for u64 items. Where it doesn’t fit, it wraps, and reports that it doesn’t fit, as the running versions do.
search
Search and sort over slices of keys. A key is an item read as a whole number (Key), or an unsigned word whose order is the order you want (RadixKey). Float::order_key gives each float such a word, as wide as the float. Positions take 32 bits inside these functions, so a slice holds at most u32::MAX items. tolerant builds its searches over floats on these functions.
signal
Correlations and convolutions, which slide a kernel along an array’s leading axes, and overlap-add, which adds windows back where they were read.
slice
Slice forms of rustymath’s functions. Each function object, such as [Pow], has a scalar form one and a slice form many. Both run code that rustymath compiles once for each item type, inside its own crate. A caller’s build settings can’t change that code, and rustymath’s speed test times what callers run. An edit to a function’s body rebuilds only rustymath.
stats
Statistics through the shared reductions and matrix products. Means and norms use the ordinary parallel folds. Variance makes two passes, without an array-sized buffer of deviations. No compensated sums or reproducibility rules are imposed.
structure
Plans for structural operations: take and drop, rotate and reverse, windows, transpose and catenate. A plan gives the result’s layout, and Steps that read the result’s items from the argument’s items in order. gather::walk copies a compact array by a plan, and basedpl copies its other arrays by the same plan. Each plan checks its arguments.
tolerant
Tolerant comparison of floats: x equals y within a relative tolerance t when |x-y| is less than t times the larger of |x| and |y|. APL’s definition says at most, which differs only where |x-y| lands exactly on that bound. Dyalog APL calls t the comparison tolerance, ⎕CT, and its default is 1e-14. A tolerance has no effect when either number is zero.
unfused
rustymath’s functions with mla unfused, whatever the target’s FUSED.

Macros§

function_doc
Each function’s doc by its name, as function_doc!(ln), with its lines joined by newlines.
with_complex_width
with_complexes
with_dtype
Runs the body with its type name standing for the element type of the dtype.
with_float_width
with_floats
with_inexact
Runs $body with $t standing for the element type of $dtype, a computing dtype that DType::inexact gives: a 32- or 64-bit float, or a complex number. Any other dtype panics.
with_int_pair
Runs $body with $x and $y bound to the integers of $a and $b at one width: their own when they share it, and otherwise both widened to 64 bits.
with_ints
with_reduce
Runs $body with the type $t standing for the reduction that $r (a Reduce) names.
with_tolerance
Runs $body with $t bound to Exactly when the Tolerance $tolerance is 0, and to the tolerance otherwise. Each binding has its own compiled copy of $body. The choice happens once, outside any loop in $body.
with_width

Structs§

Abs
|x|, or the magnitude |z| of a complex z, which is real, as a function object.
Acos
acos as a function object.
Acosh
acosh as a function object.
Add
x + y.
Angle
The angle from the positive real axis, from -π to π, as a function object. It is real for complex items too. A real x has angle 0, or π where its sign bit is set, as the angle of x + 0i is.
Asin
asin as a function object.
Asinh
asinh as a function object.
Atan
atan as a function object.
Atan2
atan2 as a function object.
Atanh
atanh as a function object.
Beta
beta as a function object.
Betainc
betainc as a function object.
BetaincAt
The regularized incomplete beta CDF with shape parameters a and b fixed.
Betaincinv
betaincinv as a function object.
Binom
binom as a function object.
BinomDk
binom_dk as a function object.
BinomDn
binom_dn as a function object.
BitAnd
Bitwise AND, or logical AND of Booleans.
BitOr
Bitwise OR, or logical OR of Booleans.
Bitwise
bitwise with the truth table it holds, as a function object. One argument is the second, with 0 as the first. Booleans and the signed types hold every result, because each leading sign bit takes the same entry of the table. An unsigned byte computes at i64, where its leading zeros can become ones, and fails where the result doesn’t fit.
Cbrt
cbrt as a function object.
Choose
x where m is nonzero and y where it’s zero, item by item: a select, with the mask m as lanes of the items’ type.
Cis
e^(iz), the cis of z, as a function object, which is cos z + i sin z for a real z. It takes real and complex items.
Clip
Clipping x between lower and upper bounds in one pass: minimum(upper, maximum(lower, x)). A lower bound above the upper one gives the upper. A NaN argument gives NaN, x or a bound, depending on the target.
Conj
The complex conjugate, with a real number unchanged.
Cos
Cosh
cosh as a function object.
Digamma
digamma as a function object.
Divide
x ÷ y, at every float and complex type. Complex numbers divide by divide.
Erf
erf as a function object.
Erfc
erfc as a function object, with the slice form many, which runs erfc_blocks on a slice.
Erfcinv
erfcinv as a function object, with the slice form many, which runs regions on a slice of f64s.
Erfinv
erfinv as a function object.
Exp
exp as a function object.
Expm1
expm1 as a function object.
Factorial
factorial as a function object.
Gamma
gamma as a function object.
Gammainc
gammainc as a function object.
Gammaincc
gammaincc as a function object.
Gammaincinv
gammaincinv as a function object.
Hypot
hypot as a function object.
Imag
The imaginary part of a number, zero for a real number.
Isfinite
Whether every part of a number is finite.
Isinf
Whether a number has an infinite part.
Isnan
Whether a number has a NaN part.
LambertW
lambertw as a function object.
LeftShift
Left shift, discarding high bits. A negative count shifts right, and a count at least the item width saturates to 0.
Lgamma
lgamma as a function object.
Ln
ln as a function object.
Log2
log2 as a function object.
Log1p
log1p as a function object.
Log10
log10 as a function object.
Logb
logb as a function object.
MathishDivide
Division with zero divided by zero defined as zero.
MathishLogb
Logb with log base one of one defined as zero.
Multiply
x × y.
Nand
See Not.
Negate
-x. A float or complex result never fails. An integer result fails where it doesn’t fit its type, as the negation of a signed type’s least value or of an unsigned byte other than 0 doesn’t, and holds the result wrapped to the type.
Nor
See Not.
Not
Logical NOT, NAND and NOR, of Booleans, and of integers that are 0 or 1, which give Booleans. Any other integer fails.
PiTimes
π × x, or π × (x ÷ y) of two arguments, at every float and complex type.
Polygamma
polygamma as a function object.
Pow
Real
The real part of a number, with a real number unchanged.
RealAcos
The real part of acos x, or of its principal value at a complex z, as a function object: acos x for x from -1 to 1, and acos of the nearer of -1 and 1 beyond. The real part of 2○⁻¹.
RealAcosh
The real part of acosh x, or of its principal value at a complex z, as a function object: acosh |x| for |x| at least 1, and 0 between -1 and 1. The real part of 6○⁻¹.
RealAsin
The real part of asin x, or of its principal value at a complex z, as a function object: asin x for x from -1 to 1, and asin of the nearer of -1 and 1 beyond. The real part of 1○⁻¹.
RealAtanh
The real part of atanh x, or of its principal value at a complex z, as a function object: atanh x for x between -1 and 1, and atanh (1 ÷ x) beyond, which is ½ ln |(1 + x) ÷ (1 - x)|. The real part of 7○⁻¹.
RealLn
ln|x|, the real part of ln x, as a function object.
RealPow
RealSqrt
The real part of √x, or of the principal √z of a complex z, as a function object: √x for a positive x, and 0 at or below 0. Its formula is recipe::real_sqrt.
RealSqrt1mx2
The real part of √(1 - x²), or of its principal value at a complex z, as a function object: √(1 - x²) for x from -1 to 1, and 0 beyond. The real part of 0○ and 0○⁻¹.
RealSqrtm1mx2
The real part of √(-1 - x²), or of its principal value at a complex z, negated where the flag is set, as a function object: 0 for every real x, whose 8○ is imaginary. The real part of 8○, and of 8○⁻¹ with the flag.
RealSqrtx2m1
The real part of √(x - 1) √(x + 1), or of its principal value at a complex z, as a function object: x’s sign times √(x² - 1) for |x| at least 1, and 0 between -1 and 1. The real part of 4○⁻¹, on APL’s branch.
Reciprocal
1 ÷ x. A float or complex result never fails. An integer’s reciprocal floors, as integer FloorDivide of 1 does: 1 gives 1, 2 or more give 0, -1 or less give -1, and 0 gives the type’s greatest value.
RightShift
Right shift, retaining the sign bit for signed integers. A negative count shifts left, and a count at least the item width saturates to the sign.
Rint
Rounding to the nearest whole number, with ties to even.
Root
root as a function object, with a scalar form and a slice form that work as Pow’s do. A constant degree of 2 or 3 takes sqrt or cbrt.
Round
Decimal rounding to nearest, ties to even. Constructing it precomputes the scale; extreme negative/positive precisions give zero/leave inputs unchanged.
Scale
Multiplication by a fixed real scale, computing f16 in f32 before rounding once.
Sign
The sign of x as -1 or 1, or z/|z| for a complex z, as a function object. A zero gives itself, and NaN gives NaN.
Sin
Sinh
sinh as a function object.
Sqrt
√x, or the principal √z of a complex z, whose real part is never negative, as a function object. A negative x gives NaN.
Sqrt1mx2
sqrt1mx2 as a function object.
Sqrt1px2
sqrt1px2 as a function object.
Sqrtm1mx2
Sqrtx2m1
sqrtx2m1 as a function object.
Subtract
x - y.
Tan
Tanh
tanh as a function object.
Trunc
Rounding toward zero, with whole numbers unchanged.

Enums§

Exponent
How Pow raises to an exponent y. Its slice form reads it once for a constant y, and its scalar form for each item. The JIT’s lowering of a constant power reads it too.

Constants§

BETWEEN_CHECKS
How many items a function handles between checks for an interrupt (interrupt::check), which keeps the check out of the loop over items.
FUSED
Whether mla fuses its multiply and add into one operation with one rounding. It does where the target has a fused multiply-add instruction, as on AArch64 and on x86-64 with FMA. Elsewhere, as in wasm and on baseline x86-64, mul_add calls a software fma, which is slow and stops the loop around it vectorizing. There mla multiplies and adds with two roundings.

Traits§

Float
A float type that rustymath’s functions take: half::f16, f32 or f64.
Native
A float type that rustymath’s algorithms run in: f32 or f64.

Functions§

acos
acos x. A real x gives a result from 0 to π and NaN beyond a magnitude of 1.
acosh
acosh x. A real x below 1 gives NaN.
asin
asin x. A real x gives a result from -π/2 to π/2 and NaN beyond a magnitude of 1.
asinh
asinh x.
atan
atan x. A real x gives a result from -π/2 to π/2.
atan2
The angle of the point (x, y) from the positive x axis, from -π to π, with y first as in C’s atan2. Zeros and infinities give C99’s angles: atan2(±0, -0) is ±π, and atan2(±∞, ±∞) is an odd multiple of ±π/4.
atanh
atanh x. ±1 gives ±∞, and a real x of magnitude beyond 1 gives NaN.
beta
B(a, b) = Γ(a) Γ(b)/Γ(a + b), the beta function. A pole of Γ(a) or Γ(b) gives NaN, and a pole of Γ(a + b) alone gives 0.
betainc
The regularized incomplete beta function I_x(a, b): the integral of t^(a-1) (1-t)^(b-1) from 0 to x, divided by B(a, b). a and b must be positive and x from 0 to 1, or the result is NaN.
betaincinv
The x with I_x(a, b) = p, for p from 0 to 1.
binom
C(n, k), the binomial coefficient. Whole n and k from 0 multiply out exactly while the result times |n| + k is a whole number the type holds, and a negative whole n gives (-1)^k C(k - n - 1, k). Other n with a whole k from 0 to 64 multiply out n(n - 1)…(n - k + 1)/k!, within 2k ulps. Other real arguments take Γ(n + 1)/(Γ(k + 1) Γ(n - k + 1)) in double words, within 4 ulps in tests against mpmath, for large n and negative arguments too.
binom_dk
∂C(n, k)/∂k, the binomial coefficient’s slope in k: C(n, k)(ψ(n - k + 1) - ψ(k + 1)). At a whole n from 0 below a whole k, it is the negative of binom_dn. Other poles of ψ, as at a negative whole k, give NaN. For a whole k from 0 to 64, its error is within 2k ulps of C(n, k) times ψ(n - k + 1) - ψ(k + 1), plus the error of that difference, so near n = 2k, where the two ψ cancel, its relative error has no bound.
binom_dn
∂C(n, k)/∂n, the binomial coefficient’s slope in n. For a whole k from 0 to 64 it is the slope of the polynomial n(n - 1)…(n - k + 1)/k! by the product rule, within 2k ulps. Other arguments take C(n, k)(ψ(n + 1) - ψ(n - k + 1)), with the ψ difference in double words where both arguments are from 10 up, with the polynomial’s slope where a whole n below a whole k puts those ψ at a pole. Other poles of ψ give NaN.
bitwise
Applies the Boolean function whose truth table is table, indexed by 2*x+y, to every bit of x and y, the leading sign bits included. It computes the table’s algebraic normal form, a0 ^ (a1 & x) ^ (a2 & y) ^ (a3 & x & y), with each coefficient spread to every bit, so every table runs the same code. A match on the table would put 16 paths into each loop that inlines it. It takes any integer type, exact ones included.
cbrt
The cube root of x.
cos
cos x. cos(±0) is 1, and cos(±∞) and cos(NaN) are NaN. Beyond the magnitude that sin gives, x takes the same exact reduction.
cosh
cosh x. It stays finite up to where cosh itself overflows, beyond the point where e^x does.
digamma
ψ(x), the digamma function: the derivative of ln Γ(x), Γ′(x)/Γ(x). ψ(+0) is -∞, ψ(-0) is ∞, a negative whole x and -∞ give NaN, and ψ(∞) is ∞. Near its zeros its error is within 4 ulps of 1, not of the result, and below -20 within 4 ulps of ln(1 - x).
divide
x / y for complex numbers, inline in the caller’s loop, by num_complex’s formula. Two real arguments divide as reals, so a real zero divisor gives ±∞ or NaN with an imaginary part of 0. Any other zero divisor gives NaN parts. |y|² overflows beyond about 1e154 at f64 and 1e19 at f32, and underflows below their inverses, where the quotient loses its digits. The decompositions’ Scalar::quotient uses Smith’s algorithm, which avoids that at the cost of speed in a vector loop.
erf
The error function, 2/√π times the integral of e^-t² from 0 to x.
erfc
1 - erf(x), without the loss of digits for large x that 1 - erf(x) has.
erfcinv
The x with erfc(x) = q. 0 gives ∞, 2 gives -∞, and q outside 0 to 2 gives NaN.
erfinv
The x with erf(x) = p. ±1 gives ±∞, and a magnitude beyond 1 gives NaN.
exp
e^x. exp(∞) is ∞, exp(-∞) is 0, and exp(NaN) is NaN.
expm1
e^x - 1, without the loss of digits near 0 that exp(x) - 1 has.
factorial
Γ(x + 1), which is x! for a whole x from 0.
gamma
Γ(x). Γ(±0) is ±∞, a negative whole x and -∞ give NaN, and Γ(∞) is ∞.
gammainc
The regularized lower incomplete gamma function P(a, x): the integral of t^(a-1) e^-t from 0 to x, divided by Γ(a). a must be positive and x nonnegative, or the result is NaN.
gammaincc
The regularized upper incomplete gamma function Q(a, x) = 1 - P(a, x), without the loss of digits that 1 - gammainc(a, x) has where Q is small.
gammaincinv
The x with P(a, x) = p, for p from 0 to 1.
hypot
√(x² + y²), with no overflow or underflow in between. An infinite argument gives ∞, even beside NaN.
lambertw
W0(x), the principal branch of the Lambert W function: the w of at least -1 with w e^w = x. A real x below -1/e gives NaN, except within half an ulp of -1/e, where W0 is -1.
lgamma
ln |Γ(x)|. It is ∞ at 0, at the negative whole numbers and at ±∞. Near its zeros at 1 and 2 its error is within 4 ulps of 2, not of the result.
ln
The natural logarithm of x. ln(0) is -∞, ln(∞) is ∞, and a negative real x or NaN gives NaN.
log2
The logarithm of x to base 2. It is k exactly at 2^k.
log1p
ln(1 + x), without the loss of digits near 0 that ln(1 + x) has. log1p(-1) is -∞.
log10
The logarithm of x to base 10. It is k exactly at 10^k, and at the float nearest 10^k where 10^k isn’t a float.
logb
The logarithm of x to base b, ln x / ln b. Base 2 and base 10 take log2 and log10, which are exact at powers of their base.
polygamma
ψ⁽ⁿ⁾(x), the polygamma function: the nth derivative of ψ, for a whole n from 0 to 170. For n from 1, x from 0 down gives NaN, as do a fractional or negative n and an n above 170.
pow
x^y. Special values follow IEEE 754’s pow: x^0 and 1^y are 1, even for NaN, and a negative x has a power only for a whole y.
root
The real nth root of y, computed without rounding 1/n first. A negative y has one only for an odd whole n. n = 0, an infinite n and NaN give NaN.
sin
sin x. sin(±0) is ±0, and sin(±∞) and sin(NaN) are NaN. Beyond a magnitude of 2^23 at f64 or 2^20 at f32, x takes a slower, exact reduction.
sinh
sinh x. It stays finite up to where sinh itself overflows, beyond the point where e^x does.
sqrt1mx2
√(1 - x²), without the digits that squaring x first loses near |x| = 1. A real x of magnitude beyond 1 gives NaN.
sqrt1px2
√(1 + x²), with no overflow where x² would overflow.
sqrtx2m1
√(x - 1) √(x + 1): √(x² - 1) with the sign of a real x, without the digits that squaring x first loses near |x| = 1. A real x of magnitude below 1 gives NaN.
tan
tan x. tan(±0) is ±0, and tan(±∞) and tan(NaN) are NaN. Beyond the magnitude that sin gives, x takes the same exact reduction.
tanh
tanh x.