Average Error: 29.2 → 0.0
Time: 51.2s
Precision: binary64
Cost: 14337
\[\log \left(N + 1\right) - \log N\]
\[\begin{array}{l} \mathbf{if}\;N \leq 1511.9843372896694:\\ \;\;\;\;\log \left(\frac{N + 1}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot {N}^{-3} + \left(\frac{1}{N} - \left(\frac{0.5}{N \cdot N} + \frac{0.25}{{N}^{4}}\right)\right)\\ \end{array}\]
\log \left(N + 1\right) - \log N
\begin{array}{l}
\mathbf{if}\;N \leq 1511.9843372896694:\\
\;\;\;\;\log \left(\frac{N + 1}{N}\right)\\

\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot {N}^{-3} + \left(\frac{1}{N} - \left(\frac{0.5}{N \cdot N} + \frac{0.25}{{N}^{4}}\right)\right)\\

\end{array}
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
(FPCore (N)
 :precision binary64
 (if (<= N 1511.9843372896694)
   (log (/ (+ N 1.0) N))
   (+
    (* 0.3333333333333333 (pow N -3.0))
    (- (/ 1.0 N) (+ (/ 0.5 (* N N)) (/ 0.25 (pow N 4.0)))))))
double code(double N) {
	return log(N + 1.0) - log(N);
}
double code(double N) {
	double tmp;
	if (N <= 1511.9843372896694) {
		tmp = log((N + 1.0) / N);
	} else {
		tmp = (0.3333333333333333 * pow(N, -3.0)) + ((1.0 / N) - ((0.5 / (N * N)) + (0.25 / pow(N, 4.0))));
	}
	return tmp;
}

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error0.0
Cost7617
\[\begin{array}{l} \mathbf{if}\;N \leq 8944.961044310863:\\ \;\;\;\;\log \left(\frac{N + 1}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot {N}^{-3} + \left(\frac{1}{N} + \frac{-0.5}{N \cdot N}\right)\\ \end{array}\]
Alternative 2
Error0.1
Cost7041
\[\begin{array}{l} \mathbf{if}\;N \leq 204410.2502577827:\\ \;\;\;\;\log \left(\frac{N + 1}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{N} + \frac{-0.5}{N \cdot N}\\ \end{array}\]
Alternative 3
Error0.6
Cost6913
\[\begin{array}{l} \mathbf{if}\;N \leq 0.902128626469268:\\ \;\;\;\;N - \log N\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{N} + \frac{-0.5}{N \cdot N}\\ \end{array}\]
Alternative 4
Error0.9
Cost6849
\[\begin{array}{l} \mathbf{if}\;N \leq 0.6844505345468515:\\ \;\;\;\;-\log N\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{N} + \frac{-0.5}{N \cdot N}\\ \end{array}\]
Alternative 5
Error28.0
Cost897
\[\begin{array}{l} \mathbf{if}\;N \leq 0.902128626469268:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{N} + \frac{-0.5}{N \cdot N}\\ \end{array}\]
Alternative 6
Error28.3
Cost513
\[\begin{array}{l} \mathbf{if}\;N \leq 0.9891998632382345:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{N}\\ \end{array}\]
Alternative 7
Error57.7
Cost64
\[1\]
Alternative 8
Error61.3
Cost64
\[0\]

Error

Derivation

  1. Split input into 2 regimes
  2. if N < 1511.9843372896694

    1. Initial program 0.1

      \[\log \left(N + 1\right) - \log N\]
    2. Using strategy rm
    3. Applied diff-log_binary64_1700.0

      \[\leadsto \color{blue}{\log \left(\frac{N + 1}{N}\right)}\]
    4. Using strategy rm
    5. Applied pow1_binary64_1390.0

      \[\leadsto \log \color{blue}{\left({\left(\frac{N + 1}{N}\right)}^{1}\right)}\]
    6. Applied log-pow_binary64_1670.0

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

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

    if 1511.9843372896694 < N

    1. Initial program 59.3

      \[\log \left(N + 1\right) - \log N\]
    2. Using strategy rm
    3. Applied diff-log_binary64_17059.1

      \[\leadsto \color{blue}{\log \left(\frac{N + 1}{N}\right)}\]
    4. Using strategy rm
    5. Applied add-exp-log_binary64_11660.3

      \[\leadsto \log \left(\frac{N + 1}{\color{blue}{e^{\log N}}}\right)\]
    6. Applied add-exp-log_binary64_11659.3

      \[\leadsto \log \left(\frac{\color{blue}{e^{\log \left(N + 1\right)}}}{e^{\log N}}\right)\]
    7. Applied div-exp_binary64_12959.3

      \[\leadsto \log \color{blue}{\left(e^{\log \left(N + 1\right) - \log N}\right)}\]
    8. Simplified59.1

      \[\leadsto \log \left(e^{\color{blue}{\log \left(\frac{N + 1}{N}\right)}}\right)\]
    9. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot \frac{1}{{N}^{3}} + \frac{1}{N}\right) - \left(0.5 \cdot \frac{1}{{N}^{2}} + 0.25 \cdot \frac{1}{{N}^{4}}\right)}\]
    10. Simplified0.0

      \[\leadsto \color{blue}{0.3333333333333333 \cdot {N}^{-3} + \left(\frac{1}{N} - \left(\frac{0.5}{N \cdot N} + \frac{0.25}{{N}^{4}}\right)\right)}\]
    11. Simplified0.0

      \[\leadsto \color{blue}{0.3333333333333333 \cdot {N}^{-3} + \left(\frac{1}{N} - \left(\frac{0.5}{N \cdot N} + \frac{0.25}{{N}^{4}}\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;N \leq 1511.9843372896694:\\ \;\;\;\;\log \left(\frac{N + 1}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot {N}^{-3} + \left(\frac{1}{N} - \left(\frac{0.5}{N \cdot N} + \frac{0.25}{{N}^{4}}\right)\right)\\ \end{array}\]

Reproduce

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