\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 \cdot x \leq 1.434275908034364 \cdot 10^{-214}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, y \cdot y, x \cdot x\right)\\
t_1 := \mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)\\
\mathbf{if}\;x \cdot x \leq 3.549117142306552 \cdot 10^{+122}:\\
\;\;\;\;\frac{t_0}{t_1}\\
\mathbf{elif}\;x \cdot x \leq 4.0770094441479955 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{4}, -0.125, \mathsf{fma}\left(0.5, \frac{x \cdot x}{y \cdot y}, -1\right)\right)\\
\mathbf{elif}\;x \cdot x \leq 4.926949301618463 \cdot 10^{+215}:\\
\;\;\;\;\frac{1}{\frac{t_1}{t_0}}\\
\mathbf{elif}\;x \cdot x \leq 2.6925800993611535 \cdot 10^{+241}:\\
\;\;\;\;-1\\
\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 x) 1.434275908034364e-214)
-1.0
(let* ((t_0 (fma -4.0 (* y y) (* x x))) (t_1 (fma x x (* y (* y 4.0)))))
(if (<= (* x x) 3.549117142306552e+122)
(/ t_0 t_1)
(if (<= (* x x) 4.0770094441479955e+154)
(fma (pow (/ x y) 4.0) -0.125 (fma 0.5 (/ (* x x) (* y y)) -1.0))
(if (<= (* x x) 4.926949301618463e+215)
(/ 1.0 (/ t_1 t_0))
(if (<= (* x x) 2.6925800993611535e+241) -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 ((x * x) <= 1.434275908034364e-214) {
tmp = -1.0;
} else {
double t_0 = fma(-4.0, (y * y), (x * x));
double t_1 = fma(x, x, (y * (y * 4.0)));
double tmp_1;
if ((x * x) <= 3.549117142306552e+122) {
tmp_1 = t_0 / t_1;
} else if ((x * x) <= 4.0770094441479955e+154) {
tmp_1 = fma(pow((x / y), 4.0), -0.125, fma(0.5, ((x * x) / (y * y)), -1.0));
} else if ((x * x) <= 4.926949301618463e+215) {
tmp_1 = 1.0 / (t_1 / t_0);
} else if ((x * x) <= 2.6925800993611535e+241) {
tmp_1 = -1.0;
} else {
tmp_1 = 1.0;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 31.8 |
|---|---|
| Target | 31.5 |
| Herbie | 13.2 |
if (*.f64 x x) < 1.43427590803436405e-214 or 4.9269493016184627e215 < (*.f64 x x) < 2.69258009936115346e241Initial program 27.2
Simplified27.3
Taylor expanded in y around inf 12.5
if 1.43427590803436405e-214 < (*.f64 x x) < 3.54911714230655185e122Initial program 16.0
Simplified16.0
if 3.54911714230655185e122 < (*.f64 x x) < 4.07700944414799548e154Initial program 16.4
Simplified16.4
Taylor expanded in y around inf 37.1
Simplified36.5
if 4.07700944414799548e154 < (*.f64 x x) < 4.9269493016184627e215Initial program 13.2
Simplified13.2
Applied clear-num_binary6413.2
if 2.69258009936115346e241 < (*.f64 x x) Initial program 55.3
Simplified55.3
Taylor expanded in y around 0 9.6
Final simplification13.2
herbie shell --seed 2022077
(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))))