\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 \leq -3.915390878948144 \cdot 10^{+55}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-4, y \cdot y, x \cdot x\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\
\mathbf{if}\;x \leq -5.5870126386508446 \cdot 10^{-151}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4.6768304092466014 \cdot 10^{-97}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.8953957386349883 \cdot 10^{+27}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}\\
\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 -3.915390878948144e+55)
1.0
(let* ((t_0 (/ (fma -4.0 (* y y) (* x x)) (fma x x (* y (* y 4.0))))))
(if (<= x -5.5870126386508446e-151)
t_0
(if (<= x 4.6768304092466014e-97)
-1.0
(if (<= x 1.8953957386349883e+27) t_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 <= -3.915390878948144e+55) {
tmp = 1.0;
} else {
double t_0 = fma(-4.0, (y * y), (x * x)) / fma(x, x, (y * (y * 4.0)));
double tmp_1;
if (x <= -5.5870126386508446e-151) {
tmp_1 = t_0;
} else if (x <= 4.6768304092466014e-97) {
tmp_1 = -1.0;
} else if (x <= 1.8953957386349883e+27) {
tmp_1 = t_0;
} else {
tmp_1 = 1.0;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 31.6 |
|---|---|
| Target | 31.3 |
| Herbie | 13.6 |
if x < -3.9153908789481439e55 or 1.89539573863498833e27 < x Initial program 43.5
Simplified43.5
Taylor expanded in y around 0 14.8
if -3.9153908789481439e55 < x < -5.58701263865084461e-151 or 4.6768304092466014e-97 < x < 1.89539573863498833e27Initial program 15.7
Simplified15.7
if -5.58701263865084461e-151 < x < 4.6768304092466014e-97Initial program 28.3
Simplified28.5
Taylor expanded in y around inf 9.9
Final simplification13.6
herbie shell --seed 2022068
(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))))