\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \leq 1.000000000077242:\\
\;\;\;\;x - 0.5 \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}(FPCore (x) :precision binary64 (log (+ 1.0 x)))
(FPCore (x) :precision binary64 (if (<= (+ 1.0 x) 1.000000000077242) (- x (* 0.5 (pow x 2.0))) (log (+ 1.0 x))))
double code(double x) {
return log(1.0 + x);
}
double code(double x) {
double tmp;
if ((1.0 + x) <= 1.000000000077242) {
tmp = x - (0.5 * pow(x, 2.0));
} else {
tmp = log(1.0 + x);
}
return tmp;
}




Bits error versus x
Results
| Original | 38.9 |
|---|---|
| Target | 0.2 |
| Herbie | 0.4 |
if (+.f64 1 x) < 1.00000000007724199Initial program 59.3
Taylor expanded around 0 0.3
if 1.00000000007724199 < (+.f64 1 x) Initial program 0.4
Final simplification0.4
herbie shell --seed 2021020
(FPCore (x)
:name "ln(1 + x)"
:precision binary64
:herbie-target
(if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0)))
(log (+ 1.0 x)))