#symnum

CAIMEOX/symbit/symnum is the public import path for this package.

Low-level numeric support used across Symbit, including exact rationals, MP-based numeric helpers, and precision-management utilities.

#When To Use This Package

  • Import CAIMEOX/symbit/symnum directly when your code depends on this package's subsystem-specific types or algorithms.
  • Prefer this package over the root facade when you want the focused API surface listed below rather than a convenience wrapper.

#Key Public Entry Points

  • catalan_fixed
  • diff
  • dps_to_prec
  • euler_fixed
  • fac
  • fhalf
  • findroot
  • finf

  • CAIMEOX/symbit
  • CAIMEOX/symbit/symcore

IntMathError

Integer-math error surface used by helpers like isqrt.

MPContext

High-level numeric context mirroring the mpmath.mp runtime state.

MPError

Error family used by high-level context operations.

MPZ

using @moonbitlang/core/bigint { type BigInt as MPZ }

MoonBit replacement for mpmath's MPZ arbitrary-precision integer type.

Mpc

Low-level arbitrary-precision complex backed by moon_floating libmp.

MpcError

Raw mpc error surface.

Mpf

Low-level arbitrary-precision real backed by moon_floating libmp.

MpfError

Raw mpf error surface.

MpfMatrix

Dense floating-point matrix type used by the mpmath-style compatibility API.

Mpi

Arbitrary-precision real interval backed by moon_floating libmpi.

MpiError

Raw interval error surface.

RoundMode

Public alias for the raw rounding mode used by libmp functions.

SeriesTermFn

Integer-indexed term callback used by summation, nsum, and nprod.

UnaryMpfFn

Real unary callback used by diff, findroot, quad, and limit wrappers.

RationalError

pub(all) suberror RationalError {
ZeroDenominator
} derive(
Debug
)

Error raised when constructing or inverting a rational with zero denominator.

BigRational

Canonical exact rational number num/den with gcd normalization.
impl Add for BigRational
impl Mul for BigRational
impl Neg for BigRational
impl Show for BigRational
impl Sub for BigRational

BigRational::add_r

fn BigRational::add_r(self : BigRational, other : BigRational) -> BigRational

Add two exact rationals.

BigRational::compare

fn BigRational::compare(self : BigRational, other : BigRational) -> Int

Three-way comparison: negative, zero, or positive.

BigRational::denominator

BigRational::div_r

fn BigRational::div_r(self : BigRational, other : BigRational) -> BigRational raise RationalError

Divide by another rational (self * other.reciprocal()).

BigRational::from_bigint

Construct an exact rational from a BigInt.

BigRational::from_int

fn BigRational::from_int(n : Int) -> BigRational

Construct an exact rational from an Int.

BigRational::from_ints

fn BigRational::from_ints(num : Int, den : Int) -> BigRational raise RationalError

Construct an exact rational from integer numerator and denominator.

BigRational::is_integral

fn BigRational::is_integral(self : BigRational) -> Bool

BigRational::is_one

fn BigRational::is_one(self : BigRational) -> Bool

BigRational::is_zero

fn BigRational::is_zero(self : BigRational) -> Bool

BigRational::mul_r

fn BigRational::mul_r(self : BigRational, other : BigRational) -> BigRational

Multiply two exact rationals.

BigRational::neg_r

fn BigRational::neg_r(self : BigRational) -> BigRational

Negate a rational.

BigRational::new

Construct a normalized rational and validate that den != 0.

BigRational::numerator

BigRational::one

BigRational::reciprocal

fn BigRational::reciprocal(self : BigRational) -> BigRational raise RationalError

Return the multiplicative inverse.

BigRational::sub_r

fn BigRational::sub_r(self : BigRational, other : BigRational) -> BigRational

Subtract two exact rationals.

BigRational::zero

fn BigRational::zero() -> BigRational

MPIntervalContext

pub struct MPIntervalContext {
prec : Int
} derive(Eq,
Debug
)

Interval context that carries precision for parse/format and interval ops.

MPIntervalContext::make_float

Parse a degenerate interval from a decimal literal.

MPIntervalContext::make_interval

Construct a closed interval from real endpoints.

MPIntervalContext::precision

fn MPIntervalContext::precision(self : MPIntervalContext) -> Int

Return interval-context precision in bits.

MPIntervalContext::to_string

Convert an interval to text using the configured precision.

catalan_fixed

Catalan's constant in fixed-point form scaled by 2**prec.

dps_to_prec

fn dps_to_prec(n : Int) -> Int

Convert decimal digits to binary precision using mpmath's formula.

euler_fixed

Euler-Mascheroni constant in fixed-point form scaled by 2**prec.

finf

Canonical positive infinity.

fnan

Canonical NaN sentinel.

fninf

Canonical negative infinity.

fnone

Canonical negative one.

fone

Canonical positive one.

format_mpf

fn format_mpf(x :
RawMpf
, format_spec : String, dps? : Int) -> String raise
MpfError

Format an mpf using the libmp formatting mini-language.

from_float

Exact conversion from a machine Double into an mpf.

from_int

Construct an exact mpf from a machine integer.

from_man_exp

Construct an mpf from a signed mantissa and power-of-two exponent.

fzero

Canonical positive zero.

gcd_bigint

Greatest common divisor for arbitrary-precision integers.

giant_steps

fn giant_steps(start : Int, target : Int, n? : Int) -> Array[Int]

Precision schedule helper copied from mpmath's giant_steps.

identify

Identify a floating-point value as a small symbolic constant expression.

inf

Alias matching mpmath's positive infinity constant.

interval_context

fn interval_context(prec : Int) -> MPIntervalContext

Construct an interval context with explicit binary precision.

is_complex_result

fn is_complex_result(err :
MPError
) -> Bool

Compatibility probe for callers that used except ComplexResult.

is_finite

is_no_convergence

fn is_no_convergence(err :
MPError
) -> Bool

Compatibility probe for callers that used except NoConvergence.

is_zero

Predicates on raw mpf values.

local_workdps

Function-style replacement for mpmath's local_workdps context manager.

local_workprec

Function-style replacement for mpmath's local_workprec context manager.

make_mpc

Build a complex value from real and imaginary parts.

make_mpf

Convenience alias mirroring mpmath's make_mpf naming.

Create a high-level numeric context from binary precision.

mp_dps

Create a high-level numeric context from decimal digits.

mpc

Minimal mpmath.mpc(...)-style constructor subset from real/imag parts.

mpc_is_inf

mpc_is_infnan

fn mpc_is_infnan(z :
RawMpc
) -> Bool

mpc_to_str

fn mpc_to_str(z :
RawMpc
, dps? : Int) -> String

mpf

Minimal mpmath.mpf(...)-style constructor subset using string input.

mpf_normalize

Normalize a raw mantissa/exponent tuple with explicit precision and rounding.

mpi_from_str

Parse an interval literal.

mpz_one

Canonical MPZ(1).

ninf

Alias matching mpmath's negative infinity constant.

normalize

Compatibility alias matching mpmath.libmp.normalize.

nprod

Numerical product wrapper with acceleration.

nsum

Numerical summation wrapper with acceleration.

phi_fixed

Golden ratio in fixed-point form scaled by 2**prec.

polyroots

Polynomial roots wrapper for real coefficients.

prec_to_dps

fn prec_to_dps(n : Int) -> Int

Convert binary precision to reliable decimal digits using mpmath's formula.

repr_dps

fn repr_dps(n : Int) -> Int

Digits needed to print an mpf uniquely for round-tripping.

round_ceiling

Round toward positive infinity.

round_down

Round toward zero.

round_floor

Round toward negative infinity.

round_nearest

Default round-to-nearest mode.

round_up

Round away from zero.

summation

Finite summation wrapper.

to_float

Convert an mpf to the nearest machine Double.

to_str

fn to_str(x :
RawMpf
, dps? : Int, base? : Int, binary_exp? : Bool) -> String raise
MpfError

Convert an mpf to a printable decimal or radix string.

workdps

Build a temporary context from decimal digits.

workprec

Build a temporary context with explicit working precision.