?

Average Accuracy: 40.1% → 99.4%
Time: 9.3s
Precision: binary64
Cost: 38976

?

\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}} \]
\[\begin{array}{l} t_0 := \mathsf{hypot}\left(x, \mathsf{hypot}\left(z, y\right)\right)\\ \sqrt{t_0} \cdot \sqrt{t_0 \cdot 0.3333333333333333} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (hypot x (hypot z y))))
   (* (sqrt t_0) (sqrt (* t_0 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) {
	double t_0 = hypot(x, hypot(z, y));
	return sqrt(t_0) * sqrt((t_0 * 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) {
	double t_0 = Math.hypot(x, Math.hypot(z, y));
	return Math.sqrt(t_0) * Math.sqrt((t_0 * 0.3333333333333333));
}
def code(x, y, z):
	return math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0))
def code(x, y, z):
	t_0 = math.hypot(x, math.hypot(z, y))
	return math.sqrt(t_0) * math.sqrt((t_0 * 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)
	t_0 = hypot(x, hypot(z, y))
	return Float64(sqrt(t_0) * sqrt(Float64(t_0 * 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)
	t_0 = hypot(x, hypot(z, y));
	tmp = sqrt(t_0) * sqrt((t_0 * 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_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[Sqrt[z ^ 2 + y ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] * N[Sqrt[N[(t$95$0 * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, \mathsf{hypot}\left(z, y\right)\right)\\
\sqrt{t_0} \cdot \sqrt{t_0 \cdot 0.3333333333333333}
\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.1%
Target59.4%
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.1%

    \[\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(x, \mathsf{hypot}\left(y, z\right)\right) \cdot \frac{1}{\sqrt{3}}} \]
    Proof

    [Start]40.1

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

    sqrt-div [=>]40.0

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

    div-inv [=>]39.7

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

    associate-+l+ [=>]39.7

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

    add-sqr-sqrt [=>]39.7

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

    hypot-def [=>]54.1

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

    hypot-def [=>]98.7

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

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

    [Start]98.7

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

    associate-*r/ [=>]99.4

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

    *-rgt-identity [=>]99.4

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

    hypot-def [<=]54.5

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

    unpow2 [<=]54.5

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

    unpow2 [<=]54.5

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

    +-commutative [<=]54.5

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

    unpow2 [=>]54.5

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

    unpow2 [=>]54.5

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

    hypot-def [=>]99.4

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

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

    [Start]99.4

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

    div-inv [=>]98.7

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

    add-sqr-sqrt [=>]98.7

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

    associate-*l* [=>]98.7

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

    pow1/2 [=>]98.7

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

    pow-flip [=>]99.1

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

    metadata-eval [=>]99.1

    \[ \sqrt{\mathsf{hypot}\left(x, \mathsf{hypot}\left(z, y\right)\right)} \cdot \left(\sqrt{\mathsf{hypot}\left(x, \mathsf{hypot}\left(z, y\right)\right)} \cdot {3}^{\color{blue}{-0.5}}\right) \]
  5. Applied egg-rr99.4%

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

    [Start]99.1

    \[ \sqrt{\mathsf{hypot}\left(x, \mathsf{hypot}\left(z, y\right)\right)} \cdot \left(\sqrt{\mathsf{hypot}\left(x, \mathsf{hypot}\left(z, y\right)\right)} \cdot {3}^{-0.5}\right) \]

    add-sqr-sqrt [=>]98.8

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

    sqrt-unprod [=>]99.1

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

    swap-sqr [=>]99.1

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

    add-sqr-sqrt [<=]99.4

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

    pow-prod-up [=>]99.4

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

    metadata-eval [=>]99.4

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

    metadata-eval [=>]99.4

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

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

Alternatives

Alternative 1
Accuracy99.4%
Cost19520
\[\frac{\mathsf{hypot}\left(x, \mathsf{hypot}\left(z, y\right)\right)}{\sqrt{3}} \]
Alternative 2
Accuracy44.8%
Cost14356
\[\begin{array}{l} t_0 := z \cdot \sqrt{0.3333333333333333}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 50000000000:\\ \;\;\;\;\sqrt{x \cdot \left(x \cdot 0.3333333333333333\right)}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+184}:\\ \;\;\;\;\sqrt{0.3333333333333333 \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+219}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(y, x\right)\\ \end{array} \]
Alternative 3
Accuracy67.0%
Cost13056
\[\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(z, x\right) \]
Alternative 4
Accuracy28.3%
Cost7956
\[\begin{array}{l} t_0 := z \cdot \sqrt{0.3333333333333333}\\ t_1 := \sqrt{0.3333333333333333 \cdot \left(x \cdot x\right)}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 50000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+184}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+219}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot \left(-x\right)\\ \end{array} \]
Alternative 5
Accuracy28.3%
Cost7956
\[\begin{array}{l} t_0 := z \cdot \sqrt{0.3333333333333333}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 50000000000:\\ \;\;\;\;\sqrt{x \cdot \left(x \cdot 0.3333333333333333\right)}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+184}:\\ \;\;\;\;\sqrt{0.3333333333333333 \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+219}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot \left(-x\right)\\ \end{array} \]
Alternative 6
Accuracy29.4%
Cost7053
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{+57} \lor \neg \left(x \leq -12500000\right) \land x \leq -4 \cdot 10^{-30}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \end{array} \]
Alternative 7
Accuracy29.5%
Cost7053
\[\begin{array}{l} \mathbf{if}\;x \leq -1.06 \cdot 10^{+58}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot \left(-x\right)\\ \mathbf{elif}\;x \leq -210000 \lor \neg \left(x \leq -5.2 \cdot 10^{-30}\right):\\ \;\;\;\;z \cdot \sqrt{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\sqrt{3}}\\ \end{array} \]
Alternative 8
Accuracy18.3%
Cost6592
\[z \cdot \sqrt{0.3333333333333333} \]

Error

Reproduce?

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