\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 -4.624630821563891 \cdot 10^{+151}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -5.472397692701883 \cdot 10^{-68}:\\
\;\;\;\;\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{elif}\;x \leq 1.733125606425097 \cdot 10^{-69}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 9.896373077841149 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(y, -4 \cdot y, x \cdot x\right)}{\mathsf{fma}\left(y, y \cdot 4, x \cdot x\right)}\right)\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 -4.624630821563891e+151)
1.0
(if (<= x -5.472397692701883e-68)
(/ (fma -4.0 (* y y) (* x x)) (fma x x (* y (* y 4.0))))
(if (<= x 1.733125606425097e-69)
-1.0
(if (<= x 9.896373077841149e+151)
(expm1
(log1p (/ (fma y (* -4.0 y) (* x x)) (fma y (* y 4.0) (* x x)))))
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 <= -4.624630821563891e+151) {
tmp = 1.0;
} else if (x <= -5.472397692701883e-68) {
tmp = fma(-4.0, (y * y), (x * x)) / fma(x, x, (y * (y * 4.0)));
} else if (x <= 1.733125606425097e-69) {
tmp = -1.0;
} else if (x <= 9.896373077841149e+151) {
tmp = expm1(log1p(fma(y, (-4.0 * y), (x * x)) / fma(y, (y * 4.0), (x * x))));
} else {
tmp = 1.0;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 30.8 |
|---|---|
| Target | 30.5 |
| Herbie | 12.5 |
if x < -4.62463082156389072e151 or 9.89637307784114881e151 < x Initial program 63.4
Simplified63.4
Taylor expanded in y around 0 8.2
if -4.62463082156389072e151 < x < -5.47239769270188322e-68Initial program 15.3
Simplified15.3
if -5.47239769270188322e-68 < x < 1.733125606425097e-69Initial program 24.5
Simplified24.7
Taylor expanded in y around inf 12.8
if 1.733125606425097e-69 < x < 9.89637307784114881e151Initial program 14.9
Simplified14.8
Applied expm1-log1p-u_binary6414.9
Simplified14.8
Final simplification12.5
herbie shell --seed 2022081
(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))))