Reference

Everything in the library

Every export of @ratmath/complex and of @ratmath/complex/cayley. Anything called z below is a Complex, text, a pair or a real number, and for the functions also a Rect or a Disc. bits is the precision in binary digits and defaults to 64.

Complex rationals

ExportWhat it does
complex(re, im)A Complex from text ("3 - 4i", "(1 + i)^8"), two parts, a [re, im] pair or a real number in any form Core reads.
Complex.re, .im (Core Rationals); add sub mul div neg conj inv pow(n) scale(q); norm() = |z|²; exactModulus() and exactSqrt() (null when irrational); equals isZero isReal isImaginary isGaussianInteger; toString toTeX toJSON toNumbers. Complex.parse(text), Complex.from(x), Complex.ZERO ONE I.
CQThe field Q(i)\mathbb{Q}(i) as a RatMath field object, for linalg and structures.
ComplexErrorThrown with a code: division-by-zero, branch-cut, branch-point, pole, precision, bad-option, bad-argument, singularity, zero-on-contour, unsupported; and from the cayley entry point no-quotient, not-a-rotation, too-large.

Enclosures

ExportWhat it does
rect(a, b)rect("1 + 2i") a point; rect([0, 1], [2, 3]) the rectangle [0,1] + i[2,3]; rect(z, radius) the square around z.
Rect.re, .im as { lo, hi }; .real, .imag as Core RationalIntervals; center width height size isPoint; add sub mul div inv neg conj scale timesI pow; contains intersects intersect hull containsZero; corners() split() round(bits) toDisc() normRange(); toString(digits) toJSON(). Rect.from(x), Rect.hull(...items).
disc(center, radius)The closed disc with rational centre and radius.
Disc.center, .radius; add sub mul div inv neg conj scale; contains intersects hull containsZero (decided exactly); toRect().

Polar form

ExportWhat it does
polar(z, bits){ modulus, argument, normSquared, exactModulus, exactTurn } for an exact z; the first two are Core RationalIntervals.
modulus(z, bits)|z| as a RationalInterval; also for a rectangle or disc.
argument(z, bits)The principal argument in (−π, π] as a RationalInterval.
arg(z, options)The argument as a Branched result, for inputs that may lie across the negative real axis.
exactTurn(z)The angle as a fraction of a full turn when that is rational (a multiple of 1/8), else null.
fromPolar(r, theta, bits)A Rect around reiθre^{i\theta}. theta in radians, or { turns: q }.
rootsOfUnity(n, bits)The n-th roots of unity, counter-clockwise from 1; the rational ones exact.
roots(z, n, bits)All n values of the n-th root of an exact z.

Functions

ExportWhat it does
exp sin cos tan sinh cosh tanhf(z, bits) or f(z, { bits }) returns a Rect. z is exact, a Rect or a Disc. tan and tanh refuse an enclosure that may contain a pole.
log(z, options)A Branched. Cut: the negative real axis. Options { bits, branch: k, side: "above" | "below" }; branch k adds 2πik.
sqrt(z, options), root(z, n, options)A Branched; exact when the square root is a complex rational. Branch k multiplies by e2πik/ne^{2\pi ik/n}.
pow(z, w, options)zwz^w. Exact for a whole-number w and exact z; a rational w goes through root; otherwise ewlog⁡ze^{w\log z}.
asin acos atanhBranched; cut on the real axis outside [−1, 1]; sides above, below.
atan asinhBranched; cut on the imaginary axis outside [−i, i]; sides right, left.
acoshBranched; cut on the real axis left of 1; sides above, below.
Branchedvalue (Rect or null), straddles, cut, candidates ([{ side, value }]), convention ({ side, value } for an exact point on the cut, else null), branch; getters rect (throws on the cut) and hull.
continueAlong(fn, path, options)Carry "log", { root: n } or { pow: w } along a polygonal path of exact points: { value, turns, branch, values }. Options bits, branch, about.
winding(path, w)The winding number of a closed polygon about w (default 0), exact.
refined(name, z, options)A Core Refinement: .quick at once, .exact() certified.
planThe phases still to come.

Möbius maps and the Riemann sphere

ExportWhat it does
mobius(a, b, c, d), mobiusFrom(from, to), Mobiusz ↦ (az + b)/(cz + d), exactly: apply, compose, inverse, equals, classify, fixedPoints, isSphereRotation. See Möbius maps.
infinity, isInfinityThe point at infinity.
crossRatio, concyclicThe invariant of four points; the exact test for lying on one circle or line.
circle(c, r2), lineThrough, circleThrough, GCircleCircles and lines as Hermitian forms, mapped exactly by map(T).
toSphere, fromSphere, chordal2Stereographic projection, exact. See The Riemann sphere.
cayley, halfPlaneToDisc, discAutomorphism, joukowski, regionsConformal maps of the standard regions.
gridImage, sampleGridData for pictures: exact image circles of a grid; sampled values (estimated).

Taylor models

ExportWhat it does
taylorModel(f, disc, opts)The model of f on a disc: a polynomial and a proven bound on ∣f−P∣|f - P| there. f is text in z or a function of one model. Options order (12), bits (96). Refuses (division-by-zero, branch-point, branch-cut, precision) when a hypothesis cannot be shown.
cauchyRiemann(u, v, { variables })Checks ux=vyu_x = v_y, uy=−vxu_y = -v_x for formulas in x and y: holds true (residuals reduce to 0, with derivative), false (a certified witness point) or null (undecided).
CTMCTM.z(disc, opts), CTM.constant(disc, value, opts); add sub mul div neg inv pow(n) scale(q); .center .radius .order .bits .disc .error .coefficients; at(z) (Rect), range() (Disc), zeroCount(), derivative(radius), integral(a, b), toString(). The package's exp log sqrt root pow sin cos tan sinh cosh tanh gamma rgamma logGamma zeta accept a model and return one.

