\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \leq 1.0000001392773128:\\
\;\;\;\;1 \cdot x + \left(\log 1 + \left(x \cdot x\right) \cdot \frac{-0.5}{1 \cdot 1}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double code(double x) {
return ((double) log(((double) (1.0 + x))));
}
double code(double x) {
double VAR;
if ((((double) (1.0 + x)) <= 1.0000001392773128)) {
VAR = ((double) (((double) (1.0 * x)) + ((double) (((double) log(1.0)) + ((double) (((double) (x * x)) * (-0.5 / ((double) (1.0 * 1.0)))))))));
} else {
VAR = ((double) log(((double) (1.0 + x))));
}
return VAR;
}




Bits error versus x
Results
| Original | 39.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000001392773128Initial program 59.1
Taylor expanded around 0 0.4
Simplified0.4
if 1.0000001392773128 < (+ 1.0 x) Initial program 0.2
Final simplification0.3
herbie shell --seed 2020196
(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)))