\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\frac{\frac{1}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}{\frac{1}{\log 1 - \mathsf{fma}\left(1, x, \frac{\frac{1}{2}}{\frac{1}{x} \cdot \frac{1}{x}}\right)}}double f(double x) {
double r3921186 = 1.0;
double r3921187 = x;
double r3921188 = r3921186 - r3921187;
double r3921189 = log(r3921188);
double r3921190 = r3921186 + r3921187;
double r3921191 = log(r3921190);
double r3921192 = r3921189 / r3921191;
return r3921192;
}
double f(double x) {
double r3921193 = 1.0;
double r3921194 = x;
double r3921195 = 1.0;
double r3921196 = r3921194 / r3921195;
double r3921197 = r3921196 * r3921196;
double r3921198 = -0.5;
double r3921199 = log(r3921195);
double r3921200 = fma(r3921195, r3921194, r3921199);
double r3921201 = fma(r3921197, r3921198, r3921200);
double r3921202 = r3921193 / r3921201;
double r3921203 = 0.5;
double r3921204 = r3921195 / r3921194;
double r3921205 = r3921204 * r3921204;
double r3921206 = r3921203 / r3921205;
double r3921207 = fma(r3921195, r3921194, r3921206);
double r3921208 = r3921199 - r3921207;
double r3921209 = r3921193 / r3921208;
double r3921210 = r3921202 / r3921209;
return r3921210;
}




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