# ?

Average Error: 38.2 → 0.0
Time: 4.8s
Precision: binary64
Cost: 6528

# ?

$\left(\left(0 \leq x \land x \leq 1.79 \cdot 10^{+308}\right) \land \left(0 \leq y \land y \leq 1.79 \cdot 10^{+308}\right)\right) \land \left(0 \leq z \land z \leq 1.79 \cdot 10^{+308}\right)$
$\begin{array}{c}[x, y, z] = \mathsf{sort}([x, y, z])\\ \end{array}$
$\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}$
$\mathsf{hypot}\left(y, z\right)$
(FPCore (x y z) :precision binary64 (sqrt (+ (+ (* x x) (* y y)) (* z z))))
(FPCore (x y z) :precision binary64 (hypot y z))
double code(double x, double y, double z) {
return sqrt((((x * x) + (y * y)) + (z * z)));
}

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

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

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

def code(x, y, z):
return math.sqrt((((x * x) + (y * y)) + (z * z)))

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

function code(x, y, z)
return sqrt(Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(z * z)))
end

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

function tmp = code(x, y, z)
tmp = sqrt((((x * x) + (y * y)) + (z * z)));
end

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

code[x_, y_, z_] := N[Sqrt[N[(N[(N[(x * x), $MachinePrecision] + N[(y * y),$MachinePrecision]), $MachinePrecision] + N[(z * z),$MachinePrecision]), $MachinePrecision]],$MachinePrecision]

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

\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}

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


# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 38.2

$\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}$
2. Applied egg-rr0.0

$\leadsto \color{blue}{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}$
3. Taylor expanded in x around 0 0.0

$\leadsto \mathsf{hypot}\left(\color{blue}{y}, z\right)$
4. Final simplification0.0

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

# Alternatives

Alternative 1
Error1.0
Cost64
$z$

# Reproduce?

herbie shell --seed 1
(FPCore (x y z)
:name "sqrt(x*x + y*y + z*z)"
:precision binary64
:pre (and (and (and (<= 0.0 x) (<= x 1.79e+308)) (and (<= 0.0 y) (<= y 1.79e+308))) (and (<= 0.0 z) (<= z 1.79e+308)))
(sqrt (+ (+ (* x x) (* y y)) (* z z))))