\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\begin{array}{l}
\mathbf{if}\;x \le -6.06717838938592463 \cdot 10^{31}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \le 5.2797885245263103 \cdot 10^{-80}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \le 5.32364720038125515 \cdot 10^{39}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}double code(double x, double y) {
return (((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y)));
}
double code(double x, double y) {
double temp;
if ((x <= -6.067178389385925e+31)) {
temp = 1.0;
} else {
double temp_1;
if ((x <= 5.27978852452631e-80)) {
temp_1 = -1.0;
} else {
double temp_2;
if ((x <= 5.323647200381255e+39)) {
temp_2 = (1.0 / (fma(x, x, ((y * 4.0) * y)) / ((x * x) - ((y * 4.0) * y))));
} else {
temp_2 = 1.0;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.7 |
|---|---|
| Target | 31.4 |
| Herbie | 14.8 |
if x < -6.067178389385925e+31 or 5.323647200381255e+39 < x Initial program 43.1
Taylor expanded around inf 14.1
if -6.067178389385925e+31 < x < 5.27978852452631e-80Initial program 24.4
Taylor expanded around 0 15.3
if 5.27978852452631e-80 < x < 5.323647200381255e+39Initial program 15.6
rmApplied clear-num15.6
Simplified15.6
Final simplification14.8
herbie shell --seed 2020057 +o rules:numerics
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4))) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4)))) 2) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))))
(/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))))