\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000014320063078:\\
\;\;\;\;\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r75338 = 1.0;
double r75339 = x;
double r75340 = r75338 + r75339;
double r75341 = log(r75340);
return r75341;
}
double f(double x) {
double r75342 = 1.0;
double r75343 = x;
double r75344 = r75342 + r75343;
double r75345 = 1.0000014320063078;
bool r75346 = r75344 <= r75345;
double r75347 = log(r75342);
double r75348 = 0.5;
double r75349 = 2.0;
double r75350 = pow(r75343, r75349);
double r75351 = pow(r75342, r75349);
double r75352 = r75350 / r75351;
double r75353 = r75348 * r75352;
double r75354 = r75347 - r75353;
double r75355 = fma(r75343, r75342, r75354);
double r75356 = log(r75344);
double r75357 = r75346 ? r75355 : r75356;
return r75357;
}




Bits error versus x
| Original | 38.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if (+ 1.0 x) < 1.0000014320063078Initial program 59.2
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000014320063078 < (+ 1.0 x) Initial program 0.1
Final simplification0.2
herbie shell --seed 2020018 +o rules:numerics
(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)))