\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000000000810462807976364274509251118:\\
\;\;\;\;\left(0.3333333333333333148296162562473909929395 \cdot {x}^{3} + 1 \cdot x\right) - 0.5 \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r58501 = 1.0;
double r58502 = x;
double r58503 = r58501 + r58502;
double r58504 = log(r58503);
return r58504;
}
double f(double x) {
double r58505 = 1.0;
double r58506 = x;
double r58507 = r58505 + r58506;
double r58508 = 1.0000000000008105;
bool r58509 = r58507 <= r58508;
double r58510 = 0.3333333333333333;
double r58511 = 3.0;
double r58512 = pow(r58506, r58511);
double r58513 = r58510 * r58512;
double r58514 = r58505 * r58506;
double r58515 = r58513 + r58514;
double r58516 = 0.5;
double r58517 = 2.0;
double r58518 = pow(r58506, r58517);
double r58519 = r58516 * r58518;
double r58520 = r58515 - r58519;
double r58521 = log(r58507);
double r58522 = r58509 ? r58520 : r58521;
return r58522;
}




Bits error versus x
Results
| Original | 38.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.4 |
if (+ 1.0 x) < 1.0000000000008105Initial program 59.4
rmApplied flip-+59.4
Applied log-div59.4
Taylor expanded around 0 0.2
Taylor expanded around 0 0.2
if 1.0000000000008105 < (+ 1.0 x) Initial program 0.7
Final simplification0.4
herbie shell --seed 2019209
(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)))