\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.00000022789517229:\\
\;\;\;\;\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r66666 = 1.0;
double r66667 = x;
double r66668 = r66666 + r66667;
double r66669 = log(r66668);
return r66669;
}
double f(double x) {
double r66670 = 1.0;
double r66671 = x;
double r66672 = r66670 + r66671;
double r66673 = 1.0000002278951723;
bool r66674 = r66672 <= r66673;
double r66675 = r66670 * r66671;
double r66676 = log(r66670);
double r66677 = r66675 + r66676;
double r66678 = 0.5;
double r66679 = 2.0;
double r66680 = pow(r66671, r66679);
double r66681 = pow(r66670, r66679);
double r66682 = r66680 / r66681;
double r66683 = r66678 * r66682;
double r66684 = r66677 - r66683;
double r66685 = log(r66672);
double r66686 = r66674 ? r66684 : r66685;
return r66686;
}




Bits error versus x
Results
| Original | 39.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
if (+ 1.0 x) < 1.0000002278951723Initial program 59.0
Taylor expanded around 0 0.4
if 1.0000002278951723 < (+ 1.0 x) Initial program 0.2
rmApplied add-exp-log1.3
rmApplied rem-exp-log0.2
Final simplification0.4
herbie shell --seed 2020021
(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)))