?

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

?

\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \]
\[\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(Float64(x * x) + 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[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := N[Sqrt[N[Sqrt[z ^ 2 + y ^ 2], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
\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%
Target61.1%
Herbie100.0%
\[\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 41.7%

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

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

    [Start]41.7

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

    associate-+l+ [=>]41.7

    \[ \sqrt{\color{blue}{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 "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))))