Contours, integrals, zeros

ExportWhat it does
ContourContour.path(points), polygon(points), rectangle(rect), circle(center, radius, { clockwise }), arc(center, from, to, { clockwise }), from(x); .pieces .start .end .closed; join(other) reversed() winding(w) sample(perPiece).
contourIntegral(f, contour, opts)A Rect certain to contain the integral. Options tolerance (2⁻⁴⁰), order, bits, maxDepth, maxPieces. Refuses with singularity when f cannot be bounded somewhere on the contour.
residueSum(f, contour, opts)The integral round a closed contour over 2πi.
argumentPrinciple(f, contour, opts), countZerosThe winding number of f(contour) round 0, a proven whole number: zeros minus poles inside. Refuses with zero-on-contour.
zeros(f, rect, opts){ zeros: [{ enclosure, multiplicity, simple, isolating, boundary }], count, complete, unresolved }. Options bits (64), tolerance (2⁻²⁰), order, modelBits, maxCells.

Residues and real integrals

ExportWhat it does
laurent(f, center, radius, { from, to })Laurent coefficients for the annulus holding the circle: coefficient(n), coefficients, principalPart, toString().
residue(f, point, { radius })The residue at an exact point or an enclosure, a Rect. For text the circle is checked to hold no other zero of the denominator.
singularities(f, rect, opts)For a formula as text: { singularities: [{ enclosure, kind, order, note }], complete, unresolved, numerator, denominator } with kind "pole", "removable", "essential", "branch point" or "undetermined".
realLineIntegral(f, { fourier, bits, variable })∫ P/Q over the real line (times e^(iax) with fourier: a) by residues: { value, real, cos, sin, poles, steps }.
trigIntegral(f, { bits, variable })∫₀^2π of a rational function of cos t and sin t: { value, real, poles, steps }.

Gamma and zeta

ExportWhat it does
gamma(z, opts), rgamma(z, opts), logGamma(z, opts)Γ(z), the entire 1/Γ(z), and log Γ(z) for Re z > 0 (the branch real on the positive axis). A point, Rect or Disc gives a Rect; a model gives a model. gamma refuses with pole at 0, −1, −2, …
zeta(s, opts), zetaTimesSMinus1(s, opts)ζ(s), and the entire (s − 1)ζ(s). zeta refuses with pole at 1.
zetaZeros(t1, t2, opts)The zeros of ζ with t1 < Im s < t2: { zeros: [{ t, enclosure, multiplicity, onCriticalLine, boundary }], count, complete, allOnCriticalLine, unresolved }.

@ratmath/complex/cayley: the algebras

ExportWhat it does
quaternions, octonions, sedenionsThe algebras of dimension 4, 8 and 16 over the rationals.
cayleyDickson(level, field)The algebra of dimension 2level2^{\text{level}} (level 0 to 8) over a field object, the rationals by default.
CayleyDicksonlevel dim name labels field zero one units; basis(i), of(...coefficients), parse(text), properties() → { commutative, associative, alternative, flexible, composition, zeroDivisors }.
quaternion(w, x, y, z), octonion(...c)Elements from coordinates or text ("1 + 2i - k", "e1 + 2 e7").
HyperAn element: .coeffs, .algebra, .real, .imaginary; add sub mul neg scale conj norm inv pow rightDivide leftDivide commutator associator equals isZero.
QQThe rationals as a field object.

@ratmath/complex/cayley: rotations

ExportWhat it does
rotate(q, v)The vector part of qvq−1qvq^{-1}, as three Rationals.
rotationMatrix(q)The 3×3 rotation matrix as rows of Rationals. q need not have norm 1.
fromRotationMatrix(M)The primitive quaternion of a rational rotation matrix; refuses a matrix that is not a rotation.
fromAxis(axis, t)1+t⋅1 + t\cdotaxis: for a unit axis, t is the tangent of half the angle.
rotationOf(q){ axis, cos, tanHalfSquared }, exact.
primitive(q)The same rotation with whole-number coordinates sharing no factor, the first nonzero one positive.
interpolate(q0, q1, t)(1−t)q0+tq1(1 - t)q_0 + tq_1 the shorter way round: an exact rotation on the arc between them.

@ratmath/complex/cayley: integer quaternions

ExportWhat it does
hurwitz(a, b, c, d)A Hurwitz from coordinates that are all whole numbers or all halves of odd numbers, or from a quaternion.
Hurwitzadd sub mul neg conj equals isZero; norm() (BigInt); divmod(b) → { quotient, remainder } with this = quotient·b + remainder; isLipschitz, toIntegers(), toQuaternion(). The constructor takes doubled coordinates.
hurwitzUnits()The 24 units.
hurwitzGcd(a, b)A right greatest common divisor.
quaternionOfNorm(p)A Lipschitz quaternion of norm p, for a prime p.
fourSquares(n)Four BigInts, largest first, whose squares add to n.
fourSquaresCount(n)The number of ordered, signed representations of n as four squares (Jacobi).
Try itEdit the code and run it with @ratmath/complex and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs