Global

Members

(constant) Constants

Description:
  • BigFloat Constants

Source:

BigFloat Constants

Flags

Description:
  • Flags for controlling the behavior of BigFloat operations.

Source:

Flags for controlling the behavior of BigFloat operations.

libbf :any

Description:
  • The libbf instance.

Source:

The libbf instance.

Type:
  • any

throwExceptionOnInvalidOp :boolean

Description:
  • If true, an exception is thrown on invalid operations.

Source:

If true, an exception is thrown on invalid operations.

Type:
  • boolean

Methods

O(nopt, coefTypeopt) → {Poly}

Description:
  • Factory for creating a Big-O term O(X^n).

Source:
Parameters:
Name Type Attributes Default Description
n number <optional>
1

The order of the truncation.

coefType function <optional>
BigFloat

The coefficient type.

Returns:
Type
Poly

X(nopt, coefTypeopt) → {Poly}

Description:
  • Factory for creating a polynomial representing X^n.

Source:
Parameters:
Name Type Attributes Default Description
n number <optional>
1

The degree of X.

coefType function <optional>
BigFloat

The coefficient type.

Returns:
Type
Poly

abs(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

acos(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

altZeta(s) → {Complex}

Description:
  • Dirichlet Eta function η(s) = (1 - 2^(1-s)) * ζ(s).

Source:
Parameters:
Name Type Description
s Complex | number | BigFloat
Returns:
Type
Complex

asin(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

atan(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

atan2(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

bernoulli(n) → {BigFloat}

Description:
  • Bernoulli numbers B_n using Ramanujan's recursive formula for small n and the Zeta relationship for large n.

    Ramanujan's Formula (speeds up recursion): sum_{k=0}^n [ C(6n+3, 6k) * B_{6k} ] = (2n+1)/2

Source:
Parameters:
Name Type Description
n number

The index of the Bernoulli number.

Returns:
Type
BigFloat

besseli(nu, z) → {Complex}

Description:
  • Modified Bessel function of the first kind I_v(z). Defined by: I_v(z) = (z/2)^v / gamma(v+1) * 0F1(; v+1; z^2/4)

Source:
Parameters:
Name Type Description
nu Complex | number

Order

z Complex | number

Complex argument

Returns:
Type
Complex

besselj(nu, z) → {Complex}

Description:
  • Bessel function of the first kind J_v(z). Defined by series: J_v(z) = (z/2)^v / gamma(v+1) * 0F1(; v+1; -z^2/4)

Source:
Parameters:
Name Type Description
nu Complex | number

Order of the Bessel function

z Complex | number

Complex argument

Returns:
Type
Complex

besselk(nu, z) → {Complex}

Description:
  • Modified Bessel function of the second kind K_v(z)

    K_v(z) = (pi/2) [I_{-v}(z) - I_v(z)] / sin(vpi)

Source:
Parameters:
Name Type Description
nu Complex | number

Order

z Complex | number

Complex argument

Returns:
Type
Complex

bessely(nu, z) → {Complex}

Description:
  • Bessel function of the second kind Y_v(z) Uses the mpmath precision trick of limit approximation (perturbation) for integer orders to sidestep exact L'Hôpital evaluation over series.

    Y_v(z) =[J_v(z)cos(vpi) - J_{-v}(z)] / sin(vpi)

Source:
Parameters:
Name Type Description
nu Complex | number

Order

z Complex | number

Complex argument

Returns:
Type
Complex

beta()

Description:
  • Beta function B(x, y) = Γ(x)Γ(y) / Γ(x+y)

Source:

bf(valopt, radixopt, managedopt, constantopt) → {BigFloat}

Description:
  • Creates a new BigFloat instance.

Source:
Parameters:
Name Type Attributes Default Description
val string | number | bigint | BigFloat <optional>

The value to initialize the BigFloat with.

radix number <optional>
10

The radix to use if val is a string.

managed boolean <optional>
true

Whether the BigFloat should be managed by the garbage collector.

constant boolean <optional>
false

Whether the BigFloat is a constant.

Returns:
Type
BigFloat

bigIntSqrt(value) → {bigint|undefined}

Description:
  • Calculates the integer square root of a BigInt. Returns undefined if the value is negative or not a perfect square.

Source:
Parameters:
Name Type Description
value bigint
Returns:
Type
bigint | undefined

ceil(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

complex(re, imopt) → {Complex}

Description:
  • Creates a new Complex instance.

Source:
Parameters:
Name Type Attributes Description
re number | string | BigFloat | Complex

Real part or Complex object

im number | string | BigFloat <optional>

Imaginary part

Returns:
Type
Complex

cos(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

decimalPrecision(dpopt) → {number|undefined}

Description:
  • Gets or sets the precision in decimal digits.

Source:
Parameters:
Name Type Attributes Description
dp number <optional>

The new precision in decimal digits. If not provided, the function returns the current precision in decimal digits.

Returns:
Type
number | undefined

diff(f, x, nopt, infoopt) → {BigFloat|null}

Description:
  • High-precision Numerical Differentiation.

    Computes the n-th derivative of function f at point x using the limit function to extrapolate the finite difference quotient as the step size h approaches zero.

Source:
Parameters:
Name Type Attributes Default Description
f function

The function to differentiate. Must accept and return BigFloat.

x number | string | BigFloat

The point at which to compute the derivative.

n number <optional>
1

The order of the derivative (1st, 2nd, etc.).

info Object <optional>
{}

Configuration object.

Properties
Name Type Attributes Default Description
singular boolean <optional>
false

If true, avoids evaluating f(x) exactly by shifting the sampling points (useful if x is a singularity).

direction number <optional>
1

Direction of the limit: 1 for forward, -1 for backward.

Returns:

The n-th derivative at x, or null if convergence fails.

Type
BigFloat | null

exp(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

factorial() → {Complex|BigFloat}

Description:
  • Factorial function n! = Γ(n + 1)

Source:
Returns:

return Complex when n is Complex, otherwize return a BigFloat

Type
Complex | BigFloat

floor(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

fminbnd(f, _ax, _bx, infoopt) → {BigFloat|null}

Description:
  • High-precision Function Minimization using Brent's Method (similar to MATLAB's fminbnd).

    This algorithm finds a local minimum of a function of one variable within a fixed interval. It combines Golden Section Search (linear convergence) with Parabolic Interpolation (superlinear convergence) for reliability and speed.

Source:
Parameters:
Name Type Attributes Default Description
f function

The objective function to minimize. Must accept a BigFloat argument and return a BigFloat result.

_ax number | string | BigFloat

The start of the search interval.

_bx number | string | BigFloat

The end of the search interval.

info Object <optional>
{}

Configuration and Status object. Updates in-place with statistics (iterations, execution time, error estimate). // --- Input Configuration Properties ---

Properties
Name Type Attributes Default Description
_e number | string | BigFloat <optional>
1e-30

Absolute Error Tolerance.

_re number | string | BigFloat <optional>
info._e

Relative Error Tolerance. The convergence criteria is based on the position x, not the function value. tol = |x| * _re + _e

max_step number <optional>
500

Maximum number of iterations allowed. If this limit is reached without convergence, the function returns null and logs a warning.

max_time number <optional>
60000

Maximum execution time in milliseconds. Prevents the function from hanging in infinite loops or extremely slow computations.

cb function <optional>

Optional callback function. If defined, this function is called after every iteration. Useful for updating UI progress or logging.

debug boolean <optional>

Optional flag to enable debug logging (implementation dependent).

   // --- Output Status Properties (Updated during execution) ---
result BigFloat | null

The final found root. Returns a BigFloat if converged, or null if failed.

lastresult BigFloat

The result of the last iteration (current best guess b). Even if convergence fails, this contains the value closest to the root when execution stopped.

eff_result string

String representation of the result based on effective precision. Generated by truncating lastresult according to eff_decimal_precision.

steps number

The number of iterations currently executed.

exectime number

The elapsed execution time in milliseconds.

error BigFloat

The estimated error bound. Typically represents half the width of the current search interval (xm).

residual BigFloat

The absolute value of the function at the current best guess: |f(x)|. Ideally, this value should be close to zero.

eff_decimal_precision number

Estimated number of significant decimal digits. Calculated as -log10(error).

toString function

Helper method. Returns a formatted string containing steps, error, residual, and execution time.

Returns:

Returns the BigFloat x where f(x) is minimized. Returns null if max steps or time limit exceeded.

Type
BigFloat | null

formatDecimal(str, prettyopt) → {string}

Description:
  • Trims repeating trailing decimals based on specific rules.

Source:
Parameters:
Name Type Attributes Default Description
str string

The input string number.

pretty boolean <optional>
false

pretty print

Returns:
  • The formatted string.
Type
string

fpround(v, precopt, rnd_modeopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
rnd_mode number <optional>
0
Returns:
Type
BigFloat

frac(nopt, dopt) → {BigFraction}

Description:
  • Creates a new BigFraction instance.

Source:
Parameters:
Name Type Attributes Default Description
n BigFraction | bigint | number | string <optional>

The numerator or the whole value.

d bigint | number | string <optional>
1n

The denominator.

Returns:
Type
BigFraction

fromDouble(val) → {Object}

Description:
  • Rapidly converts a JS Number to BigInt numerator and denominator by directly accessing IEEE 754 bits.

    Formula: Value = (-1)^S * (1 + Mantissa/2^52) * 2^(Exponent - 1023)

Source:
Parameters:
Name Type Description
val number
Returns:
Type
Object

fzero(f, _a, _b, infoopt) → {BigFloat|null}

Description:
  • High-precision Root Finding using the Brent-Dekker Method (similar to MATLAB's fzero).

    This algorithm combines the reliability of Bisection, the speed of the Secant method, and the high-order convergence of Inverse Quadratic Interpolation (IQI). It guarantees global convergence while achieving superlinear convergence rates near the root.

Source:
Parameters:
Name Type Attributes Default Description
f function

The target function to find the root of. Must accept a BigFloat argument and return a BigFloat result. The function values at the endpoints must have opposite signs (f(_a) * f(_b) <= 0).

_a number | string | BigFloat

The start of the search interval (or first initial guess).

_b number | string | BigFloat

The end of the search interval (or second initial guess).

info Object <optional>
{}

Configuration and Status object. This object configures the execution parameters and is updated in-place with statistical data during and after execution.

Properties
Name Type Attributes Default Description
_e number | string | BigFloat <optional>
1e-30

Absolute Error Tolerance. Convergence is considered achieved when the interval width or step size falls below this value.

_re number | string | BigFloat <optional>
info._e

Relative Error Tolerance. Used to handle convergence for large values. Defaults to the absolute tolerance. The effective tolerance is calculated as: tol = |b| * _re + _e.

   // --- Input Configuration Properties ---
max_step number <optional>
200

Maximum number of iterations allowed. If this limit is reached without convergence, the function returns null and logs a warning.

max_time number <optional>
60000

Maximum execution time in milliseconds. Prevents the function from hanging in infinite loops or extremely slow computations.

cb function <optional>

Optional callback function. If defined, this function is called after every iteration. Useful for updating UI progress or logging.

debug boolean <optional>

Optional flag to enable debug logging (implementation dependent).

   // --- Output Status Properties (Updated during execution) ---
result BigFloat | null

The final found root. Returns a BigFloat if converged, or null if failed.

lastresult BigFloat

The result of the last iteration (current best guess b). Even if convergence fails, this contains the value closest to the root when execution stopped.

eff_result string

String representation of the result based on effective precision. Generated by truncating lastresult according to eff_decimal_precision.

steps number

The number of iterations currently executed.

exectime number

The elapsed execution time in milliseconds.

error BigFloat

The estimated error bound. Typically represents half the width of the current search interval (xm).

residual BigFloat

The absolute value of the function at the current best guess: |f(x)|. Ideally, this value should be close to zero.

eff_decimal_precision number

Estimated number of significant decimal digits. Calculated as -log10(error).

toString function

Helper method. Returns a formatted string containing steps, error, residual, and execution time.

Returns:

Returns the BigFloat root if the tolerance criteria are met. Returns null if the maximum steps or time limit is exceeded (a warning is logged to the console).

Type
BigFloat | null

gamma(z) → {Complex}

Description:
  • High-precision Gamma function Γ(z).

Source:
Parameters:
Name Type Description
z Complex | number | string | BigFloat
Returns:
Type
Complex

gcd(a, b) → {bigint}

Description:
  • Helper function to calculate Greatest Common Divisor (GCD) using Euclidean algorithm.

Source:
Parameters:
Name Type Description
a bigint
b bigint
Returns:
Type
bigint

getEpsilon() → {number}

Description:
  • Gets the epsilon value for the current precision.

Source:
Returns:
Type
number

getGcEleLimit() → {number}

Description:
  • Get gc_ele_limit

Source:
Returns:
Type
number

getGlobalFlag() → {number}

Description:
  • Get the global flags for libbf operations.

Source:
Returns:
Type
number

getPrecision() → {number}

Description:
  • Get the global precision

Source:
Returns:
Type
number

hankel1()

Description:
  • Hankel function of the first kind H1_v(z) = J_v(z) + i*Y_v(z)

Source:

hankel2()

Description:
  • Hankel function of the second kind H2_v(z) = J_v(z) - i*Y_v(z)

Source:

hyp0f1(a, z, max_iteropt) → {Complex}

Description:
  • Confluent Hypergeometric Limit Function 0F1(; a; z) Used as the primary power series expansion for Bessel functions.

Source:
Parameters:
Name Type Attributes Default Description
a Complex

The parameter 'a' (usually nu + 1)

z Complex

The complex argument

max_iter Number <optional>
10000
Returns:
Type
Complex

identify(_x, optionsopt) → {string}

Description:
  • Identify a high-precision BigFloat as a simple symbolic expression. This function uses the Continued Fraction algorithm to find the best rational approximation p/q for x, x/pi, x^2, etc.

Source:
Parameters:
Name Type Attributes Default Description
_x BigFloat | number | string

The value to identify.

options Object <optional>
{}

Configuration options.

Properties
Name Type Attributes Default Description
tol number | BigFloat <optional>

Error tolerance (defaults to current precision's epsilon).

max_den number <optional>
1000000

Maximum denominator allowed for rational parts.

constants Array <optional>

Custom constants to check against.

Returns:
  • A string representation of the identified expression, or the number itself.
Type
string

init(m) → {Promise.<boolean>}

Description:
  • Initializes the libbf library.

Source:
Parameters:
Name Type Description
m any

The wasm module.

Returns:
Type
Promise.<boolean>

isInteger()

Description:
  • Helper to check if a Complex number is strictly an integer. Used to detect singularities in Gamma or branch logic.

Source:

isReady() → {boolean}

Description:
  • Checks if the libbf library is ready.

Source:
Returns:
Type
boolean

lambertw(z, k) → {Complex}

Description:
  • High-precision Lambert W function W_k(z). Computes the principal branch W_0(z) by default, or the k-th branch W_k(z).

Source:
Parameters:
Name Type Description
z Complex | number | string | BigFloat

The complex argument

k number

Branch index (default 0)

Returns:
Type
Complex

limit(f, point, infoopt) → {BigFloat|null}

Description:
  • High-precision Numerical Limit using Richardson Extrapolation.

    This function estimates the limit of f(x) as x approaches point. It evaluates the function at a sequence of points converging to the target and uses Richardson extrapolation to eliminate error terms, achieving high precision.

Source:
Parameters:
Name Type Attributes Default Description
f function

The function to evaluate. Must accept a BigFloat argument (x) and return a BigFloat result (f(x)).

point number | string | BigFloat

The target value to approach. Can be a finite number, or 'inf', '+inf', 'infinity' for positive infinity, '-inf', '-infinity' for negative infinity.

info Object <optional>
{}

Configuration and Status object.

Properties
Name Type Attributes Default Description
_e number <optional>
1e-30

Absolute Error Tolerance.

_re number <optional>
info._e

Relative Error Tolerance.

   // --- Input Configuration Properties ---
useExp boolean | Number <optional>
false

If true, uses exponential coordinate transformation. Useful for slowly converging limits (e.g. logarithmic) or limits at infinity. Use info.useExp as base number when it's a Number, otherwize use 2 as base number. For x->inf, substitutes x = pow(baseNumber,1/t). For x->c, substitutes x = c + dir * pow(baseNumber,-1/t).

max_step number <optional>
100

Maximum number of iterations (rows in the extrapolation table).

max_acc number <optional>
15

Maximum extrapolation order (columns in the table).

max_time number <optional>
60000

Maximum execution time in milliseconds.

direction number <optional>
1

Direction of approach for finite limits. 1 for approaching from right (c + h), -1 for approaching from left (c - h). Ignored if point is infinite.

cb function <optional>

Optional callback function executed after each iteration.

debug boolean <optional>

Optional flag to enable debug logging.

   // --- Output Status Properties ---
result BigFloat | null

The final calculated limit.

lastresult BigFloat

The best estimate from the most recent iteration.

eff_result string

String representation based on effective precision.

steps number

Current iteration number.

error BigFloat

Estimated absolute error.

rerror BigFloat

Estimated relative error.

eff_decimal_precision number

Estimated significant digits.

Returns:

Returns the BigFloat limit value if tolerances are met, or null otherwise.

Type
BigFloat | null

linspace(start, end, n)

Source:
Parameters:
Name Type Description
start BigFloat | Number | string
end BigFloat | Number | string
n Number
Returns:

log(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

logGamma(z) → {Complex}

Description:
  • High-precision Log-Gamma function ln(Gamma(z)). Essential for large z where Gamma(z) would overflow.

Source:
Parameters:
Name Type Description
z Complex | number | string | BigFloat
Returns:
Type
Complex

max(…args) → {BigFloat}

Source:
Parameters:
Name Type Attributes Description
args BigFloat | number | string | bigint <repeatable>
Returns:
Type
BigFloat

min(…args) → {BigFloat}

Source:
Parameters:
Name Type Attributes Description
args BigFloat | number | string | bigint <repeatable>
Returns:
Type
BigFloat

neg(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

nsum(f, range, infoopt) → {BigFloat|null}

Description:
  • High-precision Numerical Summation (Infinite/Finite Series).

    This function estimates the sum of f(n) for n from start to end. For infinite series, it calculates a sequence of partial sums (doubling the number of terms each step) and uses Richardson extrapolation to accelerate convergence.

Source:
Parameters:
Name Type Attributes Default Description
f function

The term function. Must accept a BigFloat argument (n) and return a BigFloat result (f(n)).

range Array.<(number|string|BigFloat)>

The summation interval [start, end]. e.g., [0, 100] or [1, 'inf'].

info Object <optional>
{}

Configuration and Status object.

Properties
Name Type Attributes Default Description
_e number <optional>
1e-30

Absolute Error Tolerance.

_re number <optional>
info._e

Relative Error Tolerance.

   // --- Input Configuration Properties ---
max_step number <optional>
20

Maximum number of doubling steps. Step m involves summing up to 2^m terms. Be careful increasing this, as computational cost doubles with each step.

max_acc number <optional>
15

Maximum extrapolation order.

max_time number <optional>
60000

Maximum execution time in milliseconds.

cb function <optional>

Optional callback function executed after each iteration.

debug boolean <optional>

Optional flag to enable debug logging.

   // --- Output Status Properties ---
result BigFloat | null

The final calculated sum.

lastresult BigFloat

The best estimate from the most recent iteration.

eff_result string

String representation based on effective precision.

steps number

Current iteration number (row index m). Total terms summed approx 2^steps.

terms_count number

Total number of terms explicitly evaluated.

error BigFloat

Estimated absolute error.

rerror BigFloat

Estimated relative error.

eff_decimal_precision number

Estimated significant digits.

Returns:

Returns the BigFloat sum if converged/completed, or null if failed.

Type
BigFloat | null

ode15s(odefun, tspan, y0, infoopt) → {Object|null}

Description:
  • High-precision Stiff ODE Solver (Equivalent to MATLAB's ode15s). Variable-Order (1-5), Variable-Step Backward Differentiation Formulas (BDF). Utilizes custom SparseMatrixCSC for high-performance implicit Newton-Raphson iterations.

Source:
Parameters:
Name Type Attributes Default Description
odefun function

The main function: dydt = odefun(t, y) or returns { M, f }.

tspan Array.<(number|string|BigFloat)>

Interval of integration [t0, tf].

y0 Array.<(number|string|BigFloat)> | BigFloat

Initial conditions.

info Object <optional>
{}

Configuration and Status object.

   // --- Input Configuration Properties ---
Properties
Name Type Attributes Default Description
Jacobian function <optional>

Optional analytical Jacobian: J = Jac(t, y, f). Returns COO object {rowIdx, colIdx, vals} or 2D Array.

_e number | string | BigFloat <optional>
"1e-15"

Absolute Tolerance.

_re number | string | BigFloat <optional>
info._e

Relative Tolerance.

estimate_error boolean <optional>

when true, info.global_error will return the estimated global error.

initial_step number | string | BigFloat <optional>

Initial step size guess.

progress number <optional>

log progress every info.progress*100% progress

progressCb number <optional>

progress call back progressCb(pos:Number,t,y)

max_step number <optional>
2000000

Maximum number of steps allowed.

max_time number <optional>
1200000

Maximum execution time in milliseconds.

cb function <optional>

Optional callback per accepted step: cb(t, y).

Returns:

{ t, y, dy } or null on catastrophic failure.

Type
Object | null

ode45(odefun, tspan, y0, infoopt) → {Object|null}

Description:
  • High-precision ODE Solver using Dormand-Prince method (similar to MATLAB's ode45).

    Solves non-stiff differential equations y' = f(t, y). Implementation of the explicit Runge-Kutta (4,5) formula (Dormand-Prince pair). Supports adaptive step size control.

Source:
Parameters:
Name Type Attributes Default Description
odefun function

The main function to integrate: dydt = odefun(t, y). - t: BigFloat (current time) - y: Array (current state vector) Returns: Array (derivatives)

tspan Array.<(number|string|BigFloat)>

Interval of integration [t0, tf].

y0 Array.<(number|string|BigFloat)> | BigFloat

Initial conditions. Can be a scalar (converted to array internally) or an array of values.

info Object <optional>
{}

Configuration and Status object. Updates in-place with solution data and statistics.

   // --- Input Configuration Properties ---
Properties
Name Type Attributes Default Description
_e number | string | BigFloat <optional>
1e-16

Absolute Tolerence (AbsTol).

_re number | string | BigFloat <optional>
1e-16

Relative Tolerance (RelTol). Error control: |e| <= max(RelTol * |y|, AbsTol)

initial_step number | string | BigFloat <optional>

Initial step size guess. If omitted, it is automatically estimated.

progress number <optional>

log progress every info.progress*100% progress

progressCb number <optional>

progress call back progressCb(pos:Number,t,y)

max_step number <optional>
2000000

Maximum number of steps allowed.

max_time number <optional>
1200000

Maximum execution time in milliseconds.

cb function <optional>

Optional callback per step: cb(t, y).

   // --- Output Status Properties ---
t Array.<BigFloat>

Array of time points.

y Array.<Array.<BigFloat>>

Array of state vectors corresponding to info.t.

steps number

Total successful steps taken.

failed_steps number

Number of rejected steps (due to error tolerance).

exectime number

Execution time in ms.

status string

"done", "timeout", or "max_steps".

Returns:

Returns { t, y } (references to info.t and info.y) if successful. Returns null if critical errors occur.

Type
Object | null

pdepe(m, pdefun, icfun, bcfun, xmesh, tspan, infoopt) → {Array.<Array.<(BigFloat|Array.<BigFloat>)>>}

Description:
  • High-performance 1D Parabolic and Elliptic PDE Solver (Equivalent to MATLAB's pdepe). Solves equations of the form: c(x,t,u,Du/Dx) * Du/Dt = x^(-m) * D/Dx( x^m * f(x,t,u,Du/Dx) ) + s(x,t,u,Du/Dx)

    NOTE: All user-provided functions (pdefun, icfun, bcfun) MUST return BigFloat or Array<BigFloat> objects directly. No implicit type conversion is performed.

Source:
Parameters:
Name Type Attributes Default Description
m number | string

Symmetry parameter: 0 (slab), 1 (cylinder), 2 (sphere).

pdefun function

Equation definitions: {c, f, s} = pdefun(x, t, u, dudx)

icfun function

Initial conditions: u0 = icfun(x)

bcfun function

Boundary conditions: {pl, ql, pr, qr} = bcfun(xl, ul, xr, ur, t)

xmesh Array.<(number|string|BigFloat)>

Spatial grid points[x_0, x_1, ..., x_N]

tspan Array.<(number|string|BigFloat)>

Time output points[t_0, t_1, ..., t_M]

info Object <optional>
{}

Configuration and Status object forwarded to ode15s.

Properties
Name Type Attributes Default Description
_e number | string | BigFloat <optional>
"1e-5"

Absolute Tolerance.

_re number | string | BigFloat <optional>
"1e-4"

Relative Tolerance.

max_step number <optional>
10000000

Maximum number of steps allowed.

max_time number <optional>
10000000

Maximum execution time in milliseconds.

cb function <optional>

Optional callback per accepted ODE step: cb(t, y).

progress number <optional>

Log progress every info.progress*100%.

progressCb number <optional>

progress call back progressCb(pos:Number,t,y)

estimate_error boolean <optional>

Enable global error estimation tracking.

Returns:
  • Solution 3D Array strictly returning BigFloat instances.
Type
Array.<Array.<(BigFloat|Array.<BigFloat>)>>

poly(v, coefTypeopt) → {Poly}

Description:
  • Factory function to create a Poly instance from various inputs. Now uses the Scalar class for coefficient parsing and unified representation.

Source:
Parameters:
Name Type Attributes Default Description
v string | Array.<any> | Object.<string, any> | Map.<string, any> | number | bigint | BigFloat | BigFraction | Complex | Poly | Scalar
coefType function <optional>
BigFloat

The class used to construct coefficients.

Returns:
Type
Poly

polyStr(v, coefTypeopt) → {Poly}

Description:
  • Factory function to create a Poly instance using a State Machine parser. This parser avoids regex for core logic to handle complex nested structures and strict validation.

    Supported formats examples:

    • Integer/Fraction: "1", "-1", "+-1", "-2/3"
    • Variables: "X", "-X", "-2X", "-2*X"
    • Exponents: "X^2", "X^-1", "X^(-1)", "X^0"
    • Complex in parens: "(-1+i)X", "(3+2i)"
    • Big-O: "+O(3)", "O(X^5)"
Source:
Parameters:
Name Type Attributes Default Description
v string
coefType function <optional>
Scalar

The class used to wrap/construct coefficients.

Returns:
Type
Poly

polyfit(x, y, order, infoopt) → {Array.<BigFloat>|null}

Description:
  • High-precision Polynomial Curve Fitting using Least Squares Method.

    Finds the coefficients of a polynomial p(x) of degree n that fits the data, minimizing the sum of the squared errors.

    Coefficients are returned in descending powers (MATLAB style): p(x) = c[0]*x^n + c[1]*x^(n-1) + ... + c[n-1]*x + c[n]

Source:
Parameters:
Name Type Attributes Default Description
x Array.<(number|string|BigFloat)>

Array of x-coordinates.

y Array.<(number|string|BigFloat)>

Array of y-coordinates.

order number

The degree of the polynomial to fit (n).

info Object <optional>
{}

Configuration and Status object.

Properties
Name Type Attributes Default Description
max_time number <optional>
60000

Maximum execution time in milliseconds.

debug boolean <optional>

Enable debug logging.

   // --- Output Status Properties ---
result Array.<BigFloat> | null

Array of coefficients (descending order).

ssr BigFloat

Sum of Squared Residuals (Error).

r_squared BigFloat

Coefficient of determination (0 to 1).

rmse BigFloat

Root Mean Square Error.

exectime number

Elapsed execution time.

toString function

Helper to format the result.

Returns:

Returns array of BigFloat coefficients if successful, null otherwise.

Type
Array.<BigFloat> | null

polyval(p, x) → {BigFloat}

Description:
  • Helper: Evaluate polynomial at x (MATLAB polyval style)

Source:
Parameters:
Name Type Description
p Array.<BigFloat>

Coefficients [c_n, ..., c_0]

x BigFloat | number
Returns:
Type
BigFloat

popPrecision()

Description:
  • Pops the precision from the stack and restores the previous precision.

Source:

pow(v, b, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
b BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

primeZeta(s) → {Complex}

Description:
  • Prime Zeta Function P(s) = sum_{p \in primes} p^-s. Calculated via Mobius inversion: P(s) = sum_{n=1}^inf (μ(n)/n) * ln(ζ(ns))

Source:
Parameters:
Name Type Description
s Complex | number | BigFloat
Returns:
Type
Complex

pushDecimalPrecision(dp)

Description:
  • Pushes the current precision to the stack and sets a new precision in decimal digits.

Source:
Parameters:
Name Type Description
dp number

The new precision in decimal digits.

pushPrecision(prec)

Description:
  • Pushes the current precision to the stack and sets a new precision.

Source:
Parameters:
Name Type Description
prec number

The new precision in bits.

quad(f, _a, _bopt, infoopt) → {BigFloat|Complex|null}

Description:
  • High-precision Numerical Integration using Tanh-Sinh (Double Exponential) Quadrature.

    SOTA level implementation equivalent to mpmath.quad.

    • Natively supports finite, half-infinite, and fully infinite bounds.
    • Supports Complex variables, endpoints, and complex integrands.
    • Supports contour/path integration when _a is an array of nodes and _b is undefined.
    • Extremely robust against endpoint singularities (e.g. log(0), 1/0) through smart boundary bypassing.
Source:
Parameters:
Name Type Attributes Default Description
f function

The integrand function. Must accept a BigFloat/Complex argument (z) and return a BigFloat/Complex result (f(z)).

_a number | string | BigFloat | Complex | Array

The lower limit of integration, or an array of points for contour integration.

_b number | string | BigFloat | Complex <optional>

The upper limit of integration (leave undefined for contour path integration).

info Object <optional>
{}

Configuration and Status object.

Properties
Name Type Attributes Default Description
_e number <optional>
1e-50

Absolute Error Tolerance.

_re number <optional>
info._e

Relative Error Tolerance.

max_step number <optional>
15

Maximum number of interval halving steps.

max_time number <optional>
60000

Maximum execution time in milliseconds.

cb function <optional>

Optional callback function executed after each level computation.

debug boolean <optional>

Optional flag to enable debug logging.

Returns:

Returns the exact integral value, or null if failed.

Type
BigFloat | Complex | null

romberg(f, _a, _b, infoopt) → {BigFloat|null}

Description:
  • High-precision Numerical Integration using Romberg's Method.

    This function estimates the definite integral of f over the interval [_a, _b] using Richardson extrapolation applied to the Trapezoidal rule. It iteratively refines the interval width and the order of the polynomial approximation to achieve high precision with relatively few function evaluations.

Source:
Parameters:
Name Type Attributes Default Description
f function

The integrand function. Must accept a BigFloat argument (x) and return a BigFloat result (f(x)).

_a number | string | BigFloat

The lower limit of integration.

_b number | string | BigFloat

The upper limit of integration.

info Object <optional>
{}

Configuration and Status object. Configures execution parameters and stores statistical data during/after execution.

Properties
Name Type Attributes Default Description
_e number <optional>
1e-30

Absolute Error Tolerance. The integration stops when the estimated absolute error falls below this threshold.

_re number <optional>
info._e

Relative Error Tolerance. The integration stops when the estimated relative error falls below this threshold. (Condition: error <= _e || rerror <= _re) // --- Input Configuration Properties ---

max_step number <optional>
25

Maximum number of interval halving steps (rows in the Romberg table). Note: The number of function evaluations grows exponentially (2^steps).

max_acc number <optional>
12

Maximum extrapolation order (columns in the Romberg table). Limits the depth of Richardson extrapolation to prevent numerical instability from high-order polynomials.

max_time number <optional>
60000

Maximum execution time in milliseconds.

cb function <optional>

Optional callback function executed after each row of the table is computed.

debug boolean <optional>

Optional flag to enable debug logging to the console.

   // --- Output Status Properties (Updated during execution) ---
result BigFloat | null

The final calculated integral. Returns a BigFloat if converged, or null if failed.

lastresult BigFloat

The best estimate of the integral from the most recent iteration.

eff_result string

String representation of the result based on effective precision.

steps number

Current iteration number (row index m). Corresponds to dividing the interval into 2^(steps-1) segments.

exectime number

Elapsed execution time in milliseconds.

error BigFloat

Estimated absolute error. Calculated as the difference between the two most accurate extrapolations in the current row.

rerror BigFloat

Estimated relative error (error / lastresult).

eff_decimal_precision number

Estimated number of significant decimal digits. Calculated as -log10(rerror).

toString function

Helper method. Returns a formatted string containing steps, error, result, and execution time.

Returns:

Returns the BigFloat integral value if tolerances are met. Returns null if max_step or max_time is reached without convergence.

Type
BigFloat | null

roots(_coeffs, infoopt) → {Array.<Complex>|null}

Description:
  • Calculates the roots of a polynomial with high precision using the Durand-Kerner method.

    This function mimics MATLAB's roots command but supports arbitrary precision BigFloat numbers. It solves for x in the polynomial equation: c[0]*x^n + c[1]*x^(n-1) + ... + c[n] = 0

    The algorithm iterates simultaneously towards all n roots, naturally handling complex conjugate pairs.

Source:
Parameters:
Name Type Attributes Default Description
_coeffs Array.<(number|string|BigFloat|Complex)>

The polynomial coefficients. Must be ordered from highest degree to lowest (e.g., [1, -5, 6] for x^2 - 5x + 6). Leading zeros are automatically removed.

info Object <optional>
{}

Configuration and Status object.

   // --- Input Configuration ---
Properties
Name Type Attributes Default Description
max_step number <optional>
500

Maximum number of iterations. Durand-Kerner usually converges quadratically, so 50-100 is typically sufficient for high precision.

max_time number <optional>
60000

Maximum execution time in milliseconds.

_e number | string | BigFloat <optional>
1e-30

Convergence tolerance. The loop stops when the maximum change in any root position is smaller than this value.

cb function <optional>

Optional callback function executed after each iteration.

   // --- Output Status (Updated during execution) ---
result Array.<{re:BigFloat, im:BigFloat}> | null

The final array of roots.

steps number

Current iteration count.

exectime number

Elapsed time in ms.

error BigFloat

The maximum correction (shift magnitude) applied in the last step. Used as a proxy for the current error bound.

eff_decimal_precision number

Estimated significant decimal digits based on convergence error.

eff_result string

A string summary of the first root (for debugging/display).

toString function

Helper to print status summary.

Returns:

Returns an array of objects representing complex numbers {re, im}. Returns null if the solver fails to converge within limits.

Type
Array.<Complex> | null

round(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

scalar(s) → {Scalar}

Description:
  • Factory function for creating Scalar instances.

Source:
Parameters:
Name Type Description
s number | bigint | string | BigFraction | BigFloat | Complex | Scalar
Returns:
Type
Scalar

setGcEleLimit(l)

Description:
  • Set gc_ele_limit

Source:
Parameters:
Name Type Description
l number

setGlobalFlag(f)

Description:
  • Set the global flags for libbf operations.

Source:
Parameters:
Name Type Description
f number

setPrecision(p)

Description:
  • Set the global precision

Source:
Parameters:
Name Type Description
p number

setThrowExceptionOnInvalidOp(f)

Description:
  • Set throwExceptionOnInvalidOp

Source:
Parameters:
Name Type Description
f boolean

shanks(f, infoopt) → {BigFloat|null}

Description:
  • High-precision Sequence Limit using Wynn's Epsilon Algorithm (Shanks Transformation).

    This function estimates the limit of a sequence f(n) as n approaches infinity. It is particularly effective for accelerating the convergence of slowly converging alternating series or sequences.

Source:
Parameters:
Name Type Attributes Default Description
f
info Object <optional>
{}

Configuration and Status object.

Properties
Name Type Attributes Default Description
_e number <optional>
1e-30

Absolute Error Tolerance.

_re number <optional>
info._e

Relative Error Tolerance.

max_step number <optional>
500

Maximum number of terms to evaluate.

max_time number <optional>
60000

Maximum execution time in milliseconds.

cb function <optional>

Optional callback function executed after each iteration.

debug boolean <optional>

Optional flag to enable debug logging.

   // --- Output Status Properties ---
result BigFloat | null

The final calculated limit.

lastresult BigFloat

The best estimate from the most recent iteration.

eff_result string

String representation based on effective precision.

steps number

Current iteration number (n).

error BigFloat

Estimated absolute error.

rerror BigFloat

Estimated relative error.

eff_decimal_precision number

Estimated significant digits.

Returns:

Returns the BigFloat limit value if tolerances are met, or null otherwise.

Type
BigFloat | null

sign(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

sin(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

solveLinearSystem(A, b) → {Array.<BigFloat>}

Description:
  • Helper: Solve Ax = b using Gaussian Elimination with Partial Pivoting

Source:
Parameters:
Name Type Description
A Array.<Array.<BigFloat>>

Matrix (modified in place)

b Array.<BigFloat>

Vector (modified in place)

Returns:

x - Solution vector

Type
Array.<BigFloat>

sqrt(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

tan(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

trunc(v, precopt) → {BigFloat}

Source:
Parameters:
Name Type Attributes Default Description
v BigFloat | number | string | bigint
prec number <optional>
0
Returns:
Type
BigFloat

zeta(s, aopt) → {Complex}

Description:
  • Computes the Riemann Zeta function ζ(s) or Hurwitz Zeta function ζ(s, a).

    Logic:

    1. Handle pole at s = 1.
    2. If Re(s) < 0 and a = 1, use the Reflection Formula to mirror into the right half-plane.
    3. Handle specific Hurwitz reductions (e.g., a = 0.5).
    4. Use the Euler-Maclaurin summation formula for high-precision results.
Source:
Parameters:
Name Type Attributes Default Description
s Complex | number | BigFloat

The complex exponent.

a Complex | number | BigFloat <optional>
1

The shift parameter (default is 1 for Riemann Zeta).

Returns:
Type
Complex