\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 \cdot x \leq 4.318107323633723 \cdot 10^{-290}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 6.546871147194143 \cdot 10^{-226}:\\
\;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\
\mathbf{elif}\;x \cdot x \leq 1.4077435868477773 \cdot 10^{-128}:\\
\;\;\;\;-1 + 0.5 \cdot \frac{{x}^{2}}{{y}^{2}}\\
\mathbf{elif}\;x \cdot x \leq 5.001370242576063 \cdot 10^{+187}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + y \cdot \left(y \cdot 4\right)} - \frac{y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\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 (<= (* x x) 4.318107323633723e-290)
-1.0
(if (<= (* x x) 6.546871147194143e-226)
(/ (- (* x x) (* y (* y 4.0))) (+ (* x x) (* y (* y 4.0))))
(if (<= (* x x) 1.4077435868477773e-128)
(+ -1.0 (* 0.5 (/ (pow x 2.0) (pow y 2.0))))
(if (<= (* x x) 5.001370242576063e+187)
(-
(/ (* x x) (+ (* x x) (* y (* y 4.0))))
(/ (* y (* y 4.0)) (+ (* x x) (* y (* y 4.0)))))
1.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 ((x * x) <= 4.318107323633723e-290) {
tmp = -1.0;
} else if ((x * x) <= 6.546871147194143e-226) {
tmp = ((x * x) - (y * (y * 4.0))) / ((x * x) + (y * (y * 4.0)));
} else if ((x * x) <= 1.4077435868477773e-128) {
tmp = -1.0 + (0.5 * (pow(x, 2.0) / pow(y, 2.0)));
} else if ((x * x) <= 5.001370242576063e+187) {
tmp = ((x * x) / ((x * x) + (y * (y * 4.0)))) - ((y * (y * 4.0)) / ((x * x) + (y * (y * 4.0))));
} else {
tmp = 1.0;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.9 |
|---|---|
| Target | 31.6 |
| Herbie | 13.1 |
if (*.f64 x x) < 4.31810732363372295e-290Initial program 28.9
Taylor expanded around 0 8.2
if 4.31810732363372295e-290 < (*.f64 x x) < 6.54687114719414309e-226Initial program 13.8
if 6.54687114719414309e-226 < (*.f64 x x) < 1.40774358684777733e-128Initial program 17.4
Taylor expanded around 0 22.1
if 1.40774358684777733e-128 < (*.f64 x x) < 5.00137024257606292e187Initial program 17.3
rmApplied div-sub_binary64_1611017.3
if 5.00137024257606292e187 < (*.f64 x x) Initial program 50.5
Taylor expanded around inf 11.4
Final simplification13.1
herbie shell --seed 2021044
(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))))