\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000771282975:\\
\;\;\;\;\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 r56748 = 1.0;
double r56749 = x;
double r56750 = r56748 + r56749;
double r56751 = log(r56750);
return r56751;
}
double f(double x) {
double r56752 = 1.0;
double r56753 = x;
double r56754 = r56752 + r56753;
double r56755 = 1.0000000771282975;
bool r56756 = r56754 <= r56755;
double r56757 = r56752 * r56753;
double r56758 = log(r56752);
double r56759 = r56757 + r56758;
double r56760 = 0.5;
double r56761 = 2.0;
double r56762 = pow(r56753, r56761);
double r56763 = pow(r56752, r56761);
double r56764 = r56762 / r56763;
double r56765 = r56760 * r56764;
double r56766 = r56759 - r56765;
double r56767 = sqrt(r56754);
double r56768 = log(r56767);
double r56769 = r56768 + r56768;
double r56770 = r56756 ? r56766 : r56769;
return r56770;
}




Bits error versus x
Results
| Original | 38.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000000771282975Initial program 59.2
Taylor expanded around 0 0.3
if 1.0000000771282975 < (+ 1.0 x) Initial program 0.2
rmApplied add-sqr-sqrt0.2
Applied log-prod0.2
Final simplification0.3
herbie shell --seed 2020060
(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)))