?

Average Accuracy: 41.5% → 99.4%
Time: 9.9s
Precision: binary64
Cost: 19520

?

\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}} \]
\[\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right) \cdot \sqrt{0.3333333333333333} \]
(FPCore (x y z)
 :precision binary64
 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
(FPCore (x y z)
 :precision binary64
 (* (hypot x (hypot y z)) (sqrt 0.3333333333333333)))
double code(double x, double y, double z) {
	return sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
double code(double x, double y, double z) {
	return hypot(x, hypot(y, z)) * sqrt(0.3333333333333333);
}
public static double code(double x, double y, double z) {
	return Math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
public static double code(double x, double y, double z) {
	return Math.hypot(x, Math.hypot(y, z)) * Math.sqrt(0.3333333333333333);
}
def code(x, y, z):
	return math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0))
def code(x, y, z):
	return math.hypot(x, math.hypot(y, z)) * math.sqrt(0.3333333333333333)
function code(x, y, z)
	return sqrt(Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(z * z)) / 3.0))
end
function code(x, y, z)
	return Float64(hypot(x, hypot(y, z)) * sqrt(0.3333333333333333))
end
function tmp = code(x, y, z)
	tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
end
function tmp = code(x, y, z)
	tmp = hypot(x, hypot(y, z)) * sqrt(0.3333333333333333);
end
code[x_, y_, z_] := N[Sqrt[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := N[(N[Sqrt[x ^ 2 + N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision] * N[Sqrt[0.3333333333333333], $MachinePrecision]), $MachinePrecision]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right) \cdot \sqrt{0.3333333333333333}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original41.5%
Target60.7%
Herbie99.4%
\[\begin{array}{l} \mathbf{if}\;z < -6.396479394109776 \cdot 10^{+136}:\\ \;\;\;\;\frac{-z}{\sqrt{3}}\\ \mathbf{elif}\;z < 7.320293694404182 \cdot 10^{+117}:\\ \;\;\;\;\frac{\sqrt{\left(z \cdot z + x \cdot x\right) + y \cdot y}}{\sqrt{3}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot z\\ \end{array} \]

Derivation?

  1. Initial program 41.5%

    \[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}} \]
  2. Applied egg-rr99.4%

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

    [Start]41.5

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

    div-inv [=>]41.5

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

    sqrt-prod [=>]41.4

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

    associate-+l+ [=>]41.4

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

    add-sqr-sqrt [=>]41.4

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

    hypot-def [=>]55.8

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

    hypot-def [=>]99.4

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

    metadata-eval [=>]99.4

    \[ \mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right) \cdot \sqrt{\color{blue}{0.3333333333333333}} \]
  3. Final simplification99.4%

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

Alternatives

Alternative 1
Accuracy71.8%
Cost13188
\[\begin{array}{l} \mathbf{if}\;z \leq 2.8 \cdot 10^{-121}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(y, x\right)\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+133}:\\ \;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \end{array} \]
Alternative 2
Accuracy68.2%
Cost13056
\[\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(z, x\right) \]
Alternative 3
Accuracy35.7%
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq 4.2 \cdot 10^{-121}:\\ \;\;\;\;x \cdot \left(-\sqrt{0.3333333333333333}\right)\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{+134}:\\ \;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \end{array} \]
Alternative 4
Accuracy32.9%
Cost7368
\[\begin{array}{l} \mathbf{if}\;z \leq 3.7 \cdot 10^{-121}:\\ \;\;\;\;x \cdot \left(-\sqrt{0.3333333333333333}\right)\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+134}:\\ \;\;\;\;\sqrt{x \cdot \left(x \cdot 0.3333333333333333\right) + 0.3333333333333333 \cdot \left(z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \end{array} \]
Alternative 5
Accuracy32.9%
Cost7240
\[\begin{array}{l} \mathbf{if}\;z \leq 2.8 \cdot 10^{-121}:\\ \;\;\;\;x \cdot \left(-\sqrt{0.3333333333333333}\right)\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+133}:\\ \;\;\;\;\sqrt{0.3333333333333333 \cdot \left(x \cdot x + z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \end{array} \]
Alternative 6
Accuracy29.8%
Cost6788
\[\begin{array}{l} \mathbf{if}\;z \leq 3.6 \cdot 10^{+69}:\\ \;\;\;\;x \cdot \left(-\sqrt{0.3333333333333333}\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \end{array} \]
Alternative 7
Accuracy19.0%
Cost6592
\[z \cdot \sqrt{0.3333333333333333} \]

Error

Reproduce?

herbie shell --seed 2023151 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.Pixel:doubleRmsOfRGB8 from repa-algorithms-3.4.0.1"
  :precision binary64

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

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