\sqrt{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;x \le -7.815000942687335399540629803602323238426 \cdot 10^{146}:\\
\;\;\;\;-1 \cdot x\\
\mathbf{elif}\;x \le 3.315991764196220167239997200279477919386 \cdot 10^{127}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}double f(double x, double y) {
double r634532 = x;
double r634533 = r634532 * r634532;
double r634534 = y;
double r634535 = r634534 * r634534;
double r634536 = r634533 + r634535;
double r634537 = sqrt(r634536);
return r634537;
}
double f(double x, double y) {
double r634538 = x;
double r634539 = -7.815000942687335e+146;
bool r634540 = r634538 <= r634539;
double r634541 = -1.0;
double r634542 = r634541 * r634538;
double r634543 = 3.31599176419622e+127;
bool r634544 = r634538 <= r634543;
double r634545 = r634538 * r634538;
double r634546 = y;
double r634547 = r634546 * r634546;
double r634548 = r634545 + r634547;
double r634549 = sqrt(r634548);
double r634550 = r634544 ? r634549 : r634538;
double r634551 = r634540 ? r634542 : r634550;
return r634551;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.8 |
|---|---|
| Target | 17.4 |
| Herbie | 17.2 |
if x < -7.815000942687335e+146Initial program 62.0
Taylor expanded around -inf 9.0
if -7.815000942687335e+146 < x < 3.31599176419622e+127Initial program 20.7
if 3.31599176419622e+127 < x Initial program 56.3
Taylor expanded around inf 8.4
Final simplification17.2
herbie shell --seed 2019294
(FPCore (x y)
:name "Data.Octree.Internal:octantDistance from Octree-0.5.4.2"
:precision binary64
:herbie-target
(if (< x -1.123695082659983e145) (- x) (if (< x 1.11655762118336204e93) (sqrt (+ (* x x) (* y y))) x))
(sqrt (+ (* x x) (* y y))))