\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \le -111.0202622422814613400987582281231880188:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(2, \frac{1}{{x}^{7}}, \mathsf{fma}\left(2, \frac{1}{{x}^{5}}, \frac{\frac{2}{x}}{x \cdot x}\right)\right)\\
\mathbf{elif}\;x \le 109.8975046823589565292422776110470294952:\\
\;\;\;\;1 \cdot \left(\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(2, \frac{1}{{x}^{7}}, \mathsf{fma}\left(2, \frac{1}{{x}^{5}}, \frac{2}{{x}^{3}}\right)\right)\\
\end{array}double f(double x) {
double r170421 = 1.0;
double r170422 = x;
double r170423 = r170422 + r170421;
double r170424 = r170421 / r170423;
double r170425 = 2.0;
double r170426 = r170425 / r170422;
double r170427 = r170424 - r170426;
double r170428 = r170422 - r170421;
double r170429 = r170421 / r170428;
double r170430 = r170427 + r170429;
return r170430;
}
double f(double x) {
double r170431 = x;
double r170432 = -111.02026224228146;
bool r170433 = r170431 <= r170432;
double r170434 = 1.0;
double r170435 = 2.0;
double r170436 = 7.0;
double r170437 = pow(r170431, r170436);
double r170438 = r170434 / r170437;
double r170439 = 5.0;
double r170440 = pow(r170431, r170439);
double r170441 = r170434 / r170440;
double r170442 = r170435 / r170431;
double r170443 = r170431 * r170431;
double r170444 = r170442 / r170443;
double r170445 = fma(r170435, r170441, r170444);
double r170446 = fma(r170435, r170438, r170445);
double r170447 = r170434 * r170446;
double r170448 = 109.89750468235896;
bool r170449 = r170431 <= r170448;
double r170450 = 1.0;
double r170451 = r170431 + r170450;
double r170452 = r170450 / r170451;
double r170453 = r170452 - r170442;
double r170454 = r170431 - r170450;
double r170455 = r170450 / r170454;
double r170456 = r170453 + r170455;
double r170457 = r170434 * r170456;
double r170458 = 3.0;
double r170459 = pow(r170431, r170458);
double r170460 = r170435 / r170459;
double r170461 = fma(r170435, r170441, r170460);
double r170462 = fma(r170435, r170438, r170461);
double r170463 = r170434 * r170462;
double r170464 = r170449 ? r170457 : r170463;
double r170465 = r170433 ? r170447 : r170464;
return r170465;
}




Bits error versus x
| Original | 9.4 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if x < -111.02026224228146Initial program 18.3
rmApplied add-exp-log18.9
rmApplied *-un-lft-identity18.9
Applied log-prod18.9
Applied exp-sum18.9
Simplified18.9
Simplified18.3
Taylor expanded around inf 0.4
Simplified0.4
rmApplied cube-mult0.5
Applied associate-/r*0.1
if -111.02026224228146 < x < 109.89750468235896Initial program 0.0
rmApplied add-exp-log35.6
rmApplied *-un-lft-identity35.6
Applied log-prod35.6
Applied exp-sum35.6
Simplified35.6
Simplified0.0
if 109.89750468235896 < x Initial program 19.4
rmApplied add-exp-log19.4
rmApplied *-un-lft-identity19.4
Applied log-prod19.4
Applied exp-sum19.4
Simplified19.4
Simplified19.4
Taylor expanded around inf 0.6
Simplified0.6
Final simplification0.2
herbie shell --seed 2019353 +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))))