\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000000000810462807976364274509251118:\\
\;\;\;\;\mathsf{fma}\left(1, x, 0.3333333333333333148296162562473909929395 \cdot {x}^{3}\right) - 0.5 \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r73720 = 1.0;
double r73721 = x;
double r73722 = r73720 + r73721;
double r73723 = log(r73722);
return r73723;
}
double f(double x) {
double r73724 = 1.0;
double r73725 = x;
double r73726 = r73724 + r73725;
double r73727 = 1.0000000000008105;
bool r73728 = r73726 <= r73727;
double r73729 = 0.3333333333333333;
double r73730 = 3.0;
double r73731 = pow(r73725, r73730);
double r73732 = r73729 * r73731;
double r73733 = fma(r73724, r73725, r73732);
double r73734 = 0.5;
double r73735 = 2.0;
double r73736 = pow(r73725, r73735);
double r73737 = r73734 * r73736;
double r73738 = r73733 - r73737;
double r73739 = log(r73726);
double r73740 = r73728 ? r73738 : r73739;
return r73740;
}




Bits error versus x
| 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
Simplified0.2
Taylor expanded around 0 0.2
Simplified0.2
if 1.0000000000008105 < (+ 1.0 x) Initial program 0.7
Final simplification0.4
herbie shell --seed 2019209 +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)))