angle_between
std.geometry.angle_between · Level L5The angle between two non-zero vectors, in [0, π], by Kahan's formula 2·atan2(‖|v|u − |u|v‖, ‖|v|u + |u|v‖): its absolute error stays near one unit of roundoff (about 10⁻¹⁷ radians here) at every angle, where acos of the normalized dot product errs by up to √u ≈ 10⁻⁸ near 0 and π, and returns 0 for angles below about 10⁻⁸. Calls norm.
Signature
angle_between(u: f64[n], v: f64[n]) → f64[]
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
2 * arctan2(norm(|v| u − |u| v), norm(|v| u + |u| v))to 80 digits (100-digit arithmetic), on all 40 test cases. - All 40 float64 results inside the running error bound; the closest uses 7% 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 6% of it.
- correctly rounded (the float64 nearest the exact value)
- 88%
- bit-equal to the NumPy formula in float64
- 100%
- largest error, in units in the last place
- 0.84
Identity
sha256:fd27c998182047f855d720e5a067010d08691c6c663e4c5ec979537cbf187ba1The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.geometry.angle_between · Ω:angle_between
- Pins
sha256:cb17079a6962dca320cae94a116810360bf6a13654b0cfb42133a42191dac2ddthis graph and the 3 it reaches through calls- Evidence
sha256:023c78f3489f848345bc76d96c4780e09bb92079e0a8c5c10bef7a7cefe76ce9the 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.