Standard Library: Math
The math module provides common mathematical functions for scalar and tensor operations.
Determinism note: the bit-identical cross-substrate guarantee covers integer and Q16.16 fixed-point arithmetic. Scalar
f64/f32arithmetic 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,tan— Trigonometric functions.exp,log,log10— Exponential and logarithmic functions.sqrt,pow,abs— Power and absolute value functions.relu,sigmoid,tanh— Activation 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);
}