\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)\\
\mathbf{if}\;x \cdot x \leq 1.8455816858840264 \cdot 10^{-266}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{x}{y}\right)}^{2}\right)\right), -1\right)\\
\mathbf{elif}\;x \cdot x \leq 2.087941773223886 \cdot 10^{+218}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\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
(let* ((t_0 (* y (* y 4.0))))
(if (<= (* x x) 1.8455816858840264e-266)
(fma 0.5 (expm1 (log1p (pow (/ x y) 2.0))) -1.0)
(if (<= (* x x) 2.087941773223886e+218)
(/ (- (* x x) t_0) (+ (* x x) 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 t_0 = y * (y * 4.0);
double tmp;
if ((x * x) <= 1.8455816858840264e-266) {
tmp = fma(0.5, expm1(log1p(pow((x / y), 2.0))), -1.0);
} else if ((x * x) <= 2.087941773223886e+218) {
tmp = ((x * x) - t_0) / ((x * x) + t_0);
} else {
tmp = 1.0;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 31.6 |
|---|---|
| Target | 31.2 |
| Herbie | 12.0 |
if (*.f64 x x) < 1.8455816858840264e-266Initial program 28.9
Simplified29.1
Taylor expanded in y around inf 14.5
Simplified14.5
Applied egg-rr7.5
if 1.8455816858840264e-266 < (*.f64 x x) < 2.0879417732238861e218Initial program 16.3
if 2.0879417732238861e218 < (*.f64 x x) Initial program 52.9
Simplified52.9
Taylor expanded in y around 0 10.6
Final simplification12.0
herbie shell --seed 2022130
(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))))