\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\frac{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}{\frac{1}{\log 1 - \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{1}{2}, x \cdot 1\right)}}double f(double x) {
double r4158527 = 1.0;
double r4158528 = x;
double r4158529 = r4158527 - r4158528;
double r4158530 = log(r4158529);
double r4158531 = r4158527 + r4158528;
double r4158532 = log(r4158531);
double r4158533 = r4158530 / r4158532;
return r4158533;
}
double f(double x) {
double r4158534 = 1.0;
double r4158535 = -0.5;
double r4158536 = x;
double r4158537 = 1.0;
double r4158538 = r4158536 / r4158537;
double r4158539 = r4158538 * r4158538;
double r4158540 = log(r4158537);
double r4158541 = fma(r4158537, r4158536, r4158540);
double r4158542 = fma(r4158535, r4158539, r4158541);
double r4158543 = r4158534 / r4158542;
double r4158544 = 0.5;
double r4158545 = r4158536 * r4158537;
double r4158546 = fma(r4158539, r4158544, r4158545);
double r4158547 = r4158540 - r4158546;
double r4158548 = r4158534 / r4158547;
double r4158549 = r4158543 / r4158548;
return r4158549;
}




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 clear-num0.4
rmApplied div-inv0.6
Applied associate-/r*0.4
Final simplification0.4
herbie shell --seed 2019171 +o rules:numerics
(FPCore (x)
:name "qlog (example 3.10)"
:pre (and (< -1.0 x) (< x 1.0))
:herbie-target
(- (+ (+ (+ 1.0 x) (/ (* x x) 2.0)) (* 0.4166666666666667 (pow x 3.0))))
(/ (log (- 1.0 x)) (log (+ 1.0 x))))