\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}\;\left(y \cdot 4\right) \cdot y \le 2.174421384893924790992224326813252125458 \cdot 10^{-280}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(1\right)\right)\\
\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 8.230670362041086953876160251338189070944 \cdot 10^{131}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\
\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 2.03161264382512748863457943165021620583 \cdot 10^{174}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(1\right)\right)\\
\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.607743261394176407070185827861113403623 \cdot 10^{244}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{{x}^{2} - 4 \cdot {y}^{2}}{\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 r564235 = x;
double r564236 = r564235 * r564235;
double r564237 = y;
double r564238 = 4.0;
double r564239 = r564237 * r564238;
double r564240 = r564239 * r564237;
double r564241 = r564236 - r564240;
double r564242 = r564236 + r564240;
double r564243 = r564241 / r564242;
return r564243;
}
double f(double x, double y) {
double r564244 = y;
double r564245 = 4.0;
double r564246 = r564244 * r564245;
double r564247 = r564246 * r564244;
double r564248 = 2.1744213848939248e-280;
bool r564249 = r564247 <= r564248;
double r564250 = 1.0;
double r564251 = expm1(r564250);
double r564252 = log1p(r564251);
double r564253 = 8.230670362041087e+131;
bool r564254 = r564247 <= r564253;
double r564255 = x;
double r564256 = r564255 * r564255;
double r564257 = r564256 - r564247;
double r564258 = r564256 + r564247;
double r564259 = r564257 / r564258;
double r564260 = 2.0316126438251275e+174;
bool r564261 = r564247 <= r564260;
double r564262 = 1.6077432613941764e+244;
bool r564263 = r564247 <= r564262;
double r564264 = 2.0;
double r564265 = pow(r564255, r564264);
double r564266 = pow(r564244, r564264);
double r564267 = r564245 * r564266;
double r564268 = r564265 - r564267;
double r564269 = fma(r564255, r564255, r564247);
double r564270 = r564268 / r564269;
double r564271 = expm1(r564270);
double r564272 = log1p(r564271);
double r564273 = -1.0;
double r564274 = r564263 ? r564272 : r564273;
double r564275 = r564261 ? r564252 : r564274;
double r564276 = r564254 ? r564259 : r564275;
double r564277 = r564249 ? r564252 : r564276;
return r564277;
}




Bits error versus x




Bits error versus y
| Original | 31.7 |
|---|---|
| Target | 31.4 |
| Herbie | 13.3 |
if (* (* y 4.0) y) < 2.1744213848939248e-280 or 8.230670362041087e+131 < (* (* y 4.0) y) < 2.0316126438251275e+174Initial program 27.4
rmApplied log1p-expm1-u27.4
Simplified27.5
Taylor expanded around inf 12.8
if 2.1744213848939248e-280 < (* (* y 4.0) y) < 8.230670362041087e+131Initial program 16.1
if 2.0316126438251275e+174 < (* (* y 4.0) y) < 1.6077432613941764e+244Initial program 16.2
rmApplied log1p-expm1-u16.2
Simplified16.2
if 1.6077432613941764e+244 < (* (* y 4.0) y) Initial program 55.9
Taylor expanded around 0 10.3
Final simplification13.3
herbie shell --seed 2019306 +o rules:numerics
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))) 0.974323384962678118) (- (/ (* x x) (+ (* x x) (* (* y y) 4))) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4)))) 2) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))))
(/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))))