The package registry is still being built. The docs are live, everything else is a preview.

Edge Python

Sign In

Sign in to publish packages and pin them by sha256.


By continuing, you accept our Terms and Conditions.

@
Palette

math (js, cli)

math is scalar math on libm, with ValueError: math domain error for domain errors. Declare it with edge add math and import it by bare name. To pin a different version, point the edge.json entry at another URL, see Modules.

Module constants are pi, e, tau, inf, nan (values, not calls). Integer helpers are factorial, gcd, lcm, isqrt, comb, perm, bounded by the VM’s 128-bit integers. hypot and gcd are variadic. modf and frexp return tuples, and floor, ceil, and trunc return int. The rest of the scalar surface, by group:

  • Power and log: sqrt, cbrt, exp, exp2, expm1, pow, log (optional base), log2, log10, log1p.
  • Trigonometric: sin, cos, tan, asin, acos, atan, atan2, hypot, dist.
  • Hyperbolic: sinh, cosh, tanh, asinh, acosh, atanh.
  • Angular and special: degrees, radians, erf, erfc, gamma, lgamma.
  • Float ops and classification: fabs, fmod, remainder, copysign, ldexp, modf, frexp, floor, ceil, trunc, isnan, isinf, isfinite.
  • Reductions: fsum, prod (returns float, even for integer inputs).

There is no complex-number surface. A batch path processes a whole bytes buffer of little-endian f64 values in one call, and pairs with struct for numeric work. Element-wise: sqrt_all, abs_all, exp_all, log_all, sin_all, cos_all. Same-length pairs: add_all, sub_all, mul_all. Scalar broadcast: scale_all(buf, k). Reductions to a float: fsum_all, prod_all, dot_all. Row-major matrix times vector: matvec(m, x, cols). A buffer length that is not a multiple of 8, or mismatched operand lengths, raises ValueError.

cmd + enter
1.4142135623730951
3.141592653589793
13.0
120
Output

The integer helpers return int:

cmd + enter
6
12
9
10 20
Output

modf and frexp decompose a float into tuples, and floor, ceil, and trunc return int:

cmd + enter
(0.75, 3.0)
(0.75, 4)
2 3 -2
Output

The batch functions work on a bytes buffer of little-endian f64 values. Pack it with struct:

cmd + enter
6.0
[10.0, 20.0, 30.0]
14.0
Output