\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 r44816 = 1.0;
double r44817 = x;
double r44818 = r44816 + r44817;
double r44819 = log(r44818);
return r44819;
}
double f(double x) {
double r44820 = 1.0;
double r44821 = x;
double r44822 = r44820 + r44821;
double r44823 = 1.0000001524436755;
bool r44824 = r44822 <= r44823;
double r44825 = 2.0;
double r44826 = pow(r44821, r44825);
double r44827 = pow(r44820, r44825);
double r44828 = r44826 / r44827;
double r44829 = -0.5;
double r44830 = log(r44820);
double r44831 = fma(r44820, r44821, r44830);
double r44832 = fma(r44828, r44829, r44831);
double r44833 = sqrt(r44822);
double r44834 = log(r44833);
double r44835 = r44834 + r44834;
double r44836 = r44824 ? r44832 : r44835;
return r44836;
}




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)))