\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 \leq -4.840441743074084 \cdot 10^{+159}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -4.569228095431844 \cdot 10^{+148}:\\
\;\;\;\;1 - 8 \cdot e^{2 \cdot \log \left(\frac{y}{x}\right)}\\
\mathbf{elif}\;y \leq -1.9184276867004103 \cdot 10^{-67}:\\
\;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\
\mathbf{elif}\;y \leq 1.45879755932371 \cdot 10^{-128}:\\
\;\;\;\;1 - 8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;y \leq 1.326325169906906 \cdot 10^{+128}:\\
\;\;\;\;\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 (<= y -4.840441743074084e+159)
-1.0
(if (<= y -4.569228095431844e+148)
(- 1.0 (* 8.0 (exp (* 2.0 (log (/ y x))))))
(if (<= y -1.9184276867004103e-67)
(/ (- (* x x) (* y (* y 4.0))) (+ (* x x) (* y (* y 4.0))))
(if (<= y 1.45879755932371e-128)
(- 1.0 (* 8.0 (* (/ y x) (/ y x))))
(if (<= y 1.326325169906906e+128)
(-
(/ (* 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 (y <= -4.840441743074084e+159) {
tmp = -1.0;
} else if (y <= -4.569228095431844e+148) {
tmp = 1.0 - (8.0 * exp(2.0 * log(y / x)));
} else if (y <= -1.9184276867004103e-67) {
tmp = ((x * x) - (y * (y * 4.0))) / ((x * x) + (y * (y * 4.0)));
} else if (y <= 1.45879755932371e-128) {
tmp = 1.0 - (8.0 * ((y / x) * (y / x)));
} else if (y <= 1.326325169906906e+128) {
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 | 12.7 |
if y < -4.8404417430740843e159 or 1.3263251699069059e128 < y Initial program 60.9
Taylor expanded around 0 8.8
if -4.8404417430740843e159 < y < -4.5692280954318441e148Initial program 35.8
Taylor expanded around inf 55.2
Simplified55.2
rmApplied add-exp-log_binary64_1512060.1
Applied add-exp-log_binary64_1512060.1
Applied prod-exp_binary64_1513160.1
Applied add-exp-log_binary64_1512064.0
Applied add-exp-log_binary64_1512064.0
Applied prod-exp_binary64_1513164.0
Applied div-exp_binary64_1513364.0
Simplified52.3
if -4.5692280954318441e148 < y < -1.9184276867004103e-67Initial program 15.7
if -1.9184276867004103e-67 < y < 1.4587975593237099e-128Initial program 27.9
Taylor expanded around inf 16.6
Simplified16.6
rmApplied times-frac_binary64_1508810.4
if 1.4587975593237099e-128 < y < 1.3263251699069059e128Initial program 16.9
rmApplied div-sub_binary64_1508716.9
Final simplification12.7
herbie shell --seed 2021023
(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))))