\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1.000000010117869209125274210236966609955:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + 1\right)\\
\end{array}double f(double x) {
double r3655838 = 1.0;
double r3655839 = x;
double r3655840 = r3655838 + r3655839;
double r3655841 = log(r3655840);
return r3655841;
}
double f(double x) {
double r3655842 = x;
double r3655843 = 1.0;
double r3655844 = r3655842 + r3655843;
double r3655845 = 1.0000000101178692;
bool r3655846 = r3655844 <= r3655845;
double r3655847 = r3655842 / r3655843;
double r3655848 = r3655847 * r3655847;
double r3655849 = -0.5;
double r3655850 = log(r3655843);
double r3655851 = fma(r3655843, r3655842, r3655850);
double r3655852 = fma(r3655848, r3655849, r3655851);
double r3655853 = log(r3655844);
double r3655854 = r3655846 ? r3655852 : r3655853;
return r3655854;
}




Bits error versus x
| Original | 39.1 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000000101178692Initial program 59.2
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000000101178692 < (+ 1.0 x) Initial program 0.3
Final simplification0.3
herbie shell --seed 2019169 +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)))