\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}\;y \cdot \left(y \cdot 4\right) \leq 6.819785607400204 \cdot 10^{-243}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 1.391055848722249 \cdot 10^{-30}:\\
\;\;\;\;\frac{1}{\frac{y \cdot \left(y \cdot 4\right) + x \cdot x}{x \cdot x - y \cdot \left(y \cdot 4\right)}}\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 6.062263388767952 \cdot 10^{-08}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 5.256578097418344 \cdot 10^{+213}:\\
\;\;\;\;\log \left(e^{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + 0.5 \cdot \sqrt[3]{{\left(\frac{x}{y}\right)}^{6}}\\
\end{array}(FPCore (x y) :precision binary64 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
:precision binary64
(if (<= (* y (* y 4.0)) 6.819785607400204e-243)
1.0
(if (<= (* y (* y 4.0)) 1.391055848722249e-30)
(/ 1.0 (/ (+ (* y (* y 4.0)) (* x x)) (- (* x x) (* y (* y 4.0)))))
(if (<= (* y (* y 4.0)) 6.062263388767952e-08)
1.0
(if (<= (* y (* y 4.0)) 5.256578097418344e+213)
(log
(exp (/ (- (* x x) (* y (* y 4.0))) (+ (* y (* y 4.0)) (* x x)))))
(+ -1.0 (* 0.5 (cbrt (pow (/ x y) 6.0)))))))))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 tmp;
if ((y * (y * 4.0)) <= 6.819785607400204e-243) {
tmp = 1.0;
} else if ((y * (y * 4.0)) <= 1.391055848722249e-30) {
tmp = 1.0 / (((y * (y * 4.0)) + (x * x)) / ((x * x) - (y * (y * 4.0))));
} else if ((y * (y * 4.0)) <= 6.062263388767952e-08) {
tmp = 1.0;
} else if ((y * (y * 4.0)) <= 5.256578097418344e+213) {
tmp = log(exp(((x * x) - (y * (y * 4.0))) / ((y * (y * 4.0)) + (x * x))));
} else {
tmp = -1.0 + (0.5 * cbrt(pow((x / y), 6.0)));
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 32.1 |
|---|---|
| Target | 31.8 |
| Herbie | 12.7 |
if (*.f64 (*.f64 y 4) y) < 6.81978560740020417e-243 or 1.39105584872224907e-30 < (*.f64 (*.f64 y 4) y) < 6.06226338876795223e-8Initial program 28.8
Taylor expanded around inf 11.6
if 6.81978560740020417e-243 < (*.f64 (*.f64 y 4) y) < 1.39105584872224907e-30Initial program 16.2
rmApplied clear-num_binary64_1610416.2
if 6.06226338876795223e-8 < (*.f64 (*.f64 y 4) y) < 5.2565780974183442e213Initial program 15.5
rmApplied add-log-exp_binary64_1614415.5
if 5.2565780974183442e213 < (*.f64 (*.f64 y 4) y) Initial program 52.7
Taylor expanded around 0 17.1
Simplified17.1
rmApplied add-cbrt-cube_binary64_1614117.1
Simplified10.5
Final simplification12.7
herbie shell --seed 2021059
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))