\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}\;y \le -2.04179898258906648865287012115961201463 \cdot 10^{153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -3.379561403631358792480741892956065284459 \cdot 10^{-65}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{fma}\left(4, \left(-y\right) \cdot y, x \cdot x\right)}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}\right)\right)\\
\mathbf{elif}\;y \le 9.959621465941042556551382638800450476793 \cdot 10^{-80}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \le 2.371593609881423098610405616408534144725 \cdot 10^{60}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(4, \left(-y\right) \cdot y, x \cdot x\right)}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}double f(double x, double y) {
double r490099 = x;
double r490100 = r490099 * r490099;
double r490101 = y;
double r490102 = 4.0;
double r490103 = r490101 * r490102;
double r490104 = r490103 * r490101;
double r490105 = r490100 - r490104;
double r490106 = r490100 + r490104;
double r490107 = r490105 / r490106;
return r490107;
}
double f(double x, double y) {
double r490108 = y;
double r490109 = -2.0417989825890665e+153;
bool r490110 = r490108 <= r490109;
double r490111 = -1.0;
double r490112 = -3.379561403631359e-65;
bool r490113 = r490108 <= r490112;
double r490114 = 4.0;
double r490115 = -r490108;
double r490116 = r490115 * r490108;
double r490117 = x;
double r490118 = r490117 * r490117;
double r490119 = fma(r490114, r490116, r490118);
double r490120 = r490108 * r490114;
double r490121 = r490120 * r490108;
double r490122 = fma(r490117, r490117, r490121);
double r490123 = r490119 / r490122;
double r490124 = expm1(r490123);
double r490125 = log1p(r490124);
double r490126 = 9.959621465941043e-80;
bool r490127 = r490108 <= r490126;
double r490128 = 1.0;
double r490129 = 2.371593609881423e+60;
bool r490130 = r490108 <= r490129;
double r490131 = log1p(r490123);
double r490132 = expm1(r490131);
double r490133 = r490130 ? r490132 : r490111;
double r490134 = r490127 ? r490128 : r490133;
double r490135 = r490113 ? r490125 : r490134;
double r490136 = r490110 ? r490111 : r490135;
return r490136;
}




Bits error versus x




Bits error versus y
| Original | 31.6 |
|---|---|
| Target | 31.3 |
| Herbie | 12.8 |
if y < -2.0417989825890665e+153 or 2.371593609881423e+60 < y Initial program 52.9
Simplified52.9
Taylor expanded around inf 10.5
if -2.0417989825890665e+153 < y < -3.379561403631359e-65Initial program 16.2
Simplified16.2
rmApplied log1p-expm1-u16.2
Simplified16.2
if -3.379561403631359e-65 < y < 9.959621465941043e-80Initial program 25.4
Simplified25.4
rmApplied log1p-expm1-u25.4
Simplified25.6
Taylor expanded around 0 12.3
if 9.959621465941043e-80 < y < 2.371593609881423e+60Initial program 15.9
Simplified15.9
rmApplied expm1-log1p-u15.9
Simplified15.9
Final simplification12.8
herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
: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))))