\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 r154018 = 1.0;
double r154019 = x;
double r154020 = r154019 + r154018;
double r154021 = r154018 / r154020;
double r154022 = 2.0;
double r154023 = r154022 / r154019;
double r154024 = r154021 - r154023;
double r154025 = r154019 - r154018;
double r154026 = r154018 / r154025;
double r154027 = r154024 + r154026;
return r154027;
}
double f(double x) {
double r154028 = x;
double r154029 = -111.02026224228146;
bool r154030 = r154028 <= r154029;
double r154031 = 1.0;
double r154032 = 2.0;
double r154033 = 7.0;
double r154034 = pow(r154028, r154033);
double r154035 = r154031 / r154034;
double r154036 = 5.0;
double r154037 = pow(r154028, r154036);
double r154038 = r154031 / r154037;
double r154039 = r154032 / r154028;
double r154040 = r154028 * r154028;
double r154041 = r154039 / r154040;
double r154042 = fma(r154032, r154038, r154041);
double r154043 = fma(r154032, r154035, r154042);
double r154044 = r154031 * r154043;
double r154045 = 109.89750468235896;
bool r154046 = r154028 <= r154045;
double r154047 = 1.0;
double r154048 = r154028 + r154047;
double r154049 = r154047 / r154048;
double r154050 = r154049 - r154039;
double r154051 = r154028 - r154047;
double r154052 = r154047 / r154051;
double r154053 = r154050 + r154052;
double r154054 = r154031 * r154053;
double r154055 = 3.0;
double r154056 = pow(r154028, r154055);
double r154057 = r154032 / r154056;
double r154058 = fma(r154032, r154038, r154057);
double r154059 = fma(r154032, r154035, r154058);
double r154060 = r154031 * r154059;
double r154061 = r154046 ? r154054 : r154060;
double r154062 = r154030 ? r154044 : r154061;
return r154062;
}




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))))