\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\begin{array}{l}
\mathbf{if}\;y \leq -2.604223501683959 \cdot 10^{+40}:\\
\;\;\;\;-y\\
\mathbf{elif}\;y \leq 6.450989484237564 \cdot 10^{+111}:\\
\;\;\;\;\sqrt{z \cdot z + \left(x \cdot x + y \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}(FPCore (x y z) :precision binary64 (sqrt (+ (+ (* x x) (* y y)) (* z z))))
(FPCore (x y z)
:precision binary64
(if (<= y -2.604223501683959e+40)
(- y)
(if (<= y 6.450989484237564e+111)
(sqrt (+ (* z z) (+ (* x x) (* y y))))
y)))double code(double x, double y, double z) {
return sqrt(((x * x) + (y * y)) + (z * z));
}
double code(double x, double y, double z) {
double tmp;
if (y <= -2.604223501683959e+40) {
tmp = -y;
} else if (y <= 6.450989484237564e+111) {
tmp = sqrt((z * z) + ((x * x) + (y * y)));
} else {
tmp = y;
}
return tmp;
}





















Bits error versus x





















Bits error versus y





















Bits error versus z
Results
| Original | 37.6 |
|---|---|
| Target | 25.4 |
| Herbie | 25.6 |
| Alternative 1 | |
|---|---|
| Error | 37.8 |
| Cost | 27072 |
| Alternative 2 | |
|---|---|
| Error | 55.4 |
| Cost | 21120 |
| Alternative 3 | |
|---|---|
| Error | 37.8 |
| Cost | 19968 |
| Alternative 4 | |
|---|---|
| Error | 37.6 |
| Cost | 7104 |
| Alternative 5 | |
|---|---|
| Error | 46.0 |
| Cost | 6848 |
| Alternative 6 | |
|---|---|
| Error | 45.7 |
| Cost | 6848 |
| Alternative 7 | |
|---|---|
| Error | 55.0 |
| Cost | 960 |
| Alternative 8 | |
|---|---|
| Error | 54.1 |
| Cost | 960 |
| Alternative 9 | |
|---|---|
| Error | 52.1 |
| Cost | 128 |
| Alternative 10 | |
|---|---|
| Error | 51.8 |
| Cost | 128 |
| Alternative 11 | |
|---|---|
| Error | 52.2 |
| Cost | 128 |
| Alternative 12 | |
|---|---|
| Error | 52.8 |
| Cost | 64 |
| Alternative 13 | |
|---|---|
| Error | 51.9 |
| Cost | 64 |
| Alternative 14 | |
|---|---|
| Error | 52.0 |
| Cost | 64 |
| Alternative 15 | |
|---|---|
| Error | 60.8 |
| Cost | 64 |
| Alternative 16 | |
|---|---|
| Error | 62.5 |
| Cost | 64 |
| Alternative 17 | |
|---|---|
| Error | 63.3 |
| Cost | 64 |

if y < -2.6042235016839591e40Initial program 47.4
Taylor expanded around -inf 21.3
Simplified21.3
Simplified21.3
if -2.6042235016839591e40 < y < 6.45098948423756438e111Initial program 29.4
Simplified29.4
if 6.45098948423756438e111 < y Initial program 57.3
Taylor expanded around inf 15.9
Simplified15.9
Final simplification25.6
herbie shell --seed 2021042
(FPCore (x y z)
:name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
:precision binary64
:herbie-target
(if (< z -6.396479394109776e+136) (- z) (if (< z 7.320293694404182e+117) (sqrt (+ (+ (* z z) (* x x)) (* y y))) z))
(sqrt (+ (+ (* x x) (* y y)) (* z z))))