# ?

Average Error: 12.7 → 0.0
Time: 7.8s
Precision: binary64
Cost: 6528

# ?

$\left(0 \leq x \land x \leq 10^{+18}\right) \land \left(0 \leq y \land y \leq 10^{+18}\right)$
$\sqrt{{x}^{2} + {y}^{2}}$
$\mathsf{hypot}\left(x, y\right)$
(FPCore (x y) :precision binary64 (sqrt (+ (pow x 2.0) (pow y 2.0))))
(FPCore (x y) :precision binary64 (hypot x y))
double code(double x, double y) {
return sqrt((pow(x, 2.0) + pow(y, 2.0)));
}

double code(double x, double y) {
return hypot(x, y);
}

public static double code(double x, double y) {
return Math.sqrt((Math.pow(x, 2.0) + Math.pow(y, 2.0)));
}

public static double code(double x, double y) {
return Math.hypot(x, y);
}

def code(x, y):
return math.sqrt((math.pow(x, 2.0) + math.pow(y, 2.0)))

def code(x, y):
return math.hypot(x, y)

function code(x, y)
return sqrt(Float64((x ^ 2.0) + (y ^ 2.0)))
end

function code(x, y)
return hypot(x, y)
end

function tmp = code(x, y)
tmp = sqrt(((x ^ 2.0) + (y ^ 2.0)));
end

function tmp = code(x, y)
tmp = hypot(x, y);
end

code[x_, y_] := N[Sqrt[N[(N[Power[x, 2.0], $MachinePrecision] + N[Power[y, 2.0],$MachinePrecision]), $MachinePrecision]],$MachinePrecision]

code[x_, y_] := N[Sqrt[x ^ 2 + y ^ 2], \$MachinePrecision]

\sqrt{{x}^{2} + {y}^{2}}

\mathsf{hypot}\left(x, y\right)


# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 12.7

$\sqrt{{x}^{2} + {y}^{2}}$
2. Simplified0.0

$\leadsto \color{blue}{\mathsf{hypot}\left(x, y\right)}$
Proof
[Start]12.7 $\sqrt{{x}^{2} + {y}^{2}}$ $\sqrt{\color{blue}{x \cdot x} + {y}^{2}}$ $\sqrt{x \cdot x + \color{blue}{y \cdot y}}$ $\color{blue}{\mathsf{hypot}\left(x, y\right)}$
3. Final simplification0.0

$\leadsto \mathsf{hypot}\left(x, y\right)$

# Alternatives

Alternative 1
Error30.3
Cost576
$y + 0.5 \cdot \left(x \cdot \frac{x}{y}\right)$
Alternative 2
Error30.6
Cost64
$y$

# Reproduce?

herbie shell --seed 1
(FPCore (x y)
:name "sqrt(x^2+y^2)"
:precision binary64
:pre (and (and (<= 0.0 x) (<= x 1e+18)) (and (<= 0.0 y) (<= y 1e+18)))
(sqrt (+ (pow x 2.0) (pow y 2.0))))