?

Average Error: 54.8% → 100.0%
Time: 10.7s
Precision: binary64
Cost: 6592.00

?

\[\log \left(N + 1\right) - \log N \]
\[\mathsf{log1p}\left(\frac{1}{N}\right) \]
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
(FPCore (N) :precision binary64 (log1p (/ 1.0 N)))
double code(double N) {
	return log((N + 1.0)) - log(N);
}
double code(double N) {
	return log1p((1.0 / N));
}
public static double code(double N) {
	return Math.log((N + 1.0)) - Math.log(N);
}
public static double code(double N) {
	return Math.log1p((1.0 / N));
}
def code(N):
	return math.log((N + 1.0)) - math.log(N)
def code(N):
	return math.log1p((1.0 / N))
function code(N)
	return Float64(log(Float64(N + 1.0)) - log(N))
end
function code(N)
	return log1p(Float64(1.0 / N))
end
code[N_] := N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]
code[N_] := N[Log[1 + N[(1.0 / N), $MachinePrecision]], $MachinePrecision]
\log \left(N + 1\right) - \log N
\mathsf{log1p}\left(\frac{1}{N}\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 54.8

    \[\log \left(N + 1\right) - \log N \]
  2. Simplified54.8

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    Proof

    [Start]54.8

    \[ \log \left(N + 1\right) - \log N \]

    +-commutative [=>]54.8

    \[ \log \color{blue}{\left(1 + N\right)} - \log N \]

    log1p-def [=>]54.8

    \[ \color{blue}{\mathsf{log1p}\left(N\right)} - \log N \]
  3. Applied egg-rr54.9

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{N + 1}{N} - 1\right)} \]
  4. Taylor expanded in N around 0 100.0

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\frac{1}{N}}\right) \]
  5. Final simplification100.0

    \[\leadsto \mathsf{log1p}\left(\frac{1}{N}\right) \]

Alternatives

Alternative 1
Error98.5%
Cost6660.00
\[\begin{array}{l} \mathbf{if}\;N \leq 0.7:\\ \;\;\;\;-\log N\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{N} \cdot \left(1 + \frac{-0.5}{N}\right)\\ \end{array} \]
Alternative 2
Error51.0%
Cost192.00
\[\frac{1}{N} \]
Alternative 3
Error4.6%
Cost64.00
\[N \]

Error

Reproduce?

herbie shell --seed 2023093 
(FPCore (N)
  :name "2log (problem 3.3.6)"
  :precision binary64
  (- (log (+ N 1.0)) (log N)))