Average Error: 38.1 → 0.5
Time: 5.9s
Precision: binary64
Cost: 25856
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \]
\[{\left(\sqrt{\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right)}\right)}^{2} \]
(FPCore (x y z) :precision binary64 (sqrt (+ (+ (* x x) (* y y)) (* z z))))
(FPCore (x y z) :precision binary64 (pow (sqrt (hypot x (hypot y z))) 2.0))
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 pow(sqrt(hypot(x, hypot(y, z))), 2.0);
}
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.pow(Math.sqrt(Math.hypot(x, Math.hypot(y, z))), 2.0);
}
def code(x, y, z):
	return math.sqrt((((x * x) + (y * y)) + (z * z)))
def code(x, y, z):
	return math.pow(math.sqrt(math.hypot(x, math.hypot(y, z))), 2.0)
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 sqrt(hypot(x, hypot(y, z))) ^ 2.0
end
function tmp = code(x, y, z)
	tmp = sqrt((((x * x) + (y * y)) + (z * z)));
end
function tmp = code(x, y, z)
	tmp = sqrt(hypot(x, hypot(y, z))) ^ 2.0;
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[Power[N[Sqrt[N[Sqrt[x ^ 2 + N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
{\left(\sqrt{\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right)}\right)}^{2}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original38.1
Target25.1
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;z < -6.396479394109776 \cdot 10^{+136}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z < 7.320293694404182 \cdot 10^{+117}:\\ \;\;\;\;\sqrt{\left(z \cdot z + x \cdot x\right) + y \cdot y}\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]

Derivation

  1. Initial program 38.1

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

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

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

Alternatives

Alternative 1
Error20.3
Cost6528
\[\mathsf{hypot}\left(z, x\right) \]
Alternative 2
Error44.9
Cost972
\[\begin{array}{l} t_0 := -0.5 \cdot \left(y \cdot \frac{y}{x}\right) - x\\ \mathbf{if}\;x \leq -3.293119197955147 \cdot 10^{+71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.415660045216952 \cdot 10^{+44}:\\ \;\;\;\;z + \left(x \cdot 0.5\right) \cdot \frac{x}{z}\\ \mathbf{elif}\;x \leq -281481616496445280:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 3
Error44.8
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -3.293119197955147 \cdot 10^{+71}:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq -3.415660045216952 \cdot 10^{+44}:\\ \;\;\;\;z + \left(x \cdot 0.5\right) \cdot \frac{x}{z}\\ \mathbf{elif}\;x \leq -281481616496445280:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 4
Error44.8
Cost524
\[\begin{array}{l} \mathbf{if}\;x \leq -3.293119197955147 \cdot 10^{+71}:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq -3.415660045216952 \cdot 10^{+44}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq -281481616496445280:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 5
Error51.8
Cost64
\[z \]

Error

Reproduce

herbie shell --seed 2022317 
(FPCore (x y z)
  :name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
  :precision binary64

  :herbie-target
  (if (< z -6.396479394109776e+136) (- z) (if (< z 7.320293694404182e+117) (sqrt (+ (+ (* z z) (* x x)) (* y y))) z))

  (sqrt (+ (+ (* x x) (* y y)) (* z z))))