\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1.000000000007547740210611664224416017532:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{2} \cdot \frac{x}{1}, \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + 1\right)\\
\end{array}double f(double x) {
double r3341976 = 1.0;
double r3341977 = x;
double r3341978 = r3341976 + r3341977;
double r3341979 = log(r3341978);
return r3341979;
}
double f(double x) {
double r3341980 = x;
double r3341981 = 1.0;
double r3341982 = r3341980 + r3341981;
double r3341983 = 1.0000000000075477;
bool r3341984 = r3341982 <= r3341983;
double r3341985 = -0.5;
double r3341986 = r3341980 / r3341981;
double r3341987 = r3341985 * r3341986;
double r3341988 = log(r3341981);
double r3341989 = fma(r3341981, r3341980, r3341988);
double r3341990 = fma(r3341987, r3341986, r3341989);
double r3341991 = log(r3341982);
double r3341992 = r3341984 ? r3341990 : r3341991;
return r3341992;
}




Bits error versus x
| Original | 39.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
if (+ 1.0 x) < 1.0000000000075477Initial program 59.4
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000000000075477 < (+ 1.0 x) Initial program 0.5
Final simplification0.4
herbie shell --seed 2019179 +o rules:numerics
(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)))