\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000000447056:\\
\;\;\;\;\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 r87240 = 1.0;
double r87241 = x;
double r87242 = r87240 + r87241;
double r87243 = log(r87242);
return r87243;
}
double f(double x) {
double r87244 = 1.0;
double r87245 = x;
double r87246 = r87244 + r87245;
double r87247 = 1.0000000000447056;
bool r87248 = r87246 <= r87247;
double r87249 = log(r87244);
double r87250 = 0.5;
double r87251 = 2.0;
double r87252 = pow(r87245, r87251);
double r87253 = pow(r87244, r87251);
double r87254 = r87252 / r87253;
double r87255 = r87250 * r87254;
double r87256 = r87249 - r87255;
double r87257 = fma(r87245, r87244, r87256);
double r87258 = log(r87246);
double r87259 = r87248 ? r87257 : r87258;
return r87259;
}




Bits error versus x
| Original | 39.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000000000447056Initial program 59.5
Taylor expanded around 0 0.2
Simplified0.2
if 1.0000000000447056 < (+ 1.0 x) Initial program 0.5
Final simplification0.3
herbie shell --seed 2020035 +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)))