?

Average Accuracy: 41.7% → 100.0%
Time: 3.8s
Precision: binary64
Cost: 12992

?

\[\sqrt{x \cdot x + \left(y \cdot y + z \cdot z\right)} \]
\[\mathsf{hypot}\left(\mathsf{hypot}\left(z, y\right), x\right) \]
(FPCore (x y z) :precision binary64 (sqrt (+ (* x x) (+ (* y y) (* z z)))))
(FPCore (x y z) :precision binary64 (hypot (hypot z y) x))
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(hypot(z, y), x);
}
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(Math.hypot(z, y), x);
}
def code(x, y, z):
	return math.sqrt(((x * x) + ((y * y) + (z * z))))
def code(x, y, z):
	return math.hypot(math.hypot(z, y), x)
function code(x, y, z)
	return sqrt(Float64(Float64(x * x) + Float64(Float64(y * y) + Float64(z * z))))
end
function code(x, y, z)
	return hypot(hypot(z, y), x)
end
function tmp = code(x, y, z)
	tmp = sqrt(((x * x) + ((y * y) + (z * z))));
end
function tmp = code(x, y, z)
	tmp = hypot(hypot(z, y), x);
end
code[x_, y_, z_] := N[Sqrt[N[(N[(x * x), $MachinePrecision] + N[(N[(y * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := N[Sqrt[N[Sqrt[z ^ 2 + y ^ 2], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]
\sqrt{x \cdot x + \left(y \cdot y + z \cdot z\right)}
\mathsf{hypot}\left(\mathsf{hypot}\left(z, y\right), x\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original41.7%
Target100.0%
Herbie100.0%
\[\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right) \]

Derivation?

  1. Initial program 41.7%

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

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

    [Start]41.7

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

    +-commutative [=>]41.7

    \[ \sqrt{\color{blue}{\left(y \cdot y + z \cdot z\right) + x \cdot x}} \]

    add-sqr-sqrt [=>]41.7

    \[ \sqrt{\color{blue}{\sqrt{y \cdot y + z \cdot z} \cdot \sqrt{y \cdot y + z \cdot z}} + x \cdot x} \]

    hypot-def [=>]56.1

    \[ \color{blue}{\mathsf{hypot}\left(\sqrt{y \cdot y + z \cdot z}, x\right)} \]

    hypot-def [=>]100.0

    \[ \mathsf{hypot}\left(\color{blue}{\mathsf{hypot}\left(y, z\right)}, x\right) \]
  3. Simplified100.0%

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

    [Start]100.0

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

    hypot-def [<=]56.1

    \[ \mathsf{hypot}\left(\color{blue}{\sqrt{y \cdot y + z \cdot z}}, x\right) \]

    +-commutative [<=]56.1

    \[ \mathsf{hypot}\left(\sqrt{\color{blue}{z \cdot z + y \cdot y}}, x\right) \]

    hypot-def [=>]100.0

    \[ \mathsf{hypot}\left(\color{blue}{\mathsf{hypot}\left(z, y\right)}, x\right) \]
  4. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy74.5%
Cost6660
\[\begin{array}{l} \mathbf{if}\;z \leq 1.02 \cdot 10^{+70}:\\ \;\;\;\;\mathsf{hypot}\left(y, x\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 2
Accuracy68.6%
Cost6528
\[\mathsf{hypot}\left(z, x\right) \]
Alternative 3
Accuracy30.4%
Cost260
\[\begin{array}{l} \mathbf{if}\;z \leq 3.2 \cdot 10^{+51}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 4
Accuracy19.1%
Cost64
\[z \]

Error

Reproduce?

herbie shell --seed 2023151 
(FPCore (x y z)
  :name "bug366 (missed optimization)"
  :precision binary64

  :herbie-target
  (hypot x (hypot y z))

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