\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \le -112.31575512255452 \lor \neg \left(x \le 107.919341256729908\right):\\
\;\;\;\;\mathsf{fma}\left(2, \frac{1}{{x}^{7}}, \mathsf{fma}\left(2, \frac{1}{{x}^{5}}, {x}^{\left(-2\right)} \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 r103366 = 1.0;
double r103367 = x;
double r103368 = r103367 + r103366;
double r103369 = r103366 / r103368;
double r103370 = 2.0;
double r103371 = r103370 / r103367;
double r103372 = r103369 - r103371;
double r103373 = r103367 - r103366;
double r103374 = r103366 / r103373;
double r103375 = r103372 + r103374;
return r103375;
}
double f(double x) {
double r103376 = x;
double r103377 = -112.31575512255452;
bool r103378 = r103376 <= r103377;
double r103379 = 107.91934125672991;
bool r103380 = r103376 <= r103379;
double r103381 = !r103380;
bool r103382 = r103378 || r103381;
double r103383 = 2.0;
double r103384 = 1.0;
double r103385 = 7.0;
double r103386 = pow(r103376, r103385);
double r103387 = r103384 / r103386;
double r103388 = 5.0;
double r103389 = pow(r103376, r103388);
double r103390 = r103384 / r103389;
double r103391 = 2.0;
double r103392 = -r103391;
double r103393 = pow(r103376, r103392);
double r103394 = r103383 / r103376;
double r103395 = r103393 * r103394;
double r103396 = fma(r103383, r103390, r103395);
double r103397 = fma(r103383, r103387, r103396);
double r103398 = 1.0;
double r103399 = r103376 + r103398;
double r103400 = r103398 / r103399;
double r103401 = r103400 - r103394;
double r103402 = r103376 - r103398;
double r103403 = r103398 / r103402;
double r103404 = expm1(r103403);
double r103405 = log1p(r103404);
double r103406 = r103401 + r103405;
double r103407 = r103382 ? r103397 : r103406;
return r103407;
}




Bits error versus x
| Original | 9.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
if x < -112.31575512255452 or 107.91934125672991 < x Initial program 19.1
Taylor expanded around inf 0.5
Simplified0.5
rmApplied add-cube-cbrt1.1
Applied unpow-prod-down1.1
Applied *-un-lft-identity1.1
Applied times-frac0.7
Simplified0.4
Simplified0.1
rmApplied pow10.1
Applied pow10.1
Applied pow-prod-up0.1
Applied pow-flip0.1
Simplified0.1
if -112.31575512255452 < x < 107.91934125672991Initial program 0.1
rmApplied log1p-expm1-u0.1
Final simplification0.1
herbie shell --seed 2020021 +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))))