hydra.overlay.python.lib.math module
Python implementations of hydra.overlay.python.lib.math primitives.
- hydra.overlay.python.lib.math.abs(x)
Return the absolute value. Constraint-polymorphic (‘numeric’).
- hydra.overlay.python.lib.math.abs_(x)
Return the absolute value. Constraint-polymorphic (‘numeric’).
- hydra.overlay.python.lib.math.acos(x: float) float
Return the arc cosine of x in radians.
- hydra.overlay.python.lib.math.acosh(x: float) float
Return the inverse hyperbolic cosine of x.
- hydra.overlay.python.lib.math.add(x, y)
Add two numbers (constraint-polymorphic over the ‘numeric’ class).
- hydra.overlay.python.lib.math.add_float64(x: float, y: float) float
Add two Float64 numbers.
- hydra.overlay.python.lib.math.asin(x: float) float
Return the arc sine of x in radians.
- hydra.overlay.python.lib.math.asinh(x: float) float
Return the inverse hyperbolic sine of x.
- hydra.overlay.python.lib.math.atan(x: float) float
Return the arc tangent of x in radians.
- hydra.overlay.python.lib.math.atan2(y: float, x: float) float
Return the arc tangent of y/x in radians, using signs to determine quadrant. Matches Haskell behavior: returns NaN when both arguments are infinite.
- hydra.overlay.python.lib.math.atanh(x: float) float
Return the inverse hyperbolic tangent of x.
- hydra.overlay.python.lib.math.ceiling(x: float) float
Return the ceiling of x as a float. Returns NaN/Inf for NaN/Inf inputs, matching Haskell/Java IEEE 754 behavior.
- hydra.overlay.python.lib.math.cos(x: float) float
Return the cosine of x radians.
- hydra.overlay.python.lib.math.cosh(x: float) float
Return the hyperbolic cosine of x.
- hydra.overlay.python.lib.math.div(x, y) Optional
Divide two integers (floor division), returning none if the divisor is zero. Constraint-polymorphic (‘integral’).
- hydra.overlay.python.lib.math.divide(x, y)
Floating-point division. Constraint-polymorphic (‘fractional’); IEEE 754 total (the Python native / raises ZeroDivisionError at x/0.0, so the zero-divisor case is guarded).
- hydra.overlay.python.lib.math.e() float
Euler’s number (e ≈ 2.71828).
- hydra.overlay.python.lib.math.even(x) bool
Check if an integer is even. Constraint-polymorphic (‘integral’).
- hydra.overlay.python.lib.math.exp(x: float) float
Return e raised to the power x.
- hydra.overlay.python.lib.math.floor(x: float) float
Return the floor of x as a float. Returns NaN/Inf for NaN/Inf inputs, matching Haskell/Java IEEE 754 behavior.
- hydra.overlay.python.lib.math.log(x: float) float
Return the natural logarithm of x.
- hydra.overlay.python.lib.math.log_base(base: float, x: float) float
Return the logarithm of x to the given base.
- hydra.overlay.python.lib.math.max(x: int, y: int) int
Return the maximum of two values.
- hydra.overlay.python.lib.math.max_(x: int, y: int) int
Return the maximum of two values.
- hydra.overlay.python.lib.math.maybe_pred(x: int) object
Return the predecessor, returning none if x is minBound.
- hydra.overlay.python.lib.math.maybe_succ(x: int) object
Return the successor, returning none if x is maxBound.
- hydra.overlay.python.lib.math.min(x: int, y: int) int
Return the minimum of two values.
- hydra.overlay.python.lib.math.min_(x: int, y: int) int
Return the minimum of two values.
- hydra.overlay.python.lib.math.mod(x, y) Optional
Mathematical modulo (floor-based, sign follows the divisor), returning none if the divisor is zero. Constraint-polymorphic (‘integral’).
- hydra.overlay.python.lib.math.mul(x, y)
Multiply two numbers (constraint-polymorphic over the ‘numeric’ class).
- hydra.overlay.python.lib.math.mul_float64(x: float, y: float) float
Multiply two Float64 numbers.
- hydra.overlay.python.lib.math.negate(x)
Negate a number (constraint-polymorphic over the ‘numeric’ class).
- hydra.overlay.python.lib.math.negate_float64(x: float) float
Negate a Float64 number.
- hydra.overlay.python.lib.math.odd(x) bool
Check if an integer is odd. Constraint-polymorphic (‘integral’).
- hydra.overlay.python.lib.math.pi() float
Pi (π ≈ 3.14159).
- hydra.overlay.python.lib.math.pow(x: float, y: float) float
Return x raised to the power y. Matches Java Math.pow / Haskell (**) IEEE 754 behavior.
- hydra.overlay.python.lib.math.pow_(x: float, y: float) float
Return x raised to the power y. Matches Java Math.pow / Haskell (**) IEEE 754 behavior.
- hydra.overlay.python.lib.math.range_(start: int, end: int) tuple
Generate a half-open range of values from start (inclusive) to end (exclusive).
- hydra.overlay.python.lib.math.rem(x, y) Optional
Integer remainder (truncated, sign follows the dividend), returning none if the divisor is zero. Constraint-polymorphic (‘integral’).
- hydra.overlay.python.lib.math.round(x: float) float
Return x rounded to the nearest integer as a float. Returns NaN/Inf for NaN/Inf inputs, matching Haskell/Java IEEE 754 behavior.
- hydra.overlay.python.lib.math.round_(x: float) float
Return x rounded to the nearest integer as a float. Returns NaN/Inf for NaN/Inf inputs, matching Haskell/Java IEEE 754 behavior.
- hydra.overlay.python.lib.math.round_float32(n: int, x: float) float
Round a float32 to n significant digits.
- hydra.overlay.python.lib.math.round_float64(n: int, x: float) float
Round a float64 to n significant digits.
- hydra.overlay.python.lib.math.signum(x)
Return the sign of a number. Constraint-polymorphic (‘numeric’).
For integers: -1, 0, or 1. For floats: IEEE 754 §5.5.1 semantics — signum(NaN) is NaN, signum(+-0.0) preserves the input’s sign (returns +-0.0, not a bare 0), and nonzero finite or infinite x returns +-1.0 via math.copysign. A naive three-branch (x<0/x>0/else 0) implementation gets both of these float cases wrong (round4 finding).
- hydra.overlay.python.lib.math.sin(x: float) float
Return the sine of x radians.
- hydra.overlay.python.lib.math.sinh(x: float) float
Return the hyperbolic sine of x.
- hydra.overlay.python.lib.math.sqrt(x: float) float
Return the square root of x.
- hydra.overlay.python.lib.math.sub(x, y)
Subtract two numbers (constraint-polymorphic over the ‘numeric’ class).
- hydra.overlay.python.lib.math.sub_float64(x: float, y: float) float
Subtract two Float64 numbers.
- hydra.overlay.python.lib.math.tan(x: float) float
Return the tangent of x radians.
- hydra.overlay.python.lib.math.tanh(x: float) float
Return the hyperbolic tangent of x.
- hydra.overlay.python.lib.math.truncate(x: float) float
Return x truncated to an integer as a float (towards zero). Returns NaN/Inf for NaN/Inf inputs, matching Haskell/Java IEEE 754 behavior.