\[\sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}
\]
↓
\[\frac{\mathsf{hypot}\left(x, \mathsf{hypot}\left(y, z\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 x (hypot y z)) (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(x, hypot(y, z)) / 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(x, Math.hypot(y, z)) / 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(x, math.hypot(y, z)) / 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(x, hypot(y, z)) / 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(x, hypot(y, z)) / 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[x ^ 2 + N[Sqrt[y ^ 2 + z ^ 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(x, \mathsf{hypot}\left(y, z\right)\right)}{\sqrt{3}}
Alternatives
| Alternative 1 |
|---|
| Error | 33.0 |
|---|
| Cost | 14876 |
|---|
\[\begin{array}{l}
t_0 := \frac{z}{\sqrt{3}}\\
t_1 := z \cdot \sqrt{0.3333333333333333}\\
t_2 := \sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-239}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-186}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-67}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+57}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+255}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+298}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{hypot}\left(y, x\right)}{\sqrt{3}}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 20.2 |
|---|
| Cost | 13056 |
|---|
\[\frac{\mathsf{hypot}\left(z, x\right)}{\sqrt{3}}
\]
| Alternative 3 |
|---|
| Error | 20.2 |
|---|
| Cost | 13056 |
|---|
\[\sqrt{0.3333333333333333} \cdot \mathsf{hypot}\left(z, x\right)
\]
| Alternative 4 |
|---|
| Error | 40.9 |
|---|
| Cost | 8924 |
|---|
\[\begin{array}{l}
t_0 := \frac{z}{\sqrt{3}}\\
t_1 := z \cdot \sqrt{0.3333333333333333}\\
t_2 := \sqrt{\frac{\left(x \cdot x + y \cdot y\right) + z \cdot z}{3}}\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-239}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-186}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-67}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+57}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+255}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 10^{+298}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.3333333333333333} \cdot \left(-0.5 \cdot \frac{y}{\frac{x}{y}} - x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 44.2 |
|---|
| Cost | 7236 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.0928096931712628 \cdot 10^{+70}:\\
\;\;\;\;\sqrt{0.3333333333333333} \cdot \left(-0.5 \cdot \frac{y}{\frac{x}{y}} - x\right)\\
\mathbf{elif}\;x \leq -5.349477531016157 \cdot 10^{+32}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\mathbf{elif}\;x \leq -2.994381464941496 \cdot 10^{-28}:\\
\;\;\;\;\sqrt{\frac{x \cdot x}{3}}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \sqrt{0.3333333333333333}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 44.2 |
|---|
| Cost | 7116 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.0928096931712628 \cdot 10^{+70}:\\
\;\;\;\;\sqrt{0.3333333333333333} \cdot \left(-x\right)\\
\mathbf{elif}\;x \leq -5.349477531016157 \cdot 10^{+32}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\mathbf{elif}\;x \leq -2.994381464941496 \cdot 10^{-28}:\\
\;\;\;\;\sqrt{\frac{x \cdot x}{3}}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \sqrt{0.3333333333333333}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 44.3 |
|---|
| Cost | 7052 |
|---|
\[\begin{array}{l}
t_0 := \frac{-x}{\sqrt{3}}\\
\mathbf{if}\;x \leq -1.0928096931712628 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -5.349477531016157 \cdot 10^{+32}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\mathbf{elif}\;x \leq -119233.22702540075:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \sqrt{0.3333333333333333}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 44.2 |
|---|
| Cost | 7052 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{0.3333333333333333} \cdot \left(-x\right)\\
\mathbf{if}\;x \leq -1.0928096931712628 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -5.349477531016157 \cdot 10^{+32}:\\
\;\;\;\;\frac{z}{\sqrt{3}}\\
\mathbf{elif}\;x \leq -2.994381464941496 \cdot 10^{-28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \sqrt{0.3333333333333333}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 51.7 |
|---|
| Cost | 6592 |
|---|
\[\frac{z}{\sqrt{3}}
\]
| Alternative 10 |
|---|
| Error | 51.7 |
|---|
| Cost | 6592 |
|---|
\[z \cdot \sqrt{0.3333333333333333}
\]