?

Average Error: 63.0 → 0
Time: 45.0s
Precision: binary64
Cost: 6720

?

\[n > 6.8 \cdot 10^{+15}\]
\[\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1 \]
\[0 + \log \left(1 + n\right) \]
(FPCore (n)
 :precision binary64
 (- (- (* (+ n 1.0) (log (+ n 1.0))) (* n (log n))) 1.0))
(FPCore (n) :precision binary64 (+ 0.0 (log (+ 1.0 n))))
double code(double n) {
	return (((n + 1.0) * log((n + 1.0))) - (n * log(n))) - 1.0;
}
double code(double n) {
	return 0.0 + log((1.0 + n));
}
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 = 0.0d0 + log((1.0d0 + n))
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 0.0 + Math.log((1.0 + n));
}
def code(n):
	return (((n + 1.0) * math.log((n + 1.0))) - (n * math.log(n))) - 1.0
def code(n):
	return 0.0 + math.log((1.0 + n))
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(0.0 + log(Float64(1.0 + n)))
end
function tmp = code(n)
	tmp = (((n + 1.0) * log((n + 1.0))) - (n * log(n))) - 1.0;
end
function tmp = code(n)
	tmp = 0.0 + log((1.0 + n));
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[(0.0 + N[Log[N[(1.0 + n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\left(\left(n + 1\right) \cdot \log \left(n + 1\right) - n \cdot \log n\right) - 1
0 + \log \left(1 + n\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original63.0
Target0
Herbie0
\[\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. Simplified62.0

    \[\leadsto \color{blue}{\left(n + 1\right) \cdot \mathsf{log1p}\left(n\right) - \mathsf{fma}\left(n, \log n, 1\right)} \]
    Proof
  3. Applied egg-rr0.8

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

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

    \[\leadsto \color{blue}{0} + \mathsf{log1p}\left(n\right) \]
    Proof
  6. Applied egg-rr0

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

Alternatives

Alternative 1
Error0.0
Cost6592
\[0 + \mathsf{log1p}\left(n\right) \]
Alternative 2
Error60.7
Cost192
\[n - 1 \]
Alternative 3
Error63.0
Cost64
\[-1 \]

Error

Reproduce?

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