?

Average Error: 63.0 → 0.0
Time: 4.7s
Precision: binary64
Cost: 6912

?

\[n > 6.8 \cdot 10^{+15}\]
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1 \]
\[\left(1 + \left(-\log \left(\frac{1}{n}\right)\right)\right) - 1 \]
(FPCore (n)
 :precision binary64
 (- (- (* (+ n 1.0) (log (+ n 1.0))) (* n (log n))) 1.0))
(FPCore (n) :precision binary64 (- (+ 1.0 (- (log (/ 1.0 n)))) 1.0))
double code(double n) {
	return (((n + 1.0) * log((n + 1.0))) - (n * log(n))) - 1.0;
}
double code(double n) {
	return (1.0 + -log((1.0 / n))) - 1.0;
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = (((n + 1.0d0) * log((n + 1.0d0))) - (n * log(n))) - 1.0d0
end function
real(8) function code(n)
    real(8), intent (in) :: n
    code = (1.0d0 + -log((1.0d0 / n))) - 1.0d0
end function
public static double code(double n) {
	return (((n + 1.0) * Math.log((n + 1.0))) - (n * Math.log(n))) - 1.0;
}
public static double code(double n) {
	return (1.0 + -Math.log((1.0 / n))) - 1.0;
}
def code(n):
	return (((n + 1.0) * math.log((n + 1.0))) - (n * math.log(n))) - 1.0
def code(n):
	return (1.0 + -math.log((1.0 / n))) - 1.0
function code(n)
	return Float64(Float64(Float64(Float64(n + 1.0) * log(Float64(n + 1.0))) - Float64(n * log(n))) - 1.0)
end
function code(n)
	return Float64(Float64(1.0 + Float64(-log(Float64(1.0 / n)))) - 1.0)
end
function tmp = code(n)
	tmp = (((n + 1.0) * log((n + 1.0))) - (n * log(n))) - 1.0;
end
function tmp = code(n)
	tmp = (1.0 + -log((1.0 / n))) - 1.0;
end
code[n_] := N[(N[(N[(N[(n + 1.0), $MachinePrecision] * N[Log[N[(n + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(n * N[Log[n], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[n_] := N[(N[(1.0 + (-N[Log[N[(1.0 / n), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] - 1.0), $MachinePrecision]
\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1
\left(1 + \left(-\log \left(\frac{1}{n}\right)\right)\right) - 1

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original63.0
Target0
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. Taylor expanded in n around inf 0.0

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

    \[\leadsto \color{blue}{\left(1 + \left(-\log \left(\frac{1}{n}\right)\right)\right)} - 1 \]
    Proof

    [Start]0.0

    \[ \left(1 + -1 \cdot \log \left(\frac{1}{n}\right)\right) - 1 \]

    rational_best-simplify-2 [=>]0.0

    \[ \left(1 + \color{blue}{\log \left(\frac{1}{n}\right) \cdot -1}\right) - 1 \]

    rational_best-simplify-12 [=>]0.0

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

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

Alternatives

Alternative 1
Error63.3
Cost6848
\[n \cdot \left(1 - \log n\right) - 1 \]

Error

Reproduce?

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