?

Average Accuracy: 40.9% → 99.4%
Time: 6.4s
Precision: binary64
Cost: 19520

?

\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}} \]
\[\frac{\mathsf{hypot}\left(z, \mathsf{hypot}\left(y, x\right)\right)}{\sqrt{3}} \]
(FPCore (x y z)
 :precision binary64
 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
(FPCore (x y z) :precision binary64 (/ (hypot z (hypot y x)) (sqrt 3.0)))
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(z, hypot(y, x)) / sqrt(3.0);
}
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(z, Math.hypot(y, x)) / Math.sqrt(3.0);
}
def code(x, y, z):
	return math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0))
def code(x, y, z):
	return math.hypot(z, math.hypot(y, x)) / math.sqrt(3.0)
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(z, hypot(y, x)) / sqrt(3.0))
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(z, hypot(y, x)) / sqrt(3.0);
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[z ^ 2 + N[Sqrt[y ^ 2 + x ^ 2], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[3.0], $MachinePrecision]), $MachinePrecision]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\frac{\mathsf{hypot}\left(z, \mathsf{hypot}\left(y, x\right)\right)}{\sqrt{3}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.9%
Target60.8%
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 40.9%

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

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

    [Start]40.9

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

    sqrt-div [=>]40.8

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

    div-inv [=>]40.5

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

    +-commutative [=>]40.5

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

    add-sqr-sqrt [=>]40.5

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

    hypot-def [=>]55.2

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

    hypot-def [=>]98.7

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

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

    [Start]98.7

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

    associate-*r/ [=>]99.4

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

    *-rgt-identity [=>]99.4

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

    hypot-def [<=]55.6

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

    unpow2 [<=]55.6

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

    unpow2 [<=]55.6

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

    +-commutative [<=]55.6

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

    unpow2 [=>]55.6

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

    unpow2 [=>]55.6

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

    hypot-def [=>]99.4

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

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

Alternatives

Alternative 1
Accuracy37.0%
Cost13188
\[\begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+121}:\\ \;\;\;\;\mathsf{hypot}\left(y, x\right) \cdot \sqrt{0.3333333333333333}\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-94}:\\ \;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\sqrt{3}}\\ \end{array} \]
Alternative 2
Accuracy67.6%
Cost13056
\[\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(z, x\right) \]
Alternative 3
Accuracy67.6%
Cost13056
\[\frac{\mathsf{hypot}\left(x, z\right)}{\sqrt{3}} \]
Alternative 4
Accuracy35.0%
Cost7496
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+127}:\\ \;\;\;\;\frac{-x}{\sqrt{3}}\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-92}:\\ \;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\sqrt{3}}\\ \end{array} \]
Alternative 5
Accuracy27.8%
Cost6916
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{+150}:\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\sqrt{3}}\\ \end{array} \]
Alternative 6
Accuracy29.6%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{+76}:\\ \;\;\;\;x \cdot \left(-\sqrt{0.3333333333333333}\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \end{array} \]
Alternative 7
Accuracy18.8%
Cost6592
\[z \cdot \sqrt{0.3333333333333333} \]

Error

Reproduce?

herbie shell --seed 2023138 
(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)))