\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 -2.652976160851104 \cdot 10^{-175}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.2823881671957526 \cdot 10^{-151}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 4.756993983734216 \cdot 10^{-26}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 8.46966307063159 \cdot 10^{-14}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.541450281263339 \cdot 10^{+107}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 8.524407389953581 \cdot 10^{+198}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 6.341550649972557 \cdot 10^{+261}:\\
\;\;\;\;1\\
\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 -2.652976160851104e-175)
1.0
(if (<= y 3.2823881671957526e-151)
-1.0
(if (<= y 4.756993983734216e-26)
1.0
(if (<= y 8.46966307063159e-14)
-1.0
(if (<= y 2.541450281263339e+107)
1.0
(if (<= y 8.524407389953581e+198)
-1.0
(if (<= y 6.341550649972557e+261) 1.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 <= -2.652976160851104e-175) {
tmp = 1.0;
} else if (y <= 3.2823881671957526e-151) {
tmp = -1.0;
} else if (y <= 4.756993983734216e-26) {
tmp = 1.0;
} else if (y <= 8.46966307063159e-14) {
tmp = -1.0;
} else if (y <= 2.541450281263339e+107) {
tmp = 1.0;
} else if (y <= 8.524407389953581e+198) {
tmp = -1.0;
} else if (y <= 6.341550649972557e+261) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 47.9 |
|---|---|
| Target | 47.5 |
| Herbie | 31.4 |
if y < -2.6529761608511038e-175 or 3.28238816719575257e-151 < y < 4.7569939837342163e-26 or 8.4696630706315897e-14 < y < 2.54145028126333895e107 or 8.52440738995358133e198 < y < 6.3415506499725572e261Initial program 45.9
Simplified45.9
Taylor expanded in y around 0 31.4
if -2.6529761608511038e-175 < y < 3.28238816719575257e-151 or 4.7569939837342163e-26 < y < 8.4696630706315897e-14 or 2.54145028126333895e107 < y < 8.52440738995358133e198 or 6.3415506499725572e261 < y Initial program 50.2
Simplified50.2
Taylor expanded in y around inf 31.4
Final simplification31.4
herbie shell --seed 2022127
(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))))