\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000000005617284415393442031927406788:\\
\;\;\;\;\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r63861 = 1.0;
double r63862 = x;
double r63863 = r63861 + r63862;
double r63864 = log(r63863);
return r63864;
}
double f(double x) {
double r63865 = 1.0;
double r63866 = x;
double r63867 = r63865 + r63866;
double r63868 = 1.0000000000056173;
bool r63869 = r63867 <= r63868;
double r63870 = r63865 * r63866;
double r63871 = log(r63865);
double r63872 = r63870 + r63871;
double r63873 = 0.5;
double r63874 = 2.0;
double r63875 = pow(r63866, r63874);
double r63876 = pow(r63865, r63874);
double r63877 = r63875 / r63876;
double r63878 = r63873 * r63877;
double r63879 = r63872 - r63878;
double r63880 = sqrt(r63867);
double r63881 = log(r63880);
double r63882 = r63881 + r63881;
double r63883 = r63869 ? r63879 : r63882;
return r63883;
}




Bits error versus x
Results
| Original | 38.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
if (+ 1.0 x) < 1.0000000000056173Initial program 59.3
Taylor expanded around 0 0.3
if 1.0000000000056173 < (+ 1.0 x) Initial program 0.6
rmApplied add-sqr-sqrt0.7
Applied log-prod0.7
Final simplification0.4
herbie shell --seed 2019294
(FPCore (x)
:name "ln(1 + x)"
:precision binary64
:herbie-target
(if (== (+ 1 x) 1) x (/ (* x (log (+ 1 x))) (- (+ 1 x) 1)))
(log (+ 1 x)))