quadratic_roots
std.elementwise.quadratic_roots · Level L1The roots of a·x² + b·x + c = 0, a ≠ 0, elementwise, in the form that avoids cancellation: q = −(b + sign(b)·√D)/2 with D = b² − 4ac, then x₁ = q/a and x₂ = c/q. For D < 0 the roots are re ± i·im, with re₁ = re₂ = −b/(2a) and im = √(−D)/|2a|; for D ≥ 0, im = 0. The naive (−b ± √D)/(2a) loses the smaller root to cancellation when b² ≫ |4ac|.
Signature
quadratic_roots(a: f64[n], b: f64[n], c: f64[n]) → f64[n], f64[n], f64[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.
- Agrees with the reference
(−b ∓ sgn(b)√D)/(2a) for D ≥ 0; −b/(2a) ± i√(−D)/|2a| for D < 0to 80 digits (100-digit arithmetic), on all 40 test cases. - All 447 float64 results inside the running error bound; the closest uses 79% of it.
- Interpreter and NumPy backend return bit-identical results.
- At float32 too: the 40 test cases rounded to float32, and 40 of them inside the running error bound at u = 2⁻²⁴; the closest uses 87% of it.
- correctly rounded (the float64 nearest the exact value)
- 84%
- bit-equal to the NumPy formula in float64
- 77%
- largest error, in units in the last place
- 4.79
Note
Whether D < 0 is a decision. Near a double root D is close to 0, and whether the roots are real or complex is not certain; such a case is uncertified, which is the problem's own ill-conditioning. The verification takes c ≠ 0, which keeps q away from 0. For b = c = 0 (a·x² = 0) NOVA returns 0 and 0, but the oracle's floor on the error of √0 leaves q = 0 uncertain, so that case is not certified.
Identity
sha256:ea197342096e22f2538c7d76ea171134321611ebf8fc1e0469e271f91e5b9c12The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.elementwise.quadratic_roots · Ω:quadratic_roots
- Pins
sha256:80aff3dc7b8864fdb70d6511f4675fb26ab887086d092bedd95725335105ee53this graph alone- Evidence
sha256:1e26112dd42fe38ca4cb5bb11c079a941335ac629ea2fc3a59de78ab4b556b72the 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.