\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 9.8813129168249 \cdot 10^{-324}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2.0305632361013187 \cdot 10^{-198}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x + \left(y \cdot y\right) \cdot -4}{x \cdot x + 4 \cdot \left(y \cdot y\right)}\right)}^{3}}\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 6.818969806715923 \cdot 10^{-140}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2.7140562314388115 \cdot 10^{-101}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x + \left(y \cdot y\right) \cdot -4}{x \cdot x + 4 \cdot \left(y \cdot y\right)}\right)}^{3}}\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 5.385412758967982 \cdot 10^{-27}:\\
\;\;\;\;1 - 8 \cdot \frac{y \cdot y}{x \cdot x}\\
\mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 1.3525302745620225 \cdot 10^{+180}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot \left(y \cdot 4\right) + x \cdot x} - \frac{y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;-1 + \sqrt[3]{{\left(\left|\frac{x}{y}\right|\right)}^{2} \cdot 0.5} \cdot \left(\sqrt[3]{{\left(\left|\frac{x}{y}\right|\right)}^{2} \cdot 0.5} \cdot \sqrt[3]{{\left(\left|\frac{x}{y}\right|\right)}^{2} \cdot 0.5}\right)\\
\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)) 9.8813129168249e-324)
1.0
(if (<= (* y (* y 4.0)) 2.0305632361013187e-198)
(cbrt
(pow (/ (+ (* x x) (* (* y y) -4.0)) (+ (* x x) (* 4.0 (* y y)))) 3.0))
(if (<= (* y (* y 4.0)) 6.818969806715923e-140)
1.0
(if (<= (* y (* y 4.0)) 2.7140562314388115e-101)
(cbrt
(pow
(/ (+ (* x x) (* (* y y) -4.0)) (+ (* x x) (* 4.0 (* y y))))
3.0))
(if (<= (* y (* y 4.0)) 5.385412758967982e-27)
(- 1.0 (* 8.0 (/ (* y y) (* x x))))
(if (<= (* y (* y 4.0)) 1.3525302745620225e+180)
(-
(/ (* x x) (+ (* y (* y 4.0)) (* x x)))
(/ (* y (* y 4.0)) (+ (* y (* y 4.0)) (* x x))))
(+
-1.0
(*
(cbrt (* (pow (fabs (/ x y)) 2.0) 0.5))
(*
(cbrt (* (pow (fabs (/ x y)) 2.0) 0.5))
(cbrt (* (pow (fabs (/ x y)) 2.0) 0.5))))))))))))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)) <= 9.8813129168249e-324) {
tmp = 1.0;
} else if ((y * (y * 4.0)) <= 2.0305632361013187e-198) {
tmp = cbrt(pow((((x * x) + ((y * y) * -4.0)) / ((x * x) + (4.0 * (y * y)))), 3.0));
} else if ((y * (y * 4.0)) <= 6.818969806715923e-140) {
tmp = 1.0;
} else if ((y * (y * 4.0)) <= 2.7140562314388115e-101) {
tmp = cbrt(pow((((x * x) + ((y * y) * -4.0)) / ((x * x) + (4.0 * (y * y)))), 3.0));
} else if ((y * (y * 4.0)) <= 5.385412758967982e-27) {
tmp = 1.0 - (8.0 * ((y * y) / (x * x)));
} else if ((y * (y * 4.0)) <= 1.3525302745620225e+180) {
tmp = ((x * x) / ((y * (y * 4.0)) + (x * x))) - ((y * (y * 4.0)) / ((y * (y * 4.0)) + (x * x)));
} else {
tmp = -1.0 + (cbrt(pow(fabs(x / y), 2.0) * 0.5) * (cbrt(pow(fabs(x / y), 2.0) * 0.5) * cbrt(pow(fabs(x / y), 2.0) * 0.5)));
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.6 |
|---|---|
| Target | 31.3 |
| Herbie | 12.7 |
if (*.f64 (*.f64 y 4) y) < 9.88131e-324 or 2.0305632361013187e-198 < (*.f64 (*.f64 y 4) y) < 6.81896980671592274e-140Initial program 29.1
Taylor expanded around inf 9.2
if 9.88131e-324 < (*.f64 (*.f64 y 4) y) < 2.0305632361013187e-198 or 6.81896980671592274e-140 < (*.f64 (*.f64 y 4) y) < 2.7140562314388115e-101Initial program 16.5
rmApplied add-cbrt-cube_binary64_1989216.5
Simplified16.5
if 2.7140562314388115e-101 < (*.f64 (*.f64 y 4) y) < 5.38541275896798215e-27Initial program 17.4
Taylor expanded around inf 25.9
Simplified25.9
if 5.38541275896798215e-27 < (*.f64 (*.f64 y 4) y) < 1.3525302745620225e180Initial program 15.6
rmApplied div-sub_binary64_1986115.6
if 1.3525302745620225e180 < (*.f64 (*.f64 y 4) y) Initial program 49.4
Taylor expanded around 0 16.0
Simplified16.0
rmApplied add-sqr-sqrt_binary64_1987816.0
Simplified16.0
Simplified10.5
rmApplied add-cube-cbrt_binary64_1989110.5
Simplified10.5
Simplified10.5
Final simplification12.7
herbie shell --seed 2021098
(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))))