Average Error: 63.0 → 0.0
Time: 4.8s
Precision: binary64
\[n > 6.8 \cdot 10^{+15}\]
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1 \]
\[\left(\log n + 1\right) + -1 \]
\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1
\left(\log n + 1\right) + -1
(FPCore (n)
 :precision binary64
 (- (- (* (+ n 1.0) (log (+ n 1.0))) (* n (log n))) 1.0))
(FPCore (n) :precision binary64 (+ (+ (log n) 1.0) -1.0))
double code(double n) {
	return (((n + 1.0) * log(n + 1.0)) - (n * log(n))) - 1.0;
}
double code(double n) {
	return (log(n) + 1.0) + -1.0;
}

Error

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original63.0
Target0.0
Herbie0.0
\[\log \left(n + 1\right) - \left(\frac{1}{2 \cdot n} - \left(\frac{1}{3 \cdot \left(n \cdot n\right)} - \frac{4}{{n}^{3}}\right)\right) \]

Derivation

  1. Initial program 63.0

    \[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1 \]
  2. Simplified44.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(n, \mathsf{log1p}\left(n\right) - \log n, \mathsf{log1p}\left(n\right)\right) + -1} \]
  3. Taylor expanded in n around inf 0.0

    \[\leadsto \color{blue}{\left(1 - \log \left(\frac{1}{n}\right)\right)} + -1 \]
  4. Simplified0.0

    \[\leadsto \color{blue}{\left(\log n + 1\right)} + -1 \]
  5. Final simplification0.0

    \[\leadsto \left(\log n + 1\right) + -1 \]

Reproduce

herbie shell --seed 2022097 
(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))