\frac{x}{x \cdot x + 1}\begin{array}{l}
\mathbf{if}\;x \le -480639372.445875644683837890625 \lor \neg \left(x \le 418.3054548803003740431449841707944869995\right):\\
\;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\mathsf{fma}\left(x, x, 1\right)}\right)\right)\\
\end{array}double f(double x) {
double r47302 = x;
double r47303 = r47302 * r47302;
double r47304 = 1.0;
double r47305 = r47303 + r47304;
double r47306 = r47302 / r47305;
return r47306;
}
double f(double x) {
double r47307 = x;
double r47308 = -480639372.44587564;
bool r47309 = r47307 <= r47308;
double r47310 = 418.3054548803004;
bool r47311 = r47307 <= r47310;
double r47312 = !r47311;
bool r47313 = r47309 || r47312;
double r47314 = 1.0;
double r47315 = r47314 / r47307;
double r47316 = 1.0;
double r47317 = 5.0;
double r47318 = pow(r47307, r47317);
double r47319 = r47316 / r47318;
double r47320 = r47315 + r47319;
double r47321 = 3.0;
double r47322 = pow(r47307, r47321);
double r47323 = r47316 / r47322;
double r47324 = r47320 - r47323;
double r47325 = fma(r47307, r47307, r47316);
double r47326 = r47314 / r47325;
double r47327 = log1p(r47326);
double r47328 = expm1(r47327);
double r47329 = r47307 * r47328;
double r47330 = r47313 ? r47324 : r47329;
return r47330;
}




Bits error versus x
| Original | 15.2 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
if x < -480639372.44587564 or 418.3054548803004 < x Initial program 30.8
Simplified30.8
rmApplied div-inv30.8
Taylor expanded around inf 0.0
Simplified0.0
if -480639372.44587564 < x < 418.3054548803004Initial program 0.0
Simplified0.0
rmApplied div-inv0.0
rmApplied expm1-log1p-u0.0
Final simplification0.0
herbie shell --seed 2019209 +o rules:numerics
(FPCore (x)
:name "x / (x^2 + 1)"
:precision binary64
:herbie-target
(/ 1 (+ x (/ 1 x)))
(/ x (+ (* x x) 1)))