\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \le -109.218011094796353 \lor \neg \left(x \le 115.29908004264922\right):\\
\;\;\;\;\mathsf{fma}\left(2, \frac{1}{{x}^{7}}, \mathsf{fma}\left(2, \frac{1}{{x}^{5}}, \frac{1}{x \cdot x} \cdot \frac{2}{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x - 1}\right)\right)\\
\end{array}double f(double x) {
double r386 = 1.0;
double r387 = x;
double r388 = r387 + r386;
double r389 = r386 / r388;
double r390 = 2.0;
double r391 = r390 / r387;
double r392 = r389 - r391;
double r393 = r387 - r386;
double r394 = r386 / r393;
double r395 = r392 + r394;
return r395;
}
double f(double x) {
double r396 = x;
double r397 = -109.21801109479635;
bool r398 = r396 <= r397;
double r399 = 115.29908004264922;
bool r400 = r396 <= r399;
double r401 = !r400;
bool r402 = r398 || r401;
double r403 = 2.0;
double r404 = 1.0;
double r405 = 7.0;
double r406 = pow(r396, r405);
double r407 = r404 / r406;
double r408 = 5.0;
double r409 = pow(r396, r408);
double r410 = r404 / r409;
double r411 = r396 * r396;
double r412 = r404 / r411;
double r413 = r403 / r396;
double r414 = r412 * r413;
double r415 = fma(r403, r410, r414);
double r416 = fma(r403, r407, r415);
double r417 = 1.0;
double r418 = r396 + r417;
double r419 = r417 / r418;
double r420 = r419 - r413;
double r421 = r396 - r417;
double r422 = r417 / r421;
double r423 = expm1(r422);
double r424 = log1p(r423);
double r425 = r420 + r424;
double r426 = r402 ? r416 : r425;
return r426;
}




Bits error versus x
| Original | 10.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
if x < -109.21801109479635 or 115.29908004264922 < x Initial program 19.9
Taylor expanded around inf 0.5
Simplified0.5
rmApplied add-cube-cbrt1.2
Applied unpow-prod-down1.2
Applied *-un-lft-identity1.2
Applied times-frac0.8
Simplified0.4
Simplified0.1
if -109.21801109479635 < x < 115.29908004264922Initial program 0.1
rmApplied log1p-expm1-u0.1
Final simplification0.1
herbie shell --seed 2020025 +o rules:numerics
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))