fraction_normalize
std.elementwise.fraction_normalize · Level L4The reduced form of the fraction p/q (q ≠ 0): numerator and denominator divided by gcd(|p|, |q|), with the denominator made positive. It changes the representation and not the value; 0/q becomes 0/1.
p/q = (p/g)/(q/g), g = gcd(|p|, |q|), q/g > 0
Signature
fraction_normalize(p: i64[n], q: i64[n]) → 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
Python's math.gcd and a sign fixin exact rational arithmetic, on all 40 test cases. - All 296 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.
Accuracy in detail
- 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
Identity
sha256:7e80ff5b7fe396c120edd54544373249c403c03003a2d5753990cc142de94121The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.elementwise.fraction_normalize · Ω:fraction_normalize
- Pins
sha256:1aeca5248f8147bf39670f7f1c6584953e6d28c85f4f955f73582aad0943213cthis graph and the 3 it reaches through calls- Evidence
sha256:a54d752f9857a27c420242bb998de89905d7635b12084ebf7bd641f9f6377192the 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.