pow_mod
std.elementwise.pow_mod · Level L4Modular exponentiation aᵏ mod m, elementwise, by binary exponentiation: a While over pow_mod_step, one exponent bit per step. Python's pow(a, k, m). The base is reduced modulo m first, so a may be negative.
Signature
pow_mod(a: i64[n], k: i64[n], m: i64[n]) → i64[n]
Structure
The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.
- input
- operation
- constant
- call
- output
Verification
- Signature proven by NOVA’s shape solver, for every size.
- Equal to the reference
pow(a, k, m)in exact rational arithmetic, on all 40 test cases. - All 148 int64 results are exact: the error is zero.
- Interpreter and NumPy backend return bit-identical results.
- At float32 too: the 40 test cases rounded to float32, and 40 of them exact, with zero error.
- correctly rounded (the int64 nearest the exact value)
- 100%
- bit-equal to the NumPy formula in int64
- 100%
- largest error, in units in the last place
- 0
Note
Exact for m up to 9·10⁷, where every product (m − 1)² stays below 2⁵³. k up to 2⁶³ takes at most 63 steps; max_steps is 64.
Identity
sha256:53ed037d33f277e46bdd01760550e5c44df988c45fd86c1a6f4c29fe6cce45cbThe semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.elementwise.pow_mod · Ω:pow_mod
- Pins
sha256:00c0abbed178f16bd64dc3a978ad5a53f05fde15e52eb4b6ec4eb988fbdb9a75this graph and the 2 it reaches through calls- Evidence
sha256:d780efd3f13c148e1cc487e5a157bb330cbfec2bda43c5d72928cb8814f65eccthe hash of its verification record- Needs
- no capability: a pure function
Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.