\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000152443675460744998417794704437256:\\
\;\;\;\;\mathsf{fma}\left(\frac{{x}^{2}}{{1}^{2}}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r80857 = 1.0;
double r80858 = x;
double r80859 = r80857 + r80858;
double r80860 = log(r80859);
return r80860;
}
double f(double x) {
double r80861 = 1.0;
double r80862 = x;
double r80863 = r80861 + r80862;
double r80864 = 1.0000001524436755;
bool r80865 = r80863 <= r80864;
double r80866 = 2.0;
double r80867 = pow(r80862, r80866);
double r80868 = pow(r80861, r80866);
double r80869 = r80867 / r80868;
double r80870 = -0.5;
double r80871 = log(r80861);
double r80872 = fma(r80861, r80862, r80871);
double r80873 = fma(r80869, r80870, r80872);
double r80874 = sqrt(r80863);
double r80875 = log(r80874);
double r80876 = r80875 + r80875;
double r80877 = r80865 ? r80873 : r80876;
return r80877;
}




Bits error versus x
| Original | 39.6 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000001524436755Initial program 59.1
rmApplied add-cbrt-cube59.1
Simplified59.1
Taylor expanded around 0 0.4
Simplified0.4
if 1.0000001524436755 < (+ 1.0 x) Initial program 0.2
rmApplied add-sqr-sqrt0.2
Applied log-prod0.2
Final simplification0.3
herbie shell --seed 2019303 +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)))