\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x \le 6.37915373787209162315678737109614360179 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{-1}{2}}{1} \cdot \frac{x \cdot x}{1} + \left(1 \cdot x + \log 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \log \left(x + 1\right) + \log \left(\sqrt{x + 1}\right)\\
\end{array}double f(double x) {
double r54948 = 1.0;
double r54949 = x;
double r54950 = r54948 + r54949;
double r54951 = log(r54950);
return r54951;
}
double f(double x) {
double r54952 = x;
double r54953 = 6.379153737872092e-06;
bool r54954 = r54952 <= r54953;
double r54955 = -0.5;
double r54956 = 1.0;
double r54957 = r54955 / r54956;
double r54958 = r54952 * r54952;
double r54959 = r54958 / r54956;
double r54960 = r54957 * r54959;
double r54961 = r54956 * r54952;
double r54962 = log(r54956);
double r54963 = r54961 + r54962;
double r54964 = r54960 + r54963;
double r54965 = 0.5;
double r54966 = r54952 + r54956;
double r54967 = log(r54966);
double r54968 = r54965 * r54967;
double r54969 = sqrt(r54966);
double r54970 = log(r54969);
double r54971 = r54968 + r54970;
double r54972 = r54954 ? r54964 : r54971;
return r54972;
}




Bits error versus x
Results
| Original | 39.3 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if x < 6.379153737872092e-06Initial program 59.0
Simplified59.0
Taylor expanded around 0 0.4
Simplified0.4
if 6.379153737872092e-06 < x Initial program 0.1
Simplified0.1
rmApplied add-sqr-sqrt0.1
Applied log-prod0.1
Simplified0.1
Simplified0.1
rmApplied pow1/20.1
Applied log-pow0.1
Simplified0.1
Final simplification0.3
herbie shell --seed 2019195
(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)))