\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1.000000000000000222044604925031308084726:\\
\;\;\;\;1 \cdot x + \left(\log 1 - \frac{x}{1} \cdot \left(\frac{1}{2} \cdot \frac{x}{1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + 1\right)\\
\end{array}double f(double x) {
double r3054010 = 1.0;
double r3054011 = x;
double r3054012 = r3054010 + r3054011;
double r3054013 = log(r3054012);
return r3054013;
}
double f(double x) {
double r3054014 = x;
double r3054015 = 1.0;
double r3054016 = r3054014 + r3054015;
double r3054017 = 1.0000000000000002;
bool r3054018 = r3054016 <= r3054017;
double r3054019 = r3054015 * r3054014;
double r3054020 = log(r3054015);
double r3054021 = r3054014 / r3054015;
double r3054022 = 0.5;
double r3054023 = r3054022 * r3054021;
double r3054024 = r3054021 * r3054023;
double r3054025 = r3054020 - r3054024;
double r3054026 = r3054019 + r3054025;
double r3054027 = log(r3054016);
double r3054028 = r3054018 ? r3054026 : r3054027;
return r3054028;
}




Bits error versus x
Results
| Original | 39.3 |
|---|---|
| Target | 0.3 |
| Herbie | 0.6 |
if (+ 1.0 x) < 1.0000000000000002Initial program 59.5
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000000000000002 < (+ 1.0 x) Initial program 1.2
Final simplification0.6
herbie shell --seed 2019192
(FPCore (x)
:name "ln(1 + x)"
:herbie-target
(if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0)))
(log (+ 1.0 x)))