Expand description
Complex arithmetic on interleaved [re, im] pairs.
The element type is [f64; 2], which is the layout numpy’s complex128,
C99’s double _Complex and a pair of Arrow Float64 children all agree
on, so a complex buffer crosses every boundary without a conversion.
Functions here are the mathematics only; the languages’ type rules and
diagnostics live in verb.rs.
Constants§
Functions§
- abs
- acos
_2 o. y: the arcsine’s complement.- acosh
_6 o. y:i * arccos y.- add
- arg
- The argument, in radians;
arg(0)is 0. - asin
_1 o. y:-i ln(iy + sqrt(1 - y^2)).- asinh
_5 o. y:ln(y + sqrt(y^2 + 1)).- atan
_3 o. y:(i/2)(ln(1 - iy) - ln(1 + iy)), the two-logarithm form, which puts the branch cuts where both references put them.- atanh
_7 o. y:(ln(1 + y) - ln(1 - y)) / 2, again as two logarithms.- ceil
- The ceiling is the floor reflected through the origin.
- circle
- The circle function
kon a complex argument.Nonefor a k the table does not define. - conj
- cos
- cosh
- div
- Division, with J’s rule for a zero divisor carried onto both parts:
0 % 0is 0 and anything else over zero is a signed infinity. - exp
- floor
- McDonnell’s complex floor: the Gaussian integer at or below y, chosen so
that the residue keeps a magnitude below one. Published in the J
dictionary’s account of
<.; both references answer with it. - from_
degrees - The unit complex at
degrees, exact on the quadrant boundaries — both references answer2ad90with0j2, not with a cosine’s rounding of it. - from_
radians - The complex of the given magnitude at the given angle in radians.
- from_
real - gcd
- The Gaussian-integer greatest common divisor, by Euclid with the nearest
Gaussian integer as the quotient.
gcd(0, 0)is 0. - lcm
x *. y: the least common multiple,(x * y) % gcd.- ln
- The principal logarithm;
ln 0is negative infinity, as on the reals. - log
x ^. y: the logarithm of y to base x.- mul
- neg
- pow
x ^ y. An integer exponent is repeated multiplication, which keeps0j1 ^ 2exactly_1rather than a rounded neighbour of it.- recip
- residue
x | y: y reduced modulo x, with the complex floor doing the rounding.- root
x %: y: the x-th root of y.- signum
y % | y: the unit complex in y’s direction, and 0 at the origin.- sin
- sinh
- sqrt
- The principal square root, by the algebraic form:
sqrt _4has to be exactly0j2, which halving the argument and taking a cosine does not give. - sub
- tan
- tanh
Type Aliases§
- Cx
- One complex number:
[real, imaginary].