\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1
\log \left(n \cdot e^{\frac{0.5}{n} + \frac{-0.16666666666666666}{n \cdot n}}\right)(FPCore (n) :precision binary64 (- (- (* (+ n 1.0) (log (+ n 1.0))) (* n (log n))) 1.0))
(FPCore (n) :precision binary64 (log (* n (exp (+ (/ 0.5 n) (/ -0.16666666666666666 (* n n)))))))
double code(double n) {
return (((n + 1.0) * log(n + 1.0)) - (n * log(n))) - 1.0;
}
double code(double n) {
return log(n * exp((0.5 / n) + (-0.16666666666666666 / (n * n))));
}




Bits error versus n
Results
| Original | 63.0 |
|---|---|
| Target | 0 |
| Herbie | 0 |
Initial program 63.0
Taylor expanded around inf 0.0
Simplified0.0
rmApplied add-log-exp_binary64_4580.0
Applied add-log-exp_binary64_4580.0
Applied diff-log_binary64_5110.0
Applied add-log-exp_binary64_4580.0
Applied add-log-exp_binary64_4580.0
Applied sum-log_binary64_5100.0
Applied diff-log_binary64_5110.1
Applied diff-log_binary64_5110.1
Simplified0
Final simplification0
herbie shell --seed 2020355
(FPCore (n)
:name "logs (example 3.8)"
:precision binary64
:pre (> n 6.8e+15)
:herbie-target
(- (log (+ n 1.0)) (- (/ 1.0 (* 2.0 n)) (- (/ 1.0 (* 3.0 (* n n))) (/ 4.0 (pow n 3.0)))))
(- (- (* (+ n 1.0) (log (+ n 1.0))) (* n (log n))) 1.0))