The math module provides common mathematical functions for scalar and tensor operations.
Warning
Determinism note: the bit-identical cross-substrate guarantee covers integer and Q16.16 fixed-point arithmetic. Scalar f64/f32 arithmetic now runs on the strict deterministic path (run-to-run bit-identical; verified on x86_64 (AVX2) + ARM64 (NEON), 2026-07-05). Correctly-rounded transcendentals (sin, exp, log, …) are still roadmap — they are not part of any bit-identity guarantee today.
Key Exports
sin, cos, tanTrigonometric functions
exp, log, log10Exponential and logarithmic functions
sqrt, pow, absPower and absolute value functions
relu, sigmoid, tanhActivation functions for ML
Example Usage
use math::{exp, relu, sigmoid};
fn softmax(x: Tensor<f32>[N]) -> Tensor<f32>[N] {
let e = exp(x);
return e / sum(e);
}
fn main() {
let logits: Tensor<f32>[4] = [1.0, 2.0, 3.0, 4.0];
let probs = softmax(logits);
print(probs);
}