Average Error: 37.9 → 0.4
Time: 9.6s
Precision: binary64
Cost: 19648
\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}} \]
\[\frac{1}{\frac{\sqrt{3}}{\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right)}} \]
(FPCore (x y z)
 :precision binary64
 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
(FPCore (x y z)
 :precision binary64
 (/ 1.0 (/ (sqrt 3.0) (hypot x (hypot y z)))))
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 1.0 / (sqrt(3.0) / hypot(x, hypot(y, z)));
}
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 1.0 / (Math.sqrt(3.0) / Math.hypot(x, Math.hypot(y, z)));
}
def code(x, y, z):
	return math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0))
def code(x, y, z):
	return 1.0 / (math.sqrt(3.0) / math.hypot(x, math.hypot(y, z)))
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(1.0 / Float64(sqrt(3.0) / hypot(x, hypot(y, z))))
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 = 1.0 / (sqrt(3.0) / hypot(x, hypot(y, z)));
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[(1.0 / N[(N[Sqrt[3.0], $MachinePrecision] / N[Sqrt[x ^ 2 + N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\frac{1}{\frac{\sqrt{3}}{\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right)}}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original37.9
Target25.8
Herbie0.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 37.9

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

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

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

Alternatives

Alternative 1
Error0.4
Cost19520
\[\frac{\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\right)\right)}{\sqrt{3}} \]
Alternative 2
Error42.4
Cost13320
\[\begin{array}{l} \mathbf{if}\;z \leq 3.8210762002133727 \cdot 10^{-28}:\\ \;\;\;\;\frac{-0.5 \cdot \left(y \cdot \frac{y}{x}\right) - x}{\sqrt{3}}\\ \mathbf{elif}\;z \leq 6.250342313438228 \cdot 10^{+145}:\\ \;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(z, y\right)}{\sqrt{3}}\\ \end{array} \]
Alternative 3
Error16.5
Cost13320
\[\begin{array}{l} \mathbf{if}\;z \leq 3.8210762002133727 \cdot 10^{-28}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(y, x\right)}{\sqrt{3}}\\ \mathbf{elif}\;z \leq 6.250342313438228 \cdot 10^{+145}:\\ \;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(z, y\right)}{\sqrt{3}}\\ \end{array} \]
Alternative 4
Error20.8
Cost13056
\[\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(z, x\right) \]
Alternative 5
Error45.3
Cost7764
\[\begin{array}{l} t_0 := \frac{z}{\sqrt{3}}\\ \mathbf{if}\;z \leq 1027893.9002576969:\\ \;\;\;\;\frac{1}{\frac{\sqrt{3}}{-x}}\\ \mathbf{elif}\;z \leq 1.8573995064406585 \cdot 10^{+32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.2867170564516421 \cdot 10^{+56}:\\ \;\;\;\;\frac{-x}{\sqrt{3}}\\ \mathbf{elif}\;z \leq 1.8184327216002477 \cdot 10^{+118}:\\ \;\;\;\;\sqrt{\frac{z \cdot z}{3}}\\ \mathbf{elif}\;z \leq 3.8347126517875565 \cdot 10^{+129}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot \left(z \cdot \frac{z}{\frac{x}{-0.5}} - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error45.6
Cost7764
\[\begin{array}{l} t_0 := \frac{z}{\sqrt{3}}\\ \mathbf{if}\;z \leq 1027893.9002576969:\\ \;\;\;\;\frac{-0.5 \cdot \left(y \cdot \frac{y}{x}\right) - x}{\sqrt{3}}\\ \mathbf{elif}\;z \leq 1.8573995064406585 \cdot 10^{+32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.2867170564516421 \cdot 10^{+56}:\\ \;\;\;\;\frac{-x}{\sqrt{3}}\\ \mathbf{elif}\;z \leq 1.8184327216002477 \cdot 10^{+118}:\\ \;\;\;\;\sqrt{\frac{z \cdot z}{3}}\\ \mathbf{elif}\;z \leq 3.8347126517875565 \cdot 10^{+129}:\\ \;\;\;\;\sqrt{0.3333333333333333} \cdot \left(z \cdot \frac{z}{\frac{x}{-0.5}} - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error43.2
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq 3.8210762002133727 \cdot 10^{-28}:\\ \;\;\;\;\frac{-0.5 \cdot \left(y \cdot \frac{y}{x}\right) - x}{\sqrt{3}}\\ \mathbf{elif}\;z \leq 6.250342313438228 \cdot 10^{+145}:\\ \;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\sqrt{3}}\\ \end{array} \]
Alternative 8
Error45.3
Cost7316
\[\begin{array}{l} t_0 := \frac{-x}{\sqrt{3}}\\ t_1 := \frac{z}{\sqrt{3}}\\ \mathbf{if}\;z \leq 1027893.9002576969:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.8573995064406585 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.2867170564516421 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.8184327216002477 \cdot 10^{+118}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.8347126517875565 \cdot 10^{+129}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error45.3
Cost7316
\[\begin{array}{l} t_0 := \frac{-x}{\sqrt{3}}\\ t_1 := \frac{z}{\sqrt{3}}\\ \mathbf{if}\;z \leq 1027893.9002576969:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.8573995064406585 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.2867170564516421 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.8184327216002477 \cdot 10^{+118}:\\ \;\;\;\;\sqrt{\frac{z \cdot z}{3}}\\ \mathbf{elif}\;z \leq 3.8347126517875565 \cdot 10^{+129}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error45.3
Cost7316
\[\begin{array}{l} t_0 := \frac{z}{\sqrt{3}}\\ t_1 := \frac{-x}{\sqrt{3}}\\ \mathbf{if}\;z \leq 1027893.9002576969:\\ \;\;\;\;\frac{1}{\frac{\sqrt{3}}{-x}}\\ \mathbf{elif}\;z \leq 1.8573995064406585 \cdot 10^{+32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.2867170564516421 \cdot 10^{+56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.8184327216002477 \cdot 10^{+118}:\\ \;\;\;\;\sqrt{\frac{z \cdot z}{3}}\\ \mathbf{elif}\;z \leq 3.8347126517875565 \cdot 10^{+129}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error52.5
Cost6592
\[\frac{z}{\sqrt{3}} \]

Error

Reproduce

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