
(FPCore (x y z) :precision binary64 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
double code(double x, double y, double z) {
return sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0d0))
end function
public static double code(double x, double y, double z) {
return Math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
def code(x, y, z): return math.sqrt(((((x * x) + (y * y)) + (z * z)) / 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 tmp = code(x, y, z) tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 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]
\begin{array}{l}
\\
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0)))
double code(double x, double y, double z) {
return sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0d0))
end function
public static double code(double x, double y, double z) {
return Math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
}
def code(x, y, z): return math.sqrt(((((x * x) + (y * y)) + (z * z)) / 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 tmp = code(x, y, z) tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 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]
\begin{array}{l}
\\
\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\end{array}
(FPCore (x y z) :precision binary64 (/ (hypot x (hypot z y)) (sqrt 3.0)))
double code(double x, double y, double z) {
return hypot(x, hypot(z, y)) / sqrt(3.0);
}
public static double code(double x, double y, double z) {
return Math.hypot(x, Math.hypot(z, y)) / Math.sqrt(3.0);
}
def code(x, y, z): return math.hypot(x, math.hypot(z, y)) / math.sqrt(3.0)
function code(x, y, z) return Float64(hypot(x, hypot(z, y)) / sqrt(3.0)) end
function tmp = code(x, y, z) tmp = hypot(x, hypot(z, y)) / sqrt(3.0); end
code[x_, y_, z_] := N[(N[Sqrt[x ^ 2 + N[Sqrt[z ^ 2 + y ^ 2], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{hypot}\left(x, \mathsf{hypot}\left(z, y\right)\right)}{\sqrt{3}}
\end{array}
Initial program 43.5%
add-log-exp7.1%
*-un-lft-identity7.1%
log-prod7.1%
metadata-eval7.1%
add-log-exp43.5%
sqrt-div43.4%
associate-+l+43.4%
fma-udef43.4%
add-sqr-sqrt43.4%
hypot-def56.4%
fma-udef56.4%
hypot-def99.4%
Applied egg-rr99.4%
+-lft-identity99.4%
hypot-def56.4%
+-commutative56.4%
hypot-def99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x y z)
:precision binary64
(if (<= z 3.3e-133)
(* (sqrt 0.3333333333333333) (hypot y x))
(if (<= z 4.2e+94)
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0))
(if (<= z 1.16e+103)
(* x (- (sqrt 0.3333333333333333)))
(/ z (sqrt 3.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= 3.3e-133) {
tmp = sqrt(0.3333333333333333) * hypot(y, x);
} else if (z <= 4.2e+94) {
tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
} else if (z <= 1.16e+103) {
tmp = x * -sqrt(0.3333333333333333);
} else {
tmp = z / sqrt(3.0);
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (z <= 3.3e-133) {
tmp = Math.sqrt(0.3333333333333333) * Math.hypot(y, x);
} else if (z <= 4.2e+94) {
tmp = Math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
} else if (z <= 1.16e+103) {
tmp = x * -Math.sqrt(0.3333333333333333);
} else {
tmp = z / Math.sqrt(3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 3.3e-133: tmp = math.sqrt(0.3333333333333333) * math.hypot(y, x) elif z <= 4.2e+94: tmp = math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0)) elif z <= 1.16e+103: tmp = x * -math.sqrt(0.3333333333333333) else: tmp = z / math.sqrt(3.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 3.3e-133) tmp = Float64(sqrt(0.3333333333333333) * hypot(y, x)); elseif (z <= 4.2e+94) tmp = sqrt(Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(z * z)) / 3.0)); elseif (z <= 1.16e+103) tmp = Float64(x * Float64(-sqrt(0.3333333333333333))); else tmp = Float64(z / sqrt(3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 3.3e-133) tmp = sqrt(0.3333333333333333) * hypot(y, x); elseif (z <= 4.2e+94) tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0)); elseif (z <= 1.16e+103) tmp = x * -sqrt(0.3333333333333333); else tmp = z / sqrt(3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 3.3e-133], N[(N[Sqrt[0.3333333333333333], $MachinePrecision] * N[Sqrt[y ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.2e+94], N[Sqrt[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.16e+103], N[(x * (-N[Sqrt[0.3333333333333333], $MachinePrecision])), $MachinePrecision], N[(z / N[Sqrt[3.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.3 \cdot 10^{-133}:\\
\;\;\;\;\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(y, x\right)\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+94}:\\
\;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{+103}:\\
\;\;\;\;x \cdot \left(-\sqrt{0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\end{array}
\end{array}
if z < 3.30000000000000009e-133Initial program 42.0%
Taylor expanded in z around 0 33.0%
*-commutative33.0%
unpow233.0%
unpow233.0%
hypot-def75.0%
Simplified75.0%
if 3.30000000000000009e-133 < z < 4.19999999999999979e94Initial program 62.2%
if 4.19999999999999979e94 < z < 1.1600000000000001e103Initial program 37.6%
Taylor expanded in x around -inf 35.0%
mul-1-neg35.0%
distribute-rgt-neg-in35.0%
Simplified35.0%
if 1.1600000000000001e103 < z Initial program 25.5%
add-log-exp6.9%
*-un-lft-identity6.9%
log-prod6.9%
metadata-eval6.9%
add-log-exp25.5%
sqrt-div25.5%
associate-+l+25.5%
fma-udef25.5%
add-sqr-sqrt25.5%
hypot-def27.9%
fma-udef27.9%
hypot-def99.4%
Applied egg-rr99.4%
+-lft-identity99.4%
hypot-def27.9%
+-commutative27.9%
hypot-def99.4%
Simplified99.4%
Taylor expanded in z around inf 71.6%
Final simplification71.6%
(FPCore (x y z) :precision binary64 (* (sqrt 0.3333333333333333) (hypot z x)))
double code(double x, double y, double z) {
return sqrt(0.3333333333333333) * hypot(z, x);
}
public static double code(double x, double y, double z) {
return Math.sqrt(0.3333333333333333) * Math.hypot(z, x);
}
def code(x, y, z): return math.sqrt(0.3333333333333333) * math.hypot(z, x)
function code(x, y, z) return Float64(sqrt(0.3333333333333333) * hypot(z, x)) end
function tmp = code(x, y, z) tmp = sqrt(0.3333333333333333) * hypot(z, x); end
code[x_, y_, z_] := N[(N[Sqrt[0.3333333333333333], $MachinePrecision] * N[Sqrt[z ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(z, x\right)
\end{array}
Initial program 43.5%
Taylor expanded in y around 0 31.2%
*-commutative31.2%
unpow231.2%
unpow231.2%
hypot-def65.2%
Simplified65.2%
Final simplification65.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- (sqrt 0.3333333333333333)))))
(if (<= z 1.05e-133)
t_0
(if (<= z 5.5e+94)
(sqrt (/ (+ (+ (* x x) (* y y)) (* z z)) 3.0))
(if (<= z 8.2e+102) t_0 (/ z (sqrt 3.0)))))))
double code(double x, double y, double z) {
double t_0 = x * -sqrt(0.3333333333333333);
double tmp;
if (z <= 1.05e-133) {
tmp = t_0;
} else if (z <= 5.5e+94) {
tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
} else if (z <= 8.2e+102) {
tmp = t_0;
} else {
tmp = z / sqrt(3.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * -sqrt(0.3333333333333333d0)
if (z <= 1.05d-133) then
tmp = t_0
else if (z <= 5.5d+94) then
tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0d0))
else if (z <= 8.2d+102) then
tmp = t_0
else
tmp = z / sqrt(3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -Math.sqrt(0.3333333333333333);
double tmp;
if (z <= 1.05e-133) {
tmp = t_0;
} else if (z <= 5.5e+94) {
tmp = Math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0));
} else if (z <= 8.2e+102) {
tmp = t_0;
} else {
tmp = z / Math.sqrt(3.0);
}
return tmp;
}
def code(x, y, z): t_0 = x * -math.sqrt(0.3333333333333333) tmp = 0 if z <= 1.05e-133: tmp = t_0 elif z <= 5.5e+94: tmp = math.sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0)) elif z <= 8.2e+102: tmp = t_0 else: tmp = z / math.sqrt(3.0) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-sqrt(0.3333333333333333))) tmp = 0.0 if (z <= 1.05e-133) tmp = t_0; elseif (z <= 5.5e+94) tmp = sqrt(Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(z * z)) / 3.0)); elseif (z <= 8.2e+102) tmp = t_0; else tmp = Float64(z / sqrt(3.0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -sqrt(0.3333333333333333); tmp = 0.0; if (z <= 1.05e-133) tmp = t_0; elseif (z <= 5.5e+94) tmp = sqrt(((((x * x) + (y * y)) + (z * z)) / 3.0)); elseif (z <= 8.2e+102) tmp = t_0; else tmp = z / sqrt(3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-N[Sqrt[0.3333333333333333], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[z, 1.05e-133], t$95$0, If[LessEqual[z, 5.5e+94], N[Sqrt[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 8.2e+102], t$95$0, N[(z / N[Sqrt[3.0], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-\sqrt{0.3333333333333333}\right)\\
\mathbf{if}\;z \leq 1.05 \cdot 10^{-133}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{+94}:\\
\;\;\;\;\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\end{array}
\end{array}
if z < 1.05e-133 or 5.4999999999999997e94 < z < 8.1999999999999999e102Initial program 42.0%
Taylor expanded in x around -inf 17.9%
mul-1-neg17.9%
distribute-rgt-neg-in17.9%
Simplified17.9%
if 1.05e-133 < z < 5.4999999999999997e94Initial program 62.2%
if 8.1999999999999999e102 < z Initial program 25.5%
add-log-exp6.9%
*-un-lft-identity6.9%
log-prod6.9%
metadata-eval6.9%
add-log-exp25.5%
sqrt-div25.5%
associate-+l+25.5%
fma-udef25.5%
add-sqr-sqrt25.5%
hypot-def27.9%
fma-udef27.9%
hypot-def99.4%
Applied egg-rr99.4%
+-lft-identity99.4%
hypot-def27.9%
+-commutative27.9%
hypot-def99.4%
Simplified99.4%
Taylor expanded in z around inf 71.6%
Final simplification33.9%
(FPCore (x y z) :precision binary64 (if (<= x -2.3e+30) (* x (- (sqrt 0.3333333333333333))) (/ z (sqrt 3.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.3e+30) {
tmp = x * -sqrt(0.3333333333333333);
} else {
tmp = z / sqrt(3.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-2.3d+30)) then
tmp = x * -sqrt(0.3333333333333333d0)
else
tmp = z / sqrt(3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.3e+30) {
tmp = x * -Math.sqrt(0.3333333333333333);
} else {
tmp = z / Math.sqrt(3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.3e+30: tmp = x * -math.sqrt(0.3333333333333333) else: tmp = z / math.sqrt(3.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.3e+30) tmp = Float64(x * Float64(-sqrt(0.3333333333333333))); else tmp = Float64(z / sqrt(3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.3e+30) tmp = x * -sqrt(0.3333333333333333); else tmp = z / sqrt(3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.3e+30], N[(x * (-N[Sqrt[0.3333333333333333], $MachinePrecision])), $MachinePrecision], N[(z / N[Sqrt[3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+30}:\\
\;\;\;\;x \cdot \left(-\sqrt{0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\end{array}
\end{array}
if x < -2.3e30Initial program 31.4%
Taylor expanded in x around -inf 59.3%
mul-1-neg59.3%
distribute-rgt-neg-in59.3%
Simplified59.3%
if -2.3e30 < x Initial program 46.5%
add-log-exp7.3%
*-un-lft-identity7.3%
log-prod7.3%
metadata-eval7.3%
add-log-exp46.5%
sqrt-div46.3%
associate-+l+46.3%
fma-udef46.3%
add-sqr-sqrt46.3%
hypot-def54.9%
fma-udef54.9%
hypot-def99.4%
Applied egg-rr99.4%
+-lft-identity99.4%
hypot-def54.9%
+-commutative54.9%
hypot-def99.4%
Simplified99.4%
Taylor expanded in z around inf 19.2%
Final simplification27.0%
(FPCore (x y z) :precision binary64 (* z (sqrt 0.3333333333333333)))
double code(double x, double y, double z) {
return z * sqrt(0.3333333333333333);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z * sqrt(0.3333333333333333d0)
end function
public static double code(double x, double y, double z) {
return z * Math.sqrt(0.3333333333333333);
}
def code(x, y, z): return z * math.sqrt(0.3333333333333333)
function code(x, y, z) return Float64(z * sqrt(0.3333333333333333)) end
function tmp = code(x, y, z) tmp = z * sqrt(0.3333333333333333); end
code[x_, y_, z_] := N[(z * N[Sqrt[0.3333333333333333], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \sqrt{0.3333333333333333}
\end{array}
Initial program 43.5%
Taylor expanded in z around inf 17.4%
Final simplification17.4%
(FPCore (x y z) :precision binary64 (/ z (sqrt 3.0)))
double code(double x, double y, double z) {
return z / sqrt(3.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z / sqrt(3.0d0)
end function
public static double code(double x, double y, double z) {
return z / Math.sqrt(3.0);
}
def code(x, y, z): return z / math.sqrt(3.0)
function code(x, y, z) return Float64(z / sqrt(3.0)) end
function tmp = code(x, y, z) tmp = z / sqrt(3.0); end
code[x_, y_, z_] := N[(z / N[Sqrt[3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{z}{\sqrt{3}}
\end{array}
Initial program 43.5%
add-log-exp7.1%
*-un-lft-identity7.1%
log-prod7.1%
metadata-eval7.1%
add-log-exp43.5%
sqrt-div43.4%
associate-+l+43.4%
fma-udef43.4%
add-sqr-sqrt43.4%
hypot-def56.4%
fma-udef56.4%
hypot-def99.4%
Applied egg-rr99.4%
+-lft-identity99.4%
hypot-def56.4%
+-commutative56.4%
hypot-def99.4%
Simplified99.4%
Taylor expanded in z around inf 17.4%
Final simplification17.4%
(FPCore (x y z)
:precision binary64
(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))))
double code(double x, double y, double z) {
double tmp;
if (z < -6.396479394109776e+136) {
tmp = -z / sqrt(3.0);
} else if (z < 7.320293694404182e+117) {
tmp = sqrt((((z * z) + (x * x)) + (y * y))) / sqrt(3.0);
} else {
tmp = sqrt(0.3333333333333333) * z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z < (-6.396479394109776d+136)) then
tmp = -z / sqrt(3.0d0)
else if (z < 7.320293694404182d+117) then
tmp = sqrt((((z * z) + (x * x)) + (y * y))) / sqrt(3.0d0)
else
tmp = sqrt(0.3333333333333333d0) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < -6.396479394109776e+136) {
tmp = -z / Math.sqrt(3.0);
} else if (z < 7.320293694404182e+117) {
tmp = Math.sqrt((((z * z) + (x * x)) + (y * y))) / Math.sqrt(3.0);
} else {
tmp = Math.sqrt(0.3333333333333333) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < -6.396479394109776e+136: tmp = -z / math.sqrt(3.0) elif z < 7.320293694404182e+117: tmp = math.sqrt((((z * z) + (x * x)) + (y * y))) / math.sqrt(3.0) else: tmp = math.sqrt(0.3333333333333333) * z return tmp
function code(x, y, z) tmp = 0.0 if (z < -6.396479394109776e+136) tmp = Float64(Float64(-z) / sqrt(3.0)); elseif (z < 7.320293694404182e+117) tmp = Float64(sqrt(Float64(Float64(Float64(z * z) + Float64(x * x)) + Float64(y * y))) / sqrt(3.0)); else tmp = Float64(sqrt(0.3333333333333333) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < -6.396479394109776e+136) tmp = -z / sqrt(3.0); elseif (z < 7.320293694404182e+117) tmp = sqrt((((z * z) + (x * x)) + (y * y))) / sqrt(3.0); else tmp = sqrt(0.3333333333333333) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, -6.396479394109776e+136], N[((-z) / N[Sqrt[3.0], $MachinePrecision]), $MachinePrecision], If[Less[z, 7.320293694404182e+117], N[(N[Sqrt[N[(N[(N[(z * z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[3.0], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[0.3333333333333333], $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\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}
\end{array}
herbie shell --seed 2023192
(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)))