\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 r168721 = 1.0;
double r168722 = x;
double r168723 = r168722 + r168721;
double r168724 = r168721 / r168723;
double r168725 = 2.0;
double r168726 = r168725 / r168722;
double r168727 = r168724 - r168726;
double r168728 = r168722 - r168721;
double r168729 = r168721 / r168728;
double r168730 = r168727 + r168729;
return r168730;
}
double f(double x) {
double r168731 = x;
double r168732 = -109.21801109479635;
bool r168733 = r168731 <= r168732;
double r168734 = 115.29908004264922;
bool r168735 = r168731 <= r168734;
double r168736 = !r168735;
bool r168737 = r168733 || r168736;
double r168738 = 2.0;
double r168739 = 1.0;
double r168740 = 7.0;
double r168741 = pow(r168731, r168740);
double r168742 = r168739 / r168741;
double r168743 = 5.0;
double r168744 = pow(r168731, r168743);
double r168745 = r168739 / r168744;
double r168746 = r168731 * r168731;
double r168747 = r168739 / r168746;
double r168748 = r168738 / r168731;
double r168749 = r168747 * r168748;
double r168750 = fma(r168738, r168745, r168749);
double r168751 = fma(r168738, r168742, r168750);
double r168752 = 1.0;
double r168753 = r168731 + r168752;
double r168754 = r168752 / r168753;
double r168755 = r168754 - r168748;
double r168756 = r168731 - r168752;
double r168757 = r168752 / r168756;
double r168758 = expm1(r168757);
double r168759 = log1p(r168758);
double r168760 = r168755 + r168759;
double r168761 = r168737 ? r168751 : r168760;
return r168761;
}




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