\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\
t_2 := \mathsf{fma}\left({\left(\frac{y}{x}\right)}^{2}, -8, 1\right)\\
\mathbf{if}\;x \leq -2.1078549869940875 \cdot 10^{+83}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -8.642290443819559 \cdot 10^{-126}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9.883008504928267 \cdot 10^{-118}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.259789577185776 \cdot 10^{-48}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 8.07270989499859 \cdot 10^{-14}:\\
\;\;\;\;-1 + 0.5 \cdot \frac{{x}^{2}}{{y}^{2}}\\
\mathbf{elif}\;x \leq 1.11024680895731 \cdot 10^{+69}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
(FPCore (x y) :precision binary64 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (/ (- (* x x) t_0) (+ (* x x) t_0)))
(t_2 (fma (pow (/ y x) 2.0) -8.0 1.0)))
(if (<= x -2.1078549869940875e+83)
t_2
(if (<= x -8.642290443819559e-126)
t_1
(if (<= x 9.883008504928267e-118)
-1.0
(if (<= x 2.259789577185776e-48)
t_1
(if (<= x 8.07270989499859e-14)
(+ -1.0 (* 0.5 (/ (pow x 2.0) (pow y 2.0))))
(if (<= x 1.11024680895731e+69) t_1 t_2))))))))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 t_0 = y * (y * 4.0);
double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
double t_2 = fma(pow((y / x), 2.0), -8.0, 1.0);
double tmp;
if (x <= -2.1078549869940875e+83) {
tmp = t_2;
} else if (x <= -8.642290443819559e-126) {
tmp = t_1;
} else if (x <= 9.883008504928267e-118) {
tmp = -1.0;
} else if (x <= 2.259789577185776e-48) {
tmp = t_1;
} else if (x <= 8.07270989499859e-14) {
tmp = -1.0 + (0.5 * (pow(x, 2.0) / pow(y, 2.0)));
} else if (x <= 1.11024680895731e+69) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 31.9 |
|---|---|
| Target | 31.6 |
| Herbie | 13.1 |
if x < -2.1078549869940875e83 or 1.11024680895730993e69 < x Initial program 48.5
Simplified48.5
Taylor expanded in y around 0 18.2
Simplified18.2
Taylor expanded in y around 0 18.2
Simplified12.0
if -2.1078549869940875e83 < x < -8.64229044381955858e-126 or 9.8830085049282675e-118 < x < 2.25978957718577587e-48 or 8.07270989499859019e-14 < x < 1.11024680895730993e69Initial program 16.2
if -8.64229044381955858e-126 < x < 9.8830085049282675e-118Initial program 28.0
Simplified28.3
Taylor expanded in y around inf 10.0
if 2.25978957718577587e-48 < x < 8.07270989499859019e-14Initial program 15.3
Simplified15.3
Taylor expanded in y around inf 28.6
Final simplification13.1
herbie shell --seed 2022160
(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))))