\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \le -111.1378599360788115291143185459077358246:\\
\;\;\;\;2 \cdot \frac{1}{{x}^{7}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{5}}\right)\\
\mathbf{elif}\;x \le 144.7677165249174038308410672470927238464:\\
\;\;\;\;\mathsf{fma}\left(1, \frac{1}{x + 1}, -\frac{1}{x} \cdot 2\right) + \left(\mathsf{fma}\left(-\frac{1}{x}, 2, \frac{1}{x} \cdot 2\right) + \frac{1}{x - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{1}{{x}^{7}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{5}}\right)\\
\end{array}double f(double x) {
double r23207997 = 1.0;
double r23207998 = x;
double r23207999 = r23207998 + r23207997;
double r23208000 = r23207997 / r23207999;
double r23208001 = 2.0;
double r23208002 = r23208001 / r23207998;
double r23208003 = r23208000 - r23208002;
double r23208004 = r23207998 - r23207997;
double r23208005 = r23207997 / r23208004;
double r23208006 = r23208003 + r23208005;
return r23208006;
}
double f(double x) {
double r23208007 = x;
double r23208008 = -111.13785993607881;
bool r23208009 = r23208007 <= r23208008;
double r23208010 = 2.0;
double r23208011 = 1.0;
double r23208012 = 7.0;
double r23208013 = pow(r23208007, r23208012);
double r23208014 = r23208011 / r23208013;
double r23208015 = r23208010 * r23208014;
double r23208016 = 3.0;
double r23208017 = pow(r23208007, r23208016);
double r23208018 = r23208011 / r23208017;
double r23208019 = r23208010 * r23208018;
double r23208020 = 5.0;
double r23208021 = pow(r23208007, r23208020);
double r23208022 = r23208011 / r23208021;
double r23208023 = r23208010 * r23208022;
double r23208024 = r23208019 + r23208023;
double r23208025 = r23208015 + r23208024;
double r23208026 = 144.7677165249174;
bool r23208027 = r23208007 <= r23208026;
double r23208028 = 1.0;
double r23208029 = r23208007 + r23208028;
double r23208030 = r23208028 / r23208029;
double r23208031 = r23208011 / r23208007;
double r23208032 = r23208031 * r23208010;
double r23208033 = -r23208032;
double r23208034 = fma(r23208011, r23208030, r23208033);
double r23208035 = -r23208031;
double r23208036 = fma(r23208035, r23208010, r23208032);
double r23208037 = r23208007 - r23208028;
double r23208038 = r23208028 / r23208037;
double r23208039 = r23208036 + r23208038;
double r23208040 = r23208034 + r23208039;
double r23208041 = r23208027 ? r23208040 : r23208025;
double r23208042 = r23208009 ? r23208025 : r23208041;
return r23208042;
}




Bits error versus x
| Original | 9.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if x < -111.13785993607881 or 144.7677165249174 < x Initial program 19.5
rmApplied div-inv19.5
Applied *-un-lft-identity19.5
Applied prod-diff19.5
Applied associate-+l+19.5
rmApplied add-cbrt-cube19.5
Simplified19.5
Taylor expanded around inf 0.5
if -111.13785993607881 < x < 144.7677165249174Initial program 0.1
rmApplied div-inv0.1
Applied *-un-lft-identity0.1
Applied prod-diff0.1
Applied associate-+l+0.1
Final simplification0.3
herbie shell --seed 2019173 +o rules:numerics
(FPCore (x)
:name "3frac (problem 3.3.3)"
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))