///|
/// Returns the square root of the sum of the squares of its arguments, hypot(x, y) = sqrt(x*x, y*y)
/// # Notes
///
/// `hypot` return the square root of the sum of the squares of its arguments, the formula is:
///
/// $$hypot(x) = \sqrt{x^2 + y^2}$$
///
/// # Examples
///
/// ```moonbit nocheck
/// assert_eq(hypot(3, 4), 5)
/// assert_eq(hypot(6, 8), 10)
/// assert_eq(hypot(5, 12), 13)
/// assert_eq(hypot(7, 24), 25)
/// assert_eq(hypot(3.14, -2.71), 4.147734321289154)
/// assert_eq(hypot(-3.14, 2.71), 4.147734321289154)
/// ```
///
/// # Accuracy
///
/// 2 ulps (units in the last place)
///
/// # Special cases
///
/// 1. If x or y is NaN, return NaN
/// 2. If x or y is inf, return +inf
pub fn hypot(x : Double, y : Double) -> Double {
let x = fabs(x)
let y = fabs(y)
if isinf(x) || isinf(y) {
return @double.infinity
}
let (x, y) = if y > x { (y, x) } else { (x, y) }
if x * double_epsilon >= y {
return x
}
let rat = y / x
x * sqrt(1.0 + rat * rat)
}
///|
test "hypot" {
fn assert_hypot_ulp(input1, input2, expect) raise {
assert_ulp(expect, hypot(input1, input2), HYPOT_MAX_ULP)
}
assert_hypot_ulp(0, 0, 0)
assert_hypot_ulp(0, -0, 0)
assert_hypot_ulp(0, 1, 1)
assert_hypot_ulp(0, -1, 1)
assert_hypot_ulp(0, 2, 2)
assert_hypot_ulp(0, -2, 2)
assert_hypot_ulp(0, 3.14159, 3.14159)
assert_hypot_ulp(0, -3.14159, 3.14159)
assert_hypot_ulp(0, -2.71828, 2.71828)
assert_hypot_ulp(0, 2.71828, 2.71828)
assert_hypot_ulp(0, 1000, 1000)
assert_hypot_ulp(0, -1000, 1000)
assert_hypot_ulp(0, 0.5, 0.5)
assert_hypot_ulp(0, -0.5, 0.5)
assert_hypot_ulp(0, 0.00005, 0.00005)
assert_hypot_ulp(0, -0.00005, 0.00005)
assert_hypot_ulp(0, 0.0027818, 0.0027818)
assert_hypot_ulp(0, -0.0027818, 0.0027818)
assert_hypot_ulp(0, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-0, 0, 0)
assert_hypot_ulp(-0, -0, 0)
assert_hypot_ulp(-0, 1, 1)
assert_hypot_ulp(-0, -1, 1)
assert_hypot_ulp(-0, 2, 2)
assert_hypot_ulp(-0, -2, 2)
assert_hypot_ulp(-0, 3.14159, 3.14159)
assert_hypot_ulp(-0, -3.14159, 3.14159)
assert_hypot_ulp(-0, -2.71828, 2.71828)
assert_hypot_ulp(-0, 2.71828, 2.71828)
assert_hypot_ulp(-0, 1000, 1000)
assert_hypot_ulp(-0, -1000, 1000)
assert_hypot_ulp(-0, 0.5, 0.5)
assert_hypot_ulp(-0, -0.5, 0.5)
assert_hypot_ulp(-0, 0.00005, 0.00005)
assert_hypot_ulp(-0, -0.00005, 0.00005)
assert_hypot_ulp(-0, 0.0027818, 0.0027818)
assert_hypot_ulp(-0, -0.0027818, 0.0027818)
assert_hypot_ulp(-0, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(1, 0, 1)
assert_hypot_ulp(1, -0, 1)
assert_hypot_ulp(1, 1, 1.4142135623730951)
assert_hypot_ulp(1, -1, 1.4142135623730951)
assert_hypot_ulp(1, 2, 2.23606797749979)
assert_hypot_ulp(1, -2, 2.23606797749979)
assert_hypot_ulp(1, 3.14159, 3.296905780895171)
assert_hypot_ulp(1, -3.14159, 3.296905780895171)
assert_hypot_ulp(1, -2.71828, 2.8963850155668185)
assert_hypot_ulp(1, 2.71828, 2.8963850155668185)
assert_hypot_ulp(1, 1000, 1000.000499999875)
assert_hypot_ulp(1, -1000, 1000.000499999875)
assert_hypot_ulp(1, 0.5, 1.118033988749895)
assert_hypot_ulp(1, -0.5, 1.118033988749895)
assert_hypot_ulp(1, 0.00005, 1.0000000012499999)
assert_hypot_ulp(1, -0.00005, 1.0000000012499999)
assert_hypot_ulp(1, 0.0027818, 1.0000038691981346)
assert_hypot_ulp(1, -0.0027818, 1.0000038691981346)
assert_hypot_ulp(1, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-1, 0, 1)
assert_hypot_ulp(-1, -0, 1)
assert_hypot_ulp(-1, 1, 1.4142135623730951)
assert_hypot_ulp(-1, -1, 1.4142135623730951)
assert_hypot_ulp(-1, 2, 2.23606797749979)
assert_hypot_ulp(-1, -2, 2.23606797749979)
assert_hypot_ulp(-1, 3.14159, 3.296905780895171)
assert_hypot_ulp(-1, -3.14159, 3.296905780895171)
assert_hypot_ulp(-1, -2.71828, 2.8963850155668185)
assert_hypot_ulp(-1, 2.71828, 2.8963850155668185)
assert_hypot_ulp(-1, 1000, 1000.000499999875)
assert_hypot_ulp(-1, -1000, 1000.000499999875)
assert_hypot_ulp(-1, 0.5, 1.118033988749895)
assert_hypot_ulp(-1, -0.5, 1.118033988749895)
assert_hypot_ulp(-1, 0.00005, 1.0000000012499999)
assert_hypot_ulp(-1, -0.00005, 1.0000000012499999)
assert_hypot_ulp(-1, 0.0027818, 1.0000038691981346)
assert_hypot_ulp(-1, -0.0027818, 1.0000038691981346)
assert_hypot_ulp(-1, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(2, 0, 2)
assert_hypot_ulp(2, -0, 2)
assert_hypot_ulp(2, 1, 2.23606797749979)
assert_hypot_ulp(2, -1, 2.23606797749979)
assert_hypot_ulp(2, 2, 2.8284271247461903)
assert_hypot_ulp(2, -2, 2.8284271247461903)
assert_hypot_ulp(2, 3.14159, 3.724189539765665)
assert_hypot_ulp(2, -3.14159, 3.724189539765665)
assert_hypot_ulp(2, -2.71828, 3.37476608943494)
assert_hypot_ulp(2, 2.71828, 3.37476608943494)
assert_hypot_ulp(2, 1000, 1000.001999998)
assert_hypot_ulp(2, -1000, 1000.001999998)
assert_hypot_ulp(2, 0.5, 2.06155281280883)
assert_hypot_ulp(2, -0.5, 2.06155281280883)
assert_hypot_ulp(2, 0.00005, 2.000000000625)
assert_hypot_ulp(2, -0.00005, 2.000000000625)
assert_hypot_ulp(2, 0.0027818, 2.000001934601874)
assert_hypot_ulp(2, -0.0027818, 2.000001934601874)
assert_hypot_ulp(2, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-2, 0, 2)
assert_hypot_ulp(-2, -0, 2)
assert_hypot_ulp(-2, 1, 2.23606797749979)
assert_hypot_ulp(-2, -1, 2.23606797749979)
assert_hypot_ulp(-2, 2, 2.8284271247461903)
assert_hypot_ulp(-2, -2, 2.8284271247461903)
assert_hypot_ulp(-2, 3.14159, 3.724189539765665)
assert_hypot_ulp(-2, -3.14159, 3.724189539765665)
assert_hypot_ulp(-2, -2.71828, 3.37476608943494)
assert_hypot_ulp(-2, 2.71828, 3.37476608943494)
assert_hypot_ulp(-2, 1000, 1000.001999998)
assert_hypot_ulp(-2, -1000, 1000.001999998)
assert_hypot_ulp(-2, 0.5, 2.06155281280883)
assert_hypot_ulp(-2, -0.5, 2.06155281280883)
assert_hypot_ulp(-2, 0.00005, 2.000000000625)
assert_hypot_ulp(-2, -0.00005, 2.000000000625)
assert_hypot_ulp(-2, 0.0027818, 2.000001934601874)
assert_hypot_ulp(-2, -0.0027818, 2.000001934601874)
assert_hypot_ulp(-2, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(3.14159, 0, 3.14159)
assert_hypot_ulp(3.14159, -0, 3.14159)
assert_hypot_ulp(3.14159, 1, 3.296905780895171)
assert_hypot_ulp(3.14159, -1, 3.296905780895171)
assert_hypot_ulp(3.14159, 2, 3.724189539765665)
assert_hypot_ulp(3.14159, -2, 3.724189539765665)
assert_hypot_ulp(3.14159, 3.14159, 4.442879185415692)
assert_hypot_ulp(3.14159, -3.14159, 4.442879185415692)
assert_hypot_ulp(3.14159, -2.71828, 4.154351199224736)
assert_hypot_ulp(3.14159, 2.71828, 4.154351199224736)
assert_hypot_ulp(3.14159, 1000, 1000.004934781688)
assert_hypot_ulp(3.14159, -1000, 1000.004934781688)
assert_hypot_ulp(3.14159, 0.5, 3.181129945176713)
assert_hypot_ulp(3.14159, -0.5, 3.181129945176713)
assert_hypot_ulp(3.14159, 0.00005, 3.141590000397887)
assert_hypot_ulp(3.14159, -0.00005, 3.141590000397887)
assert_hypot_ulp(3.14159, 0.0027818, 3.1415912316072)
assert_hypot_ulp(3.14159, -0.0027818, 3.1415912316072)
assert_hypot_ulp(3.14159, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-3.14159, 0, 3.14159)
assert_hypot_ulp(-3.14159, -0, 3.14159)
assert_hypot_ulp(-3.14159, 1, 3.296905780895171)
assert_hypot_ulp(-3.14159, -1, 3.296905780895171)
assert_hypot_ulp(-3.14159, 2, 3.724189539765665)
assert_hypot_ulp(-3.14159, -2, 3.724189539765665)
assert_hypot_ulp(-3.14159, 3.14159, 4.442879185415692)
assert_hypot_ulp(-3.14159, -3.14159, 4.442879185415692)
assert_hypot_ulp(-3.14159, -2.71828, 4.154351199224736)
assert_hypot_ulp(-3.14159, 2.71828, 4.154351199224736)
assert_hypot_ulp(-3.14159, 1000, 1000.004934781688)
assert_hypot_ulp(-3.14159, -1000, 1000.004934781688)
assert_hypot_ulp(-3.14159, 0.5, 3.181129945176713)
assert_hypot_ulp(-3.14159, -0.5, 3.181129945176713)
assert_hypot_ulp(-3.14159, 0.00005, 3.141590000397887)
assert_hypot_ulp(-3.14159, -0.00005, 3.141590000397887)
assert_hypot_ulp(-3.14159, 0.0027818, 3.1415912316072)
assert_hypot_ulp(-3.14159, -0.0027818, 3.1415912316072)
assert_hypot_ulp(-3.14159, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-2.71828, 0, 2.71828)
assert_hypot_ulp(-2.71828, -0, 2.71828)
assert_hypot_ulp(-2.71828, 1, 2.8963850155668185)
assert_hypot_ulp(-2.71828, -1, 2.8963850155668185)
assert_hypot_ulp(-2.71828, 2, 3.37476608943494)
assert_hypot_ulp(-2.71828, -2, 3.37476608943494)
assert_hypot_ulp(-2.71828, 3.14159, 4.154351199224736)
assert_hypot_ulp(-2.71828, -3.14159, 4.154351199224736)
assert_hypot_ulp(-2.71828, -2.71828, 3.844228442327537)
assert_hypot_ulp(-2.71828, 2.71828, 3.844228442327537)
assert_hypot_ulp(-2.71828, 1000, 1000.0036945162544)
assert_hypot_ulp(-2.71828, -1000, 1000.0036945162544)
assert_hypot_ulp(-2.71828, 0.5, 2.76388244294145)
assert_hypot_ulp(-2.71828, -0.5, 2.76388244294145)
assert_hypot_ulp(-2.71828, 0.00005, 2.71828000045985)
assert_hypot_ulp(-2.71828, -0.00005, 2.71828000045985)
assert_hypot_ulp(-2.71828, 0.0027818, 2.718281423401787)
assert_hypot_ulp(-2.71828, -0.0027818, 2.718281423401787)
assert_hypot_ulp(-2.71828, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(2.71828, 0, 2.71828)
assert_hypot_ulp(2.71828, -0, 2.71828)
assert_hypot_ulp(2.71828, 1, 2.8963850155668185)
assert_hypot_ulp(2.71828, -1, 2.8963850155668185)
assert_hypot_ulp(2.71828, 2, 3.37476608943494)
assert_hypot_ulp(2.71828, -2, 3.37476608943494)
assert_hypot_ulp(2.71828, 3.14159, 4.154351199224736)
assert_hypot_ulp(2.71828, -3.14159, 4.154351199224736)
assert_hypot_ulp(2.71828, -2.71828, 3.844228442327537)
assert_hypot_ulp(2.71828, 2.71828, 3.844228442327537)
assert_hypot_ulp(2.71828, 1000, 1000.0036945162544)
assert_hypot_ulp(2.71828, -1000, 1000.0036945162544)
assert_hypot_ulp(2.71828, 0.5, 2.76388244294145)
assert_hypot_ulp(2.71828, -0.5, 2.76388244294145)
assert_hypot_ulp(2.71828, 0.00005, 2.71828000045985)
assert_hypot_ulp(2.71828, -0.00005, 2.71828000045985)
assert_hypot_ulp(2.71828, 0.0027818, 2.718281423401787)
assert_hypot_ulp(2.71828, -0.0027818, 2.718281423401787)
assert_hypot_ulp(2.71828, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(1000, 0, 1000)
assert_hypot_ulp(1000, -0, 1000)
assert_hypot_ulp(1000, 1, 1000.000499999875)
assert_hypot_ulp(1000, -1, 1000.000499999875)
assert_hypot_ulp(1000, 2, 1000.001999998)
assert_hypot_ulp(1000, -2, 1000.001999998)
assert_hypot_ulp(1000, 3.14159, 1000.004934781688)
assert_hypot_ulp(1000, -3.14159, 1000.004934781688)
assert_hypot_ulp(1000, -2.71828, 1000.0036945162544)
assert_hypot_ulp(1000, 2.71828, 1000.0036945162544)
assert_hypot_ulp(1000, 1000, 1414.213562373095)
assert_hypot_ulp(1000, -1000, 1414.213562373095)
assert_hypot_ulp(1000, 0.5, 1000.0001249999922)
assert_hypot_ulp(1000, -0.5, 1000.0001249999922)
assert_hypot_ulp(1000, 0.00005, 1000.000000000001)
assert_hypot_ulp(1000, -0.00005, 1000.000000000001)
assert_hypot_ulp(1000, 0.0027818, 1000.000000003869)
assert_hypot_ulp(1000, -0.0027818, 1000.000000003869)
assert_hypot_ulp(1000, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-1000, 0, 1000)
assert_hypot_ulp(-1000, -0, 1000)
assert_hypot_ulp(-1000, 1, 1000.000499999875)
assert_hypot_ulp(-1000, -1, 1000.000499999875)
assert_hypot_ulp(-1000, 2, 1000.001999998)
assert_hypot_ulp(-1000, -2, 1000.001999998)
assert_hypot_ulp(-1000, 3.14159, 1000.004934781688)
assert_hypot_ulp(-1000, -3.14159, 1000.004934781688)
assert_hypot_ulp(-1000, -2.71828, 1000.0036945162544)
assert_hypot_ulp(-1000, 2.71828, 1000.0036945162544)
assert_hypot_ulp(-1000, 1000, 1414.213562373095)
assert_hypot_ulp(-1000, -1000, 1414.213562373095)
assert_hypot_ulp(-1000, 0.5, 1000.0001249999922)
assert_hypot_ulp(-1000, -0.5, 1000.0001249999922)
assert_hypot_ulp(-1000, 0.00005, 1000.000000000001)
assert_hypot_ulp(-1000, -0.00005, 1000.000000000001)
assert_hypot_ulp(-1000, 0.0027818, 1000.000000003869)
assert_hypot_ulp(-1000, -0.0027818, 1000.000000003869)
assert_hypot_ulp(-1000, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(0.5, 0, 0.5)
assert_hypot_ulp(0.5, -0, 0.5)
assert_hypot_ulp(0.5, 1, 1.118033988749895)
assert_hypot_ulp(0.5, -1, 1.118033988749895)
assert_hypot_ulp(0.5, 2, 2.06155281280883)
assert_hypot_ulp(0.5, -2, 2.06155281280883)
assert_hypot_ulp(0.5, 3.14159, 3.181129945176713)
assert_hypot_ulp(0.5, -3.14159, 3.181129945176713)
assert_hypot_ulp(0.5, -2.71828, 2.76388244294145)
assert_hypot_ulp(0.5, 2.71828, 2.76388244294145)
assert_hypot_ulp(0.5, 1000, 1000.0001249999922)
assert_hypot_ulp(0.5, -1000, 1000.0001249999922)
assert_hypot_ulp(0.5, 0.5, 0.7071067811865476)
assert_hypot_ulp(0.5, -0.5, 0.7071067811865476)
assert_hypot_ulp(0.5, 0.00005, 0.5000000025)
assert_hypot_ulp(0.5, -0.00005, 0.5000000025)
assert_hypot_ulp(0.5, 0.0027818, 0.5000077383513579)
assert_hypot_ulp(0.5, -0.0027818, 0.5000077383513579)
assert_hypot_ulp(0.5, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-0.5, 0, 0.5)
assert_hypot_ulp(-0.5, -0, 0.5)
assert_hypot_ulp(-0.5, 1, 1.118033988749895)
assert_hypot_ulp(-0.5, -1, 1.118033988749895)
assert_hypot_ulp(-0.5, 2, 2.06155281280883)
assert_hypot_ulp(-0.5, -2, 2.06155281280883)
assert_hypot_ulp(-0.5, 3.14159, 3.181129945176713)
assert_hypot_ulp(-0.5, -3.14159, 3.181129945176713)
assert_hypot_ulp(-0.5, -2.71828, 2.76388244294145)
assert_hypot_ulp(-0.5, 2.71828, 2.76388244294145)
assert_hypot_ulp(-0.5, 1000, 1000.0001249999922)
assert_hypot_ulp(-0.5, -1000, 1000.0001249999922)
assert_hypot_ulp(-0.5, 0.5, 0.7071067811865476)
assert_hypot_ulp(-0.5, -0.5, 0.7071067811865476)
assert_hypot_ulp(-0.5, 0.00005, 0.5000000025)
assert_hypot_ulp(-0.5, -0.00005, 0.5000000025)
assert_hypot_ulp(-0.5, 0.0027818, 0.5000077383513579)
assert_hypot_ulp(-0.5, -0.0027818, 0.5000077383513579)
assert_hypot_ulp(-0.5, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(0.00005, 0, 0.00005)
assert_hypot_ulp(0.00005, -0, 0.00005)
assert_hypot_ulp(0.00005, 1, 1.0000000012499999)
assert_hypot_ulp(0.00005, -1, 1.0000000012499999)
assert_hypot_ulp(0.00005, 2, 2.000000000625)
assert_hypot_ulp(0.00005, -2, 2.000000000625)
assert_hypot_ulp(0.00005, 3.14159, 3.141590000397887)
assert_hypot_ulp(0.00005, -3.14159, 3.141590000397887)
assert_hypot_ulp(0.00005, -2.71828, 2.71828000045985)
assert_hypot_ulp(0.00005, 2.71828, 2.71828000045985)
assert_hypot_ulp(0.00005, 1000, 1000.000000000001)
assert_hypot_ulp(0.00005, -1000, 1000.000000000001)
assert_hypot_ulp(0.00005, 0.5, 0.5000000025)
assert_hypot_ulp(0.00005, -0.5, 0.5000000025)
assert_hypot_ulp(0.00005, 0.00005, 7.071067811865475e-05)
assert_hypot_ulp(0.00005, -0.00005, 7.071067811865475e-05)
assert_hypot_ulp(0.00005, 0.0027818, 0.002782249313055896)
assert_hypot_ulp(0.00005, -0.0027818, 0.002782249313055896)
assert_hypot_ulp(0.00005, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-0.00005, 0, 0.00005)
assert_hypot_ulp(-0.00005, -0, 0.00005)
assert_hypot_ulp(-0.00005, 1, 1.0000000012499999)
assert_hypot_ulp(-0.00005, -1, 1.0000000012499999)
assert_hypot_ulp(-0.00005, 2, 2.000000000625)
assert_hypot_ulp(-0.00005, -2, 2.000000000625)
assert_hypot_ulp(-0.00005, 3.14159, 3.141590000397887)
assert_hypot_ulp(-0.00005, -3.14159, 3.141590000397887)
assert_hypot_ulp(-0.00005, -2.71828, 2.71828000045985)
assert_hypot_ulp(-0.00005, 2.71828, 2.71828000045985)
assert_hypot_ulp(-0.00005, 1000, 1000.000000000001)
assert_hypot_ulp(-0.00005, -1000, 1000.000000000001)
assert_hypot_ulp(-0.00005, 0.5, 0.5000000025)
assert_hypot_ulp(-0.00005, -0.5, 0.5000000025)
assert_hypot_ulp(-0.00005, 0.00005, 7.071067811865475e-05)
assert_hypot_ulp(-0.00005, -0.00005, 7.071067811865475e-05)
assert_hypot_ulp(-0.00005, 0.0027818, 0.002782249313055896)
assert_hypot_ulp(-0.00005, -0.0027818, 0.002782249313055896)
assert_hypot_ulp(-0.00005, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(0.0027818, 0, 0.0027818)
assert_hypot_ulp(0.0027818, -0, 0.0027818)
assert_hypot_ulp(0.0027818, 1, 1.0000038691981346)
assert_hypot_ulp(0.0027818, -1, 1.0000038691981346)
assert_hypot_ulp(0.0027818, 2, 2.000001934601874)
assert_hypot_ulp(0.0027818, -2, 2.000001934601874)
assert_hypot_ulp(0.0027818, 3.14159, 3.1415912316072)
assert_hypot_ulp(0.0027818, -3.14159, 3.1415912316072)
assert_hypot_ulp(0.0027818, -2.71828, 2.718281423401787)
assert_hypot_ulp(0.0027818, 2.71828, 2.718281423401787)
assert_hypot_ulp(0.0027818, 1000, 1000.000000003869)
assert_hypot_ulp(0.0027818, -1000, 1000.000000003869)
assert_hypot_ulp(0.0027818, 0.5, 0.5000077383513579)
assert_hypot_ulp(0.0027818, -0.5, 0.5000077383513579)
assert_hypot_ulp(0.0027818, 0.00005, 0.002782249313055896)
assert_hypot_ulp(0.0027818, -0.00005, 0.002782249313055896)
assert_hypot_ulp(0.0027818, 0.0027818, 0.003934059287809476)
assert_hypot_ulp(0.0027818, -0.0027818, 0.003934059287809476)
assert_hypot_ulp(0.0027818, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(-0.0027818, 0, 0.0027818)
assert_hypot_ulp(-0.0027818, -0, 0.0027818)
assert_hypot_ulp(-0.0027818, 1, 1.0000038691981346)
assert_hypot_ulp(-0.0027818, -1, 1.0000038691981346)
assert_hypot_ulp(-0.0027818, 2, 2.000001934601874)
assert_hypot_ulp(-0.0027818, -2, 2.000001934601874)
assert_hypot_ulp(-0.0027818, 3.14159, 3.1415912316072)
assert_hypot_ulp(-0.0027818, -3.14159, 3.1415912316072)
assert_hypot_ulp(-0.0027818, -2.71828, 2.718281423401787)
assert_hypot_ulp(-0.0027818, 2.71828, 2.718281423401787)
assert_hypot_ulp(-0.0027818, 1000, 1000.000000003869)
assert_hypot_ulp(-0.0027818, -1000, 1000.000000003869)
assert_hypot_ulp(-0.0027818, 0.5, 0.5000077383513579)
assert_hypot_ulp(-0.0027818, -0.5, 0.5000077383513579)
assert_hypot_ulp(-0.0027818, 0.00005, 0.002782249313055896)
assert_hypot_ulp(-0.0027818, -0.00005, 0.002782249313055896)
assert_hypot_ulp(-0.0027818, 0.0027818, 0.003934059287809476)
assert_hypot_ulp(-0.0027818, -0.0027818, 0.003934059287809476)
assert_hypot_ulp(-0.0027818, @double.not_a_number, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 0, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -0, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 1, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -1, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 2, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -2, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 3.14159, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -3.14159, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -2.71828, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 2.71828, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 1000, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -1000, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 0.5, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -0.5, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 0.00005, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -0.00005, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, 0.0027818, @double.not_a_number)
assert_hypot_ulp(@double.not_a_number, -0.0027818, @double.not_a_number)
assert_hypot_ulp(
@double.not_a_number, @double.not_a_number, @double.not_a_number,
)
assert_hypot_ulp(@double.infinity, 0, @double.infinity)
assert_hypot_ulp(3, @double.neg_infinity, @double.infinity)
}