\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\right)\right)double f(double x) {
double r68676 = 1.0;
double r68677 = x;
double r68678 = r68676 - r68677;
double r68679 = log(r68678);
double r68680 = r68676 + r68677;
double r68681 = log(r68680);
double r68682 = r68679 / r68681;
return r68682;
}
double f(double x) {
double r68683 = 1.0;
double r68684 = log(r68683);
double r68685 = x;
double r68686 = 0.5;
double r68687 = 2.0;
double r68688 = pow(r68685, r68687);
double r68689 = pow(r68683, r68687);
double r68690 = r68688 / r68689;
double r68691 = r68686 * r68690;
double r68692 = fma(r68683, r68685, r68691);
double r68693 = r68684 - r68692;
double r68694 = -0.5;
double r68695 = fma(r68683, r68685, r68684);
double r68696 = fma(r68694, r68690, r68695);
double r68697 = r68693 / r68696;
double r68698 = expm1(r68697);
double r68699 = log1p(r68698);
return r68699;
}




Bits error versus x
| Original | 61.4 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
Initial program 61.4
Taylor expanded around 0 60.5
Simplified60.5
Taylor expanded around 0 0.4
Simplified0.4
rmApplied log1p-expm1-u0.4
Final simplification0.4
herbie shell --seed 2019325 +o rules:numerics
(FPCore (x)
:name "qlog (example 3.10)"
:precision binary64
:pre (and (< -1 x) (< x 1))
:herbie-target
(- (+ (+ (+ 1 x) (/ (* x x) 2)) (* 0.4166666666666667 (pow x 3))))
(/ (log (- 1 x)) (log (+ 1 x))))