Average Error: 0.2 → 0.1
Time: 7.8s
Precision: binary64
Cost: 12992
\[\left(\left(1 \leq x \land x \leq 1000\right) \land \left(1 \leq y \land y \leq 1000\right)\right) \land \left(1 \leq z \land z \leq 1000\right)\]
\[ \begin{array}{c}[x, y, z] = \mathsf{sort}([x, y, z])\\ \end{array} \]
\[\sqrt{\left({x}^{2} + {y}^{2}\right) + {z}^{2}} \]
\[\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right) \]
(FPCore (x y z)
 :precision binary64
 (sqrt (+ (+ (pow x 2.0) (pow y 2.0)) (pow z 2.0))))
(FPCore (x y z) :precision binary64 (hypot (hypot x y) z))
double code(double x, double y, double z) {
	return sqrt(((pow(x, 2.0) + pow(y, 2.0)) + pow(z, 2.0)));
}
double code(double x, double y, double z) {
	return hypot(hypot(x, y), z);
}
public static double code(double x, double y, double z) {
	return Math.sqrt(((Math.pow(x, 2.0) + Math.pow(y, 2.0)) + Math.pow(z, 2.0)));
}
public static double code(double x, double y, double z) {
	return Math.hypot(Math.hypot(x, y), z);
}
def code(x, y, z):
	return math.sqrt(((math.pow(x, 2.0) + math.pow(y, 2.0)) + math.pow(z, 2.0)))
def code(x, y, z):
	return math.hypot(math.hypot(x, y), z)
function code(x, y, z)
	return sqrt(Float64(Float64((x ^ 2.0) + (y ^ 2.0)) + (z ^ 2.0)))
end
function code(x, y, z)
	return hypot(hypot(x, y), z)
end
function tmp = code(x, y, z)
	tmp = sqrt((((x ^ 2.0) + (y ^ 2.0)) + (z ^ 2.0)));
end
function tmp = code(x, y, z)
	tmp = hypot(hypot(x, y), z);
end
code[x_, y_, z_] := N[Sqrt[N[(N[(N[Power[x, 2.0], $MachinePrecision] + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := N[Sqrt[N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] ^ 2 + z ^ 2], $MachinePrecision]
\sqrt{\left({x}^{2} + {y}^{2}\right) + {z}^{2}}
\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.2

    \[\sqrt{\left({x}^{2} + {y}^{2}\right) + {z}^{2}} \]
  2. Applied egg-rr0.1

    \[\leadsto \color{blue}{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)} \]
  3. Final simplification0.1

    \[\leadsto \mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right) \]

Alternatives

Alternative 1
Error38.5
Cost13636
\[\begin{array}{l} \mathbf{if}\;{y}^{2} \leq 7500:\\ \;\;\;\;\mathsf{hypot}\left(x, \left(y \cdot y\right) \cdot \frac{-0.5}{z} - z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{hypot}\left(z, y\right)\\ \end{array} \]
Alternative 2
Error0.2
Cost7104
\[\sqrt{y \cdot y + \left(x \cdot x + z \cdot z\right)} \]
Alternative 3
Error0.2
Cost7104
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \]
Alternative 4
Error34.5
Cost7040
\[\mathsf{hypot}\left(\left(x \cdot x\right) \cdot \frac{-0.5}{y} - y, z\right) \]
Alternative 5
Error41.5
Cost6528
\[\mathsf{hypot}\left(z, y\right) \]
Alternative 6
Error46.7
Cost64
\[z \]

Error

Reproduce

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