2log (problem 3.3.6)

Percentage Accurate: 23.7% → 99.4%
Time: 32.0s
Alternatives: 20
Speedup: 68.3×

Specification

?
\[N > 1 \land N < 10^{+40}\]
\[\begin{array}{l} \\ \log \left(N + 1\right) - \log N \end{array} \]
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
double code(double N) {
	return log((N + 1.0)) - log(N);
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = log((n + 1.0d0)) - log(n)
end function
public static double code(double N) {
	return Math.log((N + 1.0)) - Math.log(N);
}
def code(N):
	return math.log((N + 1.0)) - math.log(N)
function code(N)
	return Float64(log(Float64(N + 1.0)) - log(N))
end
function tmp = code(N)
	tmp = log((N + 1.0)) - log(N);
end
code[N_] := N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\log \left(N + 1\right) - \log N
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 20 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 23.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \log \left(N + 1\right) - \log N \end{array} \]
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
double code(double N) {
	return log((N + 1.0)) - log(N);
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = log((n + 1.0d0)) - log(n)
end function
public static double code(double N) {
	return Math.log((N + 1.0)) - Math.log(N);
}
def code(N):
	return math.log((N + 1.0)) - math.log(N)
function code(N)
	return Float64(log(Float64(N + 1.0)) - log(N))
end
function tmp = code(N)
	tmp = log((N + 1.0)) - log(N);
end
code[N_] := N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\log \left(N + 1\right) - \log N
\end{array}

Alternative 1: 99.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := N \cdot \left(N \cdot N\right)\\ t_1 := N \cdot t\_0\\ t_2 := \left(N \cdot N\right) \cdot t\_1\\ \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \left(\log \left(\left(N \cdot N + \left(N \cdot N\right) \cdot \left(N \cdot \left(N + -1\right)\right)\right) \cdot \left(t\_2 + t\_2 \cdot \left(t\_2 - t\_0\right)\right)\right) - \log \left(N \cdot \left(\left(N \cdot N\right) \cdot t\_2\right) + t\_2 \cdot \left(\left(N \cdot N\right) \cdot \left(t\_1 \cdot t\_2\right)\right)\right)\right)}{\log \left(N \cdot \left(N + 1\right)\right)}\\ \end{array} \end{array} \]
(FPCore (N)
 :precision binary64
 (let* ((t_0 (* N (* N N))) (t_1 (* N t_0)) (t_2 (* (* N N) t_1)))
   (if (<= (- (log (+ N 1.0)) (log N)) 0.0006)
     (/
      1.0
      (/ N (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N))))
     (/
      (*
       (log (/ N (+ N 1.0)))
       (-
        (log
         (*
          (+ (* N N) (* (* N N) (* N (+ N -1.0))))
          (+ t_2 (* t_2 (- t_2 t_0)))))
        (log (+ (* N (* (* N N) t_2)) (* t_2 (* (* N N) (* t_1 t_2)))))))
      (log (* N (+ N 1.0)))))))
double code(double N) {
	double t_0 = N * (N * N);
	double t_1 = N * t_0;
	double t_2 = (N * N) * t_1;
	double tmp;
	if ((log((N + 1.0)) - log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = (log((N / (N + 1.0))) * (log((((N * N) + ((N * N) * (N * (N + -1.0)))) * (t_2 + (t_2 * (t_2 - t_0))))) - log(((N * ((N * N) * t_2)) + (t_2 * ((N * N) * (t_1 * t_2))))))) / log((N * (N + 1.0)));
	}
	return tmp;
}
real(8) function code(n)
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = n * (n * n)
    t_1 = n * t_0
    t_2 = (n * n) * t_1
    if ((log((n + 1.0d0)) - log(n)) <= 0.0006d0) then
        tmp = 1.0d0 / (n / (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)))
    else
        tmp = (log((n / (n + 1.0d0))) * (log((((n * n) + ((n * n) * (n * (n + (-1.0d0))))) * (t_2 + (t_2 * (t_2 - t_0))))) - log(((n * ((n * n) * t_2)) + (t_2 * ((n * n) * (t_1 * t_2))))))) / log((n * (n + 1.0d0)))
    end if
    code = tmp
end function
public static double code(double N) {
	double t_0 = N * (N * N);
	double t_1 = N * t_0;
	double t_2 = (N * N) * t_1;
	double tmp;
	if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = (Math.log((N / (N + 1.0))) * (Math.log((((N * N) + ((N * N) * (N * (N + -1.0)))) * (t_2 + (t_2 * (t_2 - t_0))))) - Math.log(((N * ((N * N) * t_2)) + (t_2 * ((N * N) * (t_1 * t_2))))))) / Math.log((N * (N + 1.0)));
	}
	return tmp;
}
def code(N):
	t_0 = N * (N * N)
	t_1 = N * t_0
	t_2 = (N * N) * t_1
	tmp = 0
	if (math.log((N + 1.0)) - math.log(N)) <= 0.0006:
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)))
	else:
		tmp = (math.log((N / (N + 1.0))) * (math.log((((N * N) + ((N * N) * (N * (N + -1.0)))) * (t_2 + (t_2 * (t_2 - t_0))))) - math.log(((N * ((N * N) * t_2)) + (t_2 * ((N * N) * (t_1 * t_2))))))) / math.log((N * (N + 1.0)))
	return tmp
function code(N)
	t_0 = Float64(N * Float64(N * N))
	t_1 = Float64(N * t_0)
	t_2 = Float64(Float64(N * N) * t_1)
	tmp = 0.0
	if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0006)
		tmp = Float64(1.0 / Float64(N / Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N))));
	else
		tmp = Float64(Float64(log(Float64(N / Float64(N + 1.0))) * Float64(log(Float64(Float64(Float64(N * N) + Float64(Float64(N * N) * Float64(N * Float64(N + -1.0)))) * Float64(t_2 + Float64(t_2 * Float64(t_2 - t_0))))) - log(Float64(Float64(N * Float64(Float64(N * N) * t_2)) + Float64(t_2 * Float64(Float64(N * N) * Float64(t_1 * t_2))))))) / log(Float64(N * Float64(N + 1.0))));
	end
	return tmp
end
function tmp_2 = code(N)
	t_0 = N * (N * N);
	t_1 = N * t_0;
	t_2 = (N * N) * t_1;
	tmp = 0.0;
	if ((log((N + 1.0)) - log(N)) <= 0.0006)
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	else
		tmp = (log((N / (N + 1.0))) * (log((((N * N) + ((N * N) * (N * (N + -1.0)))) * (t_2 + (t_2 * (t_2 - t_0))))) - log(((N * ((N * N) * t_2)) + (t_2 * ((N * N) * (t_1 * t_2))))))) / log((N * (N + 1.0)));
	end
	tmp_2 = tmp;
end
code[N_] := Block[{t$95$0 = N[(N * N[(N * N), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N * N), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0006], N[(1.0 / N[(N / N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(N / N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Log[N[(N[(N[(N * N), $MachinePrecision] + N[(N[(N * N), $MachinePrecision] * N[(N * N[(N + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 + N[(t$95$2 * N[(t$95$2 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Log[N[(N[(N * N[(N[(N * N), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * N[(N[(N * N), $MachinePrecision] * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Log[N[(N * N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := N \cdot \left(N \cdot N\right)\\
t_1 := N \cdot t\_0\\
t_2 := \left(N \cdot N\right) \cdot t\_1\\
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\
\;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \left(\log \left(\left(N \cdot N + \left(N \cdot N\right) \cdot \left(N \cdot \left(N + -1\right)\right)\right) \cdot \left(t\_2 + t\_2 \cdot \left(t\_2 - t\_0\right)\right)\right) - \log \left(N \cdot \left(\left(N \cdot N\right) \cdot t\_2\right) + t\_2 \cdot \left(\left(N \cdot N\right) \cdot \left(t\_1 \cdot t\_2\right)\right)\right)\right)}{\log \left(N \cdot \left(N + 1\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.99999999999999947e-4

    1. Initial program 18.0%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6418.0%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified18.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Taylor expanded in N around inf

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
    7. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      9. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]

    if 5.99999999999999947e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N))

    1. Initial program 90.5%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6490.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified90.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N}{\color{blue}{\log \left(1 + N\right) + \log N}} \]
      2. frac-2negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(\log \left(1 + N\right) + \log N\right)\right)}} \]
      3. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right) \]
      4. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)\right), \left(\log \left(1 + N\right) + \log N\right)\right)\right) \]
    6. Applied egg-rr94.3%

      \[\leadsto \color{blue}{-\frac{\log \left(N \cdot \left(1 + N\right)\right) \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)}} \]
    7. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\left(N \cdot 1 + N \cdot N\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      2. flip3-+N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\left(\frac{{\left(N \cdot 1\right)}^{3} + {\left(N \cdot N\right)}^{3}}{\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)}\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left({\left(N \cdot 1\right)}^{3} + {\left(N \cdot N\right)}^{3}\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      4. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left({N}^{3} + {\left(N \cdot N\right)}^{3}\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left({N}^{3}\right), \left({\left(N \cdot N\right)}^{3}\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      6. cube-multN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(N \cdot \left(N \cdot N\right)\right), \left({\left(N \cdot N\right)}^{3}\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \left(N \cdot N\right)\right), \left({\left(N \cdot N\right)}^{3}\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \left({\left(N \cdot N\right)}^{3}\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      9. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\left(N \cdot N\right), 3\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      11. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \left(N \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      12. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\left(N \cdot N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      15. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      16. cube-multN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - {N}^{3}\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      17. --lowering--.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \mathsf{\_.f64}\left(\left(\left(N \cdot N\right) \cdot \left(N \cdot N\right)\right), \left({N}^{3}\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
    8. Applied egg-rr94.4%

      \[\leadsto -\frac{\log \color{blue}{\left(\frac{N \cdot \left(N \cdot N\right) + {\left(N \cdot N\right)}^{3}}{N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)}\right)} \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)} \]
    9. Applied egg-rr94.4%

      \[\leadsto -\frac{\color{blue}{\left(\log \left(N \cdot \left(\left(N \cdot N\right) \cdot \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right)\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right) \cdot \left(\left(N \cdot N\right) \cdot \left(\left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right)\right)\right) - \log \left(\left(N \cdot N + \left(N \cdot N\right) \cdot \left(N \cdot \left(N - 1\right)\right)\right) \cdot \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right) \cdot \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right)} \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \left(\log \left(\left(N \cdot N + \left(N \cdot N\right) \cdot \left(N \cdot \left(N + -1\right)\right)\right) \cdot \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right) \cdot \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right) - N \cdot \left(N \cdot N\right)\right)\right)\right) - \log \left(N \cdot \left(\left(N \cdot N\right) \cdot \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right)\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right) \cdot \left(\left(N \cdot N\right) \cdot \left(\left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right) \cdot \left(\left(N \cdot N\right) \cdot \left(N \cdot \left(N \cdot \left(N \cdot N\right)\right)\right)\right)\right)\right)\right)\right)}{\log \left(N \cdot \left(N + 1\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := N \cdot \left(N \cdot N\right)\\ \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \log \left(\frac{t\_0 \cdot \left(1 + t\_0\right)}{N \cdot N + \left(N \cdot N\right) \cdot \left(N \cdot \left(N + -1\right)\right)}\right)}{0 - \log \left(N \cdot \left(N + 1\right)\right)}\\ \end{array} \end{array} \]
(FPCore (N)
 :precision binary64
 (let* ((t_0 (* N (* N N))))
   (if (<= (- (log (+ N 1.0)) (log N)) 0.0006)
     (/
      1.0
      (/ N (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N))))
     (/
      (*
       (log (/ N (+ N 1.0)))
       (log (/ (* t_0 (+ 1.0 t_0)) (+ (* N N) (* (* N N) (* N (+ N -1.0)))))))
      (- 0.0 (log (* N (+ N 1.0))))))))
double code(double N) {
	double t_0 = N * (N * N);
	double tmp;
	if ((log((N + 1.0)) - log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = (log((N / (N + 1.0))) * log(((t_0 * (1.0 + t_0)) / ((N * N) + ((N * N) * (N * (N + -1.0))))))) / (0.0 - log((N * (N + 1.0))));
	}
	return tmp;
}
real(8) function code(n)
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = n * (n * n)
    if ((log((n + 1.0d0)) - log(n)) <= 0.0006d0) then
        tmp = 1.0d0 / (n / (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)))
    else
        tmp = (log((n / (n + 1.0d0))) * log(((t_0 * (1.0d0 + t_0)) / ((n * n) + ((n * n) * (n * (n + (-1.0d0)))))))) / (0.0d0 - log((n * (n + 1.0d0))))
    end if
    code = tmp
end function
public static double code(double N) {
	double t_0 = N * (N * N);
	double tmp;
	if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = (Math.log((N / (N + 1.0))) * Math.log(((t_0 * (1.0 + t_0)) / ((N * N) + ((N * N) * (N * (N + -1.0))))))) / (0.0 - Math.log((N * (N + 1.0))));
	}
	return tmp;
}
def code(N):
	t_0 = N * (N * N)
	tmp = 0
	if (math.log((N + 1.0)) - math.log(N)) <= 0.0006:
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)))
	else:
		tmp = (math.log((N / (N + 1.0))) * math.log(((t_0 * (1.0 + t_0)) / ((N * N) + ((N * N) * (N * (N + -1.0))))))) / (0.0 - math.log((N * (N + 1.0))))
	return tmp
function code(N)
	t_0 = Float64(N * Float64(N * N))
	tmp = 0.0
	if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0006)
		tmp = Float64(1.0 / Float64(N / Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N))));
	else
		tmp = Float64(Float64(log(Float64(N / Float64(N + 1.0))) * log(Float64(Float64(t_0 * Float64(1.0 + t_0)) / Float64(Float64(N * N) + Float64(Float64(N * N) * Float64(N * Float64(N + -1.0))))))) / Float64(0.0 - log(Float64(N * Float64(N + 1.0)))));
	end
	return tmp
end
function tmp_2 = code(N)
	t_0 = N * (N * N);
	tmp = 0.0;
	if ((log((N + 1.0)) - log(N)) <= 0.0006)
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	else
		tmp = (log((N / (N + 1.0))) * log(((t_0 * (1.0 + t_0)) / ((N * N) + ((N * N) * (N * (N + -1.0))))))) / (0.0 - log((N * (N + 1.0))));
	end
	tmp_2 = tmp;
end
code[N_] := Block[{t$95$0 = N[(N * N[(N * N), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0006], N[(1.0 / N[(N / N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(N / N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[(N[(t$95$0 * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(N * N), $MachinePrecision] + N[(N[(N * N), $MachinePrecision] * N[(N * N[(N + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(0.0 - N[Log[N[(N * N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := N \cdot \left(N \cdot N\right)\\
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\
\;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \log \left(\frac{t\_0 \cdot \left(1 + t\_0\right)}{N \cdot N + \left(N \cdot N\right) \cdot \left(N \cdot \left(N + -1\right)\right)}\right)}{0 - \log \left(N \cdot \left(N + 1\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.99999999999999947e-4

    1. Initial program 18.0%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6418.0%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified18.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Taylor expanded in N around inf

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
    7. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      9. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]

    if 5.99999999999999947e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N))

    1. Initial program 90.5%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6490.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified90.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N}{\color{blue}{\log \left(1 + N\right) + \log N}} \]
      2. frac-2negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(\log \left(1 + N\right) + \log N\right)\right)}} \]
      3. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right) \]
      4. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)\right), \left(\log \left(1 + N\right) + \log N\right)\right)\right) \]
    6. Applied egg-rr94.3%

      \[\leadsto \color{blue}{-\frac{\log \left(N \cdot \left(1 + N\right)\right) \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)}} \]
    7. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\left(N \cdot 1 + N \cdot N\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      2. flip3-+N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\left(\frac{{\left(N \cdot 1\right)}^{3} + {\left(N \cdot N\right)}^{3}}{\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)}\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left({\left(N \cdot 1\right)}^{3} + {\left(N \cdot N\right)}^{3}\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      4. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left({N}^{3} + {\left(N \cdot N\right)}^{3}\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left({N}^{3}\right), \left({\left(N \cdot N\right)}^{3}\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      6. cube-multN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(N \cdot \left(N \cdot N\right)\right), \left({\left(N \cdot N\right)}^{3}\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \left(N \cdot N\right)\right), \left({\left(N \cdot N\right)}^{3}\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \left({\left(N \cdot N\right)}^{3}\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      9. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\left(N \cdot N\right), 3\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \left(\left(N \cdot 1\right) \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      11. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \left(N \cdot \left(N \cdot 1\right) + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      12. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\left(N \cdot N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - \left(N \cdot 1\right) \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      15. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      16. cube-multN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - {N}^{3}\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      17. --lowering--.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(N, N\right), 3\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \mathsf{\_.f64}\left(\left(\left(N \cdot N\right) \cdot \left(N \cdot N\right)\right), \left({N}^{3}\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
    8. Applied egg-rr94.4%

      \[\leadsto -\frac{\log \color{blue}{\left(\frac{N \cdot \left(N \cdot N\right) + {\left(N \cdot N\right)}^{3}}{N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)}\right)} \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(N \cdot \left(N \cdot N\right) + {\left(N \cdot N\right)}^{3}\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      2. cube-multN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(N \cdot \left(N \cdot N\right) + \left(N \cdot N\right) \cdot \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      3. swap-sqrN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(N \cdot \left(N \cdot N\right) + \left(N \cdot \left(N \cdot N\right)\right) \cdot \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      4. distribute-rgt1-inN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(\left(N \cdot \left(N \cdot N\right) + 1\right) \cdot \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(\left(1 + N \cdot \left(N \cdot N\right)\right) \cdot \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(\left({1}^{3} + N \cdot \left(N \cdot N\right)\right) \cdot \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      7. cube-unmultN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(\left({1}^{3} + {N}^{3}\right) \cdot \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({1}^{3} + {N}^{3}\right), \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(1 + {N}^{3}\right), \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      10. cube-unmultN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(1 + N \cdot \left(N \cdot N\right)\right), \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(N, \left(N \cdot N\right)\right)\right), \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right)\right), \left(N \cdot \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right)\right), \mathsf{*.f64}\left(N, \left(N \cdot N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right)\right), \mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right)\right), \left(N \cdot N + \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right)\right), \mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right)\right), \mathsf{+.f64}\left(\left(N \cdot N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right)\right), \mathsf{*.f64}\left(N, \mathsf{*.f64}\left(N, N\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), \left(\left(N \cdot N\right) \cdot \left(N \cdot N\right) - N \cdot \left(N \cdot N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
    10. Applied egg-rr94.4%

      \[\leadsto -\frac{\log \color{blue}{\left(\frac{\left(1 + N \cdot \left(N \cdot N\right)\right) \cdot \left(N \cdot \left(N \cdot N\right)\right)}{N \cdot N + \left(N \cdot N\right) \cdot \left(N \cdot \left(N - 1\right)\right)}\right)} \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \log \left(\frac{\left(N \cdot \left(N \cdot N\right)\right) \cdot \left(1 + N \cdot \left(N \cdot N\right)\right)}{N \cdot N + \left(N \cdot N\right) \cdot \left(N \cdot \left(N + -1\right)\right)}\right)}{0 - \log \left(N \cdot \left(N + 1\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(N \cdot \left(N + 1\right)\right)\\ \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \frac{1}{\frac{-1}{t\_0}}}{t\_0}\\ \end{array} \end{array} \]
(FPCore (N)
 :precision binary64
 (let* ((t_0 (log (* N (+ N 1.0)))))
   (if (<= (- (log (+ N 1.0)) (log N)) 0.0006)
     (/
      1.0
      (/ N (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N))))
     (/ (* (log (/ N (+ N 1.0))) (/ 1.0 (/ -1.0 t_0))) t_0))))
double code(double N) {
	double t_0 = log((N * (N + 1.0)));
	double tmp;
	if ((log((N + 1.0)) - log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = (log((N / (N + 1.0))) * (1.0 / (-1.0 / t_0))) / t_0;
	}
	return tmp;
}
real(8) function code(n)
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = log((n * (n + 1.0d0)))
    if ((log((n + 1.0d0)) - log(n)) <= 0.0006d0) then
        tmp = 1.0d0 / (n / (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)))
    else
        tmp = (log((n / (n + 1.0d0))) * (1.0d0 / ((-1.0d0) / t_0))) / t_0
    end if
    code = tmp
end function
public static double code(double N) {
	double t_0 = Math.log((N * (N + 1.0)));
	double tmp;
	if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = (Math.log((N / (N + 1.0))) * (1.0 / (-1.0 / t_0))) / t_0;
	}
	return tmp;
}
def code(N):
	t_0 = math.log((N * (N + 1.0)))
	tmp = 0
	if (math.log((N + 1.0)) - math.log(N)) <= 0.0006:
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)))
	else:
		tmp = (math.log((N / (N + 1.0))) * (1.0 / (-1.0 / t_0))) / t_0
	return tmp
function code(N)
	t_0 = log(Float64(N * Float64(N + 1.0)))
	tmp = 0.0
	if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0006)
		tmp = Float64(1.0 / Float64(N / Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N))));
	else
		tmp = Float64(Float64(log(Float64(N / Float64(N + 1.0))) * Float64(1.0 / Float64(-1.0 / t_0))) / t_0);
	end
	return tmp
end
function tmp_2 = code(N)
	t_0 = log((N * (N + 1.0)));
	tmp = 0.0;
	if ((log((N + 1.0)) - log(N)) <= 0.0006)
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	else
		tmp = (log((N / (N + 1.0))) * (1.0 / (-1.0 / t_0))) / t_0;
	end
	tmp_2 = tmp;
end
code[N_] := Block[{t$95$0 = N[Log[N[(N * N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0006], N[(1.0 / N[(N / N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(N / N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(N \cdot \left(N + 1\right)\right)\\
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\
\;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \frac{1}{\frac{-1}{t\_0}}}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.99999999999999947e-4

    1. Initial program 18.0%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6418.0%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified18.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Taylor expanded in N around inf

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
    7. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      9. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]

    if 5.99999999999999947e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N))

    1. Initial program 90.5%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6490.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified90.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N}{\color{blue}{\log \left(1 + N\right) + \log N}} \]
      2. frac-2negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(\log \left(1 + N\right) + \log N\right)\right)}} \]
      3. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right) \]
      4. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)\right), \left(\log \left(1 + N\right) + \log N\right)\right)\right) \]
    6. Applied egg-rr94.3%

      \[\leadsto \color{blue}{-\frac{\log \left(N \cdot \left(1 + N\right)\right) \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)}} \]
    7. Step-by-step derivation
      1. /-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{\log \left(N \cdot \left(1 + N\right)\right)}{1}\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      2. clear-numN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{1}{\frac{1}{\log \left(N \cdot \left(1 + N\right)\right)}}\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{1}{\log \left(N \cdot \left(1 + N\right)\right)}\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \log \left(N \cdot \left(1 + N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      5. log-lowering-log.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{log.f64}\left(\left(N \cdot \left(1 + N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \left(1 + N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
      7. +-lowering-+.f6494.4%

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right)\right) \]
    8. Applied egg-rr94.4%

      \[\leadsto -\frac{\color{blue}{\frac{1}{\frac{1}{\log \left(N \cdot \left(1 + N\right)\right)}}} \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \frac{1}{\frac{-1}{\log \left(N \cdot \left(N + 1\right)\right)}}}{\log \left(N \cdot \left(N + 1\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{\log \left(\frac{N}{N + 1}\right) \cdot \log \left(N \cdot \left(N + 1\right)\right)}{\log \left(N + N \cdot N\right)}\\ \end{array} \end{array} \]
(FPCore (N)
 :precision binary64
 (if (<= (- (log (+ N 1.0)) (log N)) 0.0006)
   (/
    1.0
    (/ N (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N))))
   (-
    0.0
    (/ (* (log (/ N (+ N 1.0))) (log (* N (+ N 1.0)))) (log (+ N (* N N)))))))
double code(double N) {
	double tmp;
	if ((log((N + 1.0)) - log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = 0.0 - ((log((N / (N + 1.0))) * log((N * (N + 1.0)))) / log((N + (N * N))));
	}
	return tmp;
}
real(8) function code(n)
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((log((n + 1.0d0)) - log(n)) <= 0.0006d0) then
        tmp = 1.0d0 / (n / (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)))
    else
        tmp = 0.0d0 - ((log((n / (n + 1.0d0))) * log((n * (n + 1.0d0)))) / log((n + (n * n))))
    end if
    code = tmp
end function
public static double code(double N) {
	double tmp;
	if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = 0.0 - ((Math.log((N / (N + 1.0))) * Math.log((N * (N + 1.0)))) / Math.log((N + (N * N))));
	}
	return tmp;
}
def code(N):
	tmp = 0
	if (math.log((N + 1.0)) - math.log(N)) <= 0.0006:
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)))
	else:
		tmp = 0.0 - ((math.log((N / (N + 1.0))) * math.log((N * (N + 1.0)))) / math.log((N + (N * N))))
	return tmp
function code(N)
	tmp = 0.0
	if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0006)
		tmp = Float64(1.0 / Float64(N / Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N))));
	else
		tmp = Float64(0.0 - Float64(Float64(log(Float64(N / Float64(N + 1.0))) * log(Float64(N * Float64(N + 1.0)))) / log(Float64(N + Float64(N * N)))));
	end
	return tmp
end
function tmp_2 = code(N)
	tmp = 0.0;
	if ((log((N + 1.0)) - log(N)) <= 0.0006)
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	else
		tmp = 0.0 - ((log((N / (N + 1.0))) * log((N * (N + 1.0)))) / log((N + (N * N))));
	end
	tmp_2 = tmp;
end
code[N_] := If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0006], N[(1.0 / N[(N / N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(N[(N[Log[N[(N / N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[(N * N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Log[N[(N + N[(N * N), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\
\;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\

\mathbf{else}:\\
\;\;\;\;0 - \frac{\log \left(\frac{N}{N + 1}\right) \cdot \log \left(N \cdot \left(N + 1\right)\right)}{\log \left(N + N \cdot N\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.99999999999999947e-4

    1. Initial program 18.0%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6418.0%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified18.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Taylor expanded in N around inf

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
    7. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      9. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]

    if 5.99999999999999947e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N))

    1. Initial program 90.5%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6490.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified90.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N}{\color{blue}{\log \left(1 + N\right) + \log N}} \]
      2. frac-2negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(\log \left(1 + N\right) + \log N\right)\right)}} \]
      3. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right) \]
      4. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)\right), \left(\log \left(1 + N\right) + \log N\right)\right)\right) \]
    6. Applied egg-rr94.3%

      \[\leadsto \color{blue}{-\frac{\log \left(N \cdot \left(1 + N\right)\right) \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)}} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\left(N \cdot \left(N + 1\right)\right)\right)\right)\right) \]
      2. distribute-lft-inN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\left(N \cdot N + N \cdot 1\right)\right)\right)\right) \]
      3. *-rgt-identityN/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\left(N \cdot N + N\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{+.f64}\left(\left(N \cdot N\right), N\right)\right)\right)\right) \]
      5. *-lowering-*.f6494.3%

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{log.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right), \mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right), \mathsf{log.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(N, N\right), N\right)\right)\right)\right) \]
    8. Applied egg-rr94.3%

      \[\leadsto -\frac{\log \left(N \cdot \left(1 + N\right)\right) \cdot \log \left(\frac{N}{1 + N}\right)}{\log \color{blue}{\left(N \cdot N + N\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{\log \left(\frac{N}{N + 1}\right) \cdot \log \left(N \cdot \left(N + 1\right)\right)}{\log \left(N + N \cdot N\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(N \cdot \left(N + 1\right)\right)\\ \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot t\_0}{0 - t\_0}\\ \end{array} \end{array} \]
(FPCore (N)
 :precision binary64
 (let* ((t_0 (log (* N (+ N 1.0)))))
   (if (<= (- (log (+ N 1.0)) (log N)) 0.0006)
     (/
      1.0
      (/ N (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N))))
     (/ (* (log (/ N (+ N 1.0))) t_0) (- 0.0 t_0)))))
double code(double N) {
	double t_0 = log((N * (N + 1.0)));
	double tmp;
	if ((log((N + 1.0)) - log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = (log((N / (N + 1.0))) * t_0) / (0.0 - t_0);
	}
	return tmp;
}
real(8) function code(n)
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = log((n * (n + 1.0d0)))
    if ((log((n + 1.0d0)) - log(n)) <= 0.0006d0) then
        tmp = 1.0d0 / (n / (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)))
    else
        tmp = (log((n / (n + 1.0d0))) * t_0) / (0.0d0 - t_0)
    end if
    code = tmp
end function
public static double code(double N) {
	double t_0 = Math.log((N * (N + 1.0)));
	double tmp;
	if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = (Math.log((N / (N + 1.0))) * t_0) / (0.0 - t_0);
	}
	return tmp;
}
def code(N):
	t_0 = math.log((N * (N + 1.0)))
	tmp = 0
	if (math.log((N + 1.0)) - math.log(N)) <= 0.0006:
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)))
	else:
		tmp = (math.log((N / (N + 1.0))) * t_0) / (0.0 - t_0)
	return tmp
function code(N)
	t_0 = log(Float64(N * Float64(N + 1.0)))
	tmp = 0.0
	if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0006)
		tmp = Float64(1.0 / Float64(N / Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N))));
	else
		tmp = Float64(Float64(log(Float64(N / Float64(N + 1.0))) * t_0) / Float64(0.0 - t_0));
	end
	return tmp
end
function tmp_2 = code(N)
	t_0 = log((N * (N + 1.0)));
	tmp = 0.0;
	if ((log((N + 1.0)) - log(N)) <= 0.0006)
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	else
		tmp = (log((N / (N + 1.0))) * t_0) / (0.0 - t_0);
	end
	tmp_2 = tmp;
end
code[N_] := Block[{t$95$0 = N[Log[N[(N * N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0006], N[(1.0 / N[(N / N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(N / N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(0.0 - t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(N \cdot \left(N + 1\right)\right)\\
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\
\;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot t\_0}{0 - t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.99999999999999947e-4

    1. Initial program 18.0%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6418.0%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified18.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Taylor expanded in N around inf

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
    7. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      9. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]

    if 5.99999999999999947e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N))

    1. Initial program 90.5%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6490.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified90.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N}{\color{blue}{\log \left(1 + N\right) + \log N}} \]
      2. frac-2negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(\log \left(1 + N\right) + \log N\right)\right)}} \]
      3. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right) \]
      4. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\left(\frac{\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)}{\log \left(1 + N\right) + \log N}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\log \left(1 + N\right) \cdot \log \left(1 + N\right) - \log N \cdot \log N\right)\right)\right), \left(\log \left(1 + N\right) + \log N\right)\right)\right) \]
    6. Applied egg-rr94.3%

      \[\leadsto \color{blue}{-\frac{\log \left(N \cdot \left(1 + N\right)\right) \cdot \log \left(\frac{N}{1 + N}\right)}{\log \left(N \cdot \left(1 + N\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{N}{N + 1}\right) \cdot \log \left(N \cdot \left(N + 1\right)\right)}{0 - \log \left(N \cdot \left(N + 1\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 99.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;0 - \log \left(\frac{N}{N + 1}\right)\\ \end{array} \end{array} \]
(FPCore (N)
 :precision binary64
 (if (<= (- (log (+ N 1.0)) (log N)) 0.0006)
   (/
    1.0
    (/ N (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N))))
   (- 0.0 (log (/ N (+ N 1.0))))))
double code(double N) {
	double tmp;
	if ((log((N + 1.0)) - log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = 0.0 - log((N / (N + 1.0)));
	}
	return tmp;
}
real(8) function code(n)
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((log((n + 1.0d0)) - log(n)) <= 0.0006d0) then
        tmp = 1.0d0 / (n / (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)))
    else
        tmp = 0.0d0 - log((n / (n + 1.0d0)))
    end if
    code = tmp
end function
public static double code(double N) {
	double tmp;
	if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0006) {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	} else {
		tmp = 0.0 - Math.log((N / (N + 1.0)));
	}
	return tmp;
}
def code(N):
	tmp = 0
	if (math.log((N + 1.0)) - math.log(N)) <= 0.0006:
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)))
	else:
		tmp = 0.0 - math.log((N / (N + 1.0)))
	return tmp
function code(N)
	tmp = 0.0
	if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0006)
		tmp = Float64(1.0 / Float64(N / Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N))));
	else
		tmp = Float64(0.0 - log(Float64(N / Float64(N + 1.0))));
	end
	return tmp
end
function tmp_2 = code(N)
	tmp = 0.0;
	if ((log((N + 1.0)) - log(N)) <= 0.0006)
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	else
		tmp = 0.0 - log((N / (N + 1.0)));
	end
	tmp_2 = tmp;
end
code[N_] := If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0006], N[(1.0 / N[(N / N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[Log[N[(N / N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\
\;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\

\mathbf{else}:\\
\;\;\;\;0 - \log \left(\frac{N}{N + 1}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.99999999999999947e-4

    1. Initial program 18.0%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6418.0%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified18.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Taylor expanded in N around inf

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
    7. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      9. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]

    if 5.99999999999999947e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N))

    1. Initial program 90.5%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6490.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified90.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. diff-logN/A

        \[\leadsto \log \left(\frac{1 + N}{N}\right) \]
      2. clear-numN/A

        \[\leadsto \log \left(\frac{1}{\frac{N}{1 + N}}\right) \]
      3. log-recN/A

        \[\leadsto \mathsf{neg}\left(\log \left(\frac{N}{1 + N}\right)\right) \]
      4. diff-logN/A

        \[\leadsto \mathsf{neg}\left(\left(\log N - \log \left(1 + N\right)\right)\right) \]
      5. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\left(\log N - \log \left(1 + N\right)\right)\right) \]
      6. diff-logN/A

        \[\leadsto \mathsf{neg.f64}\left(\log \left(\frac{N}{1 + N}\right)\right) \]
      7. log-lowering-log.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{log.f64}\left(\left(\frac{N}{1 + N}\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \left(1 + N\right)\right)\right)\right) \]
      9. +-lowering-+.f6494.3%

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{log.f64}\left(\mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, N\right)\right)\right)\right) \]
    6. Applied egg-rr94.3%

      \[\leadsto \color{blue}{-\log \left(\frac{N}{1 + N}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \mathbf{else}:\\ \;\;\;\;0 - \log \left(\frac{N}{N + 1}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;N \leq 1300:\\ \;\;\;\;\log \left(\frac{N + 1}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \end{array} \end{array} \]
(FPCore (N)
 :precision binary64
 (if (<= N 1300.0)
   (log (/ (+ N 1.0) N))
   (/
    1.0
    (/ N (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N))))))
double code(double N) {
	double tmp;
	if (N <= 1300.0) {
		tmp = log(((N + 1.0) / N));
	} else {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	}
	return tmp;
}
real(8) function code(n)
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= 1300.0d0) then
        tmp = log(((n + 1.0d0) / n))
    else
        tmp = 1.0d0 / (n / (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)))
    end if
    code = tmp
end function
public static double code(double N) {
	double tmp;
	if (N <= 1300.0) {
		tmp = Math.log(((N + 1.0) / N));
	} else {
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	}
	return tmp;
}
def code(N):
	tmp = 0
	if N <= 1300.0:
		tmp = math.log(((N + 1.0) / N))
	else:
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)))
	return tmp
function code(N)
	tmp = 0.0
	if (N <= 1300.0)
		tmp = log(Float64(Float64(N + 1.0) / N));
	else
		tmp = Float64(1.0 / Float64(N / Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N))));
	end
	return tmp
end
function tmp_2 = code(N)
	tmp = 0.0;
	if (N <= 1300.0)
		tmp = log(((N + 1.0) / N));
	else
		tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
	end
	tmp_2 = tmp;
end
code[N_] := If[LessEqual[N, 1300.0], N[Log[N[(N[(N + 1.0), $MachinePrecision] / N), $MachinePrecision]], $MachinePrecision], N[(1.0 / N[(N / N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;N \leq 1300:\\
\;\;\;\;\log \left(\frac{N + 1}{N}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if N < 1300

    1. Initial program 90.8%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6490.9%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified90.9%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. diff-logN/A

        \[\leadsto \log \left(\frac{1 + N}{N}\right) \]
      2. log-lowering-log.f64N/A

        \[\leadsto \mathsf{log.f64}\left(\left(\frac{1 + N}{N}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{log.f64}\left(\mathsf{/.f64}\left(\left(1 + N\right), N\right)\right) \]
      4. +-lowering-+.f6493.4%

        \[\leadsto \mathsf{log.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, N\right), N\right)\right) \]
    6. Applied egg-rr93.4%

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

    if 1300 < N

    1. Initial program 18.3%

      \[\log \left(N + 1\right) - \log N \]
    2. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
      3. log1p-defineN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
      4. log1p-lowering-log1p.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
      5. log-lowering-log.f6418.3%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
    3. Simplified18.3%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
    4. Add Preprocessing
    5. Taylor expanded in N around inf

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
    6. Simplified99.7%

      \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
    7. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
      9. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;N \leq 1300:\\ \;\;\;\;\log \left(\frac{N + 1}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 96.6% accurate, 12.1× speedup?

\[\begin{array}{l} \\ \frac{-1}{N \cdot \left(\frac{-0.5 + \frac{0.08333333333333333 + \frac{-0.041666666666666664}{N}}{N}}{N} + -1\right)} \end{array} \]
(FPCore (N)
 :precision binary64
 (/
  -1.0
  (*
   N
   (+
    (/ (+ -0.5 (/ (+ 0.08333333333333333 (/ -0.041666666666666664 N)) N)) N)
    -1.0))))
double code(double N) {
	return -1.0 / (N * (((-0.5 + ((0.08333333333333333 + (-0.041666666666666664 / N)) / N)) / N) + -1.0));
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = (-1.0d0) / (n * ((((-0.5d0) + ((0.08333333333333333d0 + ((-0.041666666666666664d0) / n)) / n)) / n) + (-1.0d0)))
end function
public static double code(double N) {
	return -1.0 / (N * (((-0.5 + ((0.08333333333333333 + (-0.041666666666666664 / N)) / N)) / N) + -1.0));
}
def code(N):
	return -1.0 / (N * (((-0.5 + ((0.08333333333333333 + (-0.041666666666666664 / N)) / N)) / N) + -1.0))
function code(N)
	return Float64(-1.0 / Float64(N * Float64(Float64(Float64(-0.5 + Float64(Float64(0.08333333333333333 + Float64(-0.041666666666666664 / N)) / N)) / N) + -1.0)))
end
function tmp = code(N)
	tmp = -1.0 / (N * (((-0.5 + ((0.08333333333333333 + (-0.041666666666666664 / N)) / N)) / N) + -1.0));
end
code[N_] := N[(-1.0 / N[(N * N[(N[(N[(-0.5 + N[(N[(0.08333333333333333 + N[(-0.041666666666666664 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-1}{N \cdot \left(\frac{-0.5 + \frac{0.08333333333333333 + \frac{-0.041666666666666664}{N}}{N}}{N} + -1\right)}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    9. /-lowering-/.f6496.7%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
  8. Applied egg-rr96.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  9. Taylor expanded in N around -inf

    \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(-1 \cdot \left(N \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right)\right)\right)}\right) \]
  10. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(N \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right)\right)\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot N\right)\right)\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(N\right)\right)}\right)\right) \]
    4. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot \left(-1 \cdot \color{blue}{N}\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right), \color{blue}{\left(-1 \cdot N\right)}\right)\right) \]
  11. Simplified97.1%

    \[\leadsto \frac{1}{\color{blue}{\left(\frac{-\left(0.5 - \frac{0.08333333333333333 - \frac{0.041666666666666664}{N}}{N}\right)}{N} + -1\right) \cdot \left(0 - N\right)}} \]
  12. Step-by-step derivation
    1. sub0-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1\right) \cdot \left(\mathsf{neg}\left(N\right)\right)\right)\right) \]
    2. distribute-rgt-neg-outN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(\left(\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1\right) \cdot N\right)\right)\right) \]
    3. neg-lowering-neg.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{neg.f64}\left(\left(\left(\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1\right) \cdot N\right)\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{neg.f64}\left(\mathsf{*.f64}\left(\left(\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1\right), N\right)\right)\right) \]
  13. Applied egg-rr97.1%

    \[\leadsto \frac{1}{\color{blue}{-\left(\frac{-0.5 + \frac{0.08333333333333333 + \frac{-0.041666666666666664}{N}}{N}}{N} + -1\right) \cdot N}} \]
  14. Final simplification97.1%

    \[\leadsto \frac{-1}{N \cdot \left(\frac{-0.5 + \frac{0.08333333333333333 + \frac{-0.041666666666666664}{N}}{N}}{N} + -1\right)} \]
  15. Add Preprocessing

Alternative 9: 96.5% accurate, 12.1× speedup?

\[\begin{array}{l} \\ \frac{\frac{-1}{\frac{-0.5 + \frac{0.08333333333333333 + \frac{-0.041666666666666664}{N}}{N}}{N} + -1}}{N} \end{array} \]
(FPCore (N)
 :precision binary64
 (/
  (/
   -1.0
   (+
    (/ (+ -0.5 (/ (+ 0.08333333333333333 (/ -0.041666666666666664 N)) N)) N)
    -1.0))
  N))
double code(double N) {
	return (-1.0 / (((-0.5 + ((0.08333333333333333 + (-0.041666666666666664 / N)) / N)) / N) + -1.0)) / N;
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = ((-1.0d0) / ((((-0.5d0) + ((0.08333333333333333d0 + ((-0.041666666666666664d0) / n)) / n)) / n) + (-1.0d0))) / n
end function
public static double code(double N) {
	return (-1.0 / (((-0.5 + ((0.08333333333333333 + (-0.041666666666666664 / N)) / N)) / N) + -1.0)) / N;
}
def code(N):
	return (-1.0 / (((-0.5 + ((0.08333333333333333 + (-0.041666666666666664 / N)) / N)) / N) + -1.0)) / N
function code(N)
	return Float64(Float64(-1.0 / Float64(Float64(Float64(-0.5 + Float64(Float64(0.08333333333333333 + Float64(-0.041666666666666664 / N)) / N)) / N) + -1.0)) / N)
end
function tmp = code(N)
	tmp = (-1.0 / (((-0.5 + ((0.08333333333333333 + (-0.041666666666666664 / N)) / N)) / N) + -1.0)) / N;
end
code[N_] := N[(N[(-1.0 / N[(N[(N[(-0.5 + N[(N[(0.08333333333333333 + N[(-0.041666666666666664 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{-1}{\frac{-0.5 + \frac{0.08333333333333333 + \frac{-0.041666666666666664}{N}}{N}}{N} + -1}}{N}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    9. /-lowering-/.f6496.7%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
  8. Applied egg-rr96.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  9. Taylor expanded in N around -inf

    \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(-1 \cdot \left(N \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right)\right)\right)}\right) \]
  10. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(N \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right)\right)\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot N\right)\right)\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(N\right)\right)}\right)\right) \]
    4. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot \left(-1 \cdot \color{blue}{N}\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right), \color{blue}{\left(-1 \cdot N\right)}\right)\right) \]
  11. Simplified97.1%

    \[\leadsto \frac{1}{\color{blue}{\left(\frac{-\left(0.5 - \frac{0.08333333333333333 - \frac{0.041666666666666664}{N}}{N}\right)}{N} + -1\right) \cdot \left(0 - N\right)}} \]
  12. Step-by-step derivation
    1. sub0-negN/A

      \[\leadsto \frac{1}{\left(\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1\right) \cdot \left(\mathsf{neg}\left(N\right)\right)} \]
    2. associate-/r*N/A

      \[\leadsto \frac{\frac{1}{\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1}}{\color{blue}{\mathsf{neg}\left(N\right)}} \]
    3. distribute-frac-neg2N/A

      \[\leadsto \mathsf{neg}\left(\frac{\frac{1}{\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1}}{N}\right) \]
    4. neg-lowering-neg.f64N/A

      \[\leadsto \mathsf{neg.f64}\left(\left(\frac{\frac{1}{\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1}}{N}\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{\frac{\mathsf{neg}\left(\left(\frac{1}{2} - \frac{\frac{1}{12} - \frac{\frac{1}{24}}{N}}{N}\right)\right)}{N} + -1}\right), N\right)\right) \]
  13. Applied egg-rr97.0%

    \[\leadsto \color{blue}{-\frac{\frac{1}{\frac{-0.5 + \frac{0.08333333333333333 + \frac{-0.041666666666666664}{N}}{N}}{N} + -1}}{N}} \]
  14. Final simplification97.0%

    \[\leadsto \frac{\frac{-1}{\frac{-0.5 + \frac{0.08333333333333333 + \frac{-0.041666666666666664}{N}}{N}}{N} + -1}}{N} \]
  15. Add Preprocessing

Alternative 10: 96.5% accurate, 12.1× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{0.041666666666666664 + N \cdot \left(N \cdot \left(N + 0.5\right) + -0.08333333333333333\right)}{N \cdot N}} \end{array} \]
(FPCore (N)
 :precision binary64
 (/
  1.0
  (/
   (+ 0.041666666666666664 (* N (+ (* N (+ N 0.5)) -0.08333333333333333)))
   (* N N))))
double code(double N) {
	return 1.0 / ((0.041666666666666664 + (N * ((N * (N + 0.5)) + -0.08333333333333333))) / (N * N));
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = 1.0d0 / ((0.041666666666666664d0 + (n * ((n * (n + 0.5d0)) + (-0.08333333333333333d0)))) / (n * n))
end function
public static double code(double N) {
	return 1.0 / ((0.041666666666666664 + (N * ((N * (N + 0.5)) + -0.08333333333333333))) / (N * N));
}
def code(N):
	return 1.0 / ((0.041666666666666664 + (N * ((N * (N + 0.5)) + -0.08333333333333333))) / (N * N))
function code(N)
	return Float64(1.0 / Float64(Float64(0.041666666666666664 + Float64(N * Float64(Float64(N * Float64(N + 0.5)) + -0.08333333333333333))) / Float64(N * N)))
end
function tmp = code(N)
	tmp = 1.0 / ((0.041666666666666664 + (N * ((N * (N + 0.5)) + -0.08333333333333333))) / (N * N));
end
code[N_] := N[(1.0 / N[(N[(0.041666666666666664 + N[(N * N[(N[(N * N[(N + 0.5), $MachinePrecision]), $MachinePrecision] + -0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N * N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{0.041666666666666664 + N \cdot \left(N \cdot \left(N + 0.5\right) + -0.08333333333333333\right)}{N \cdot N}}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    9. /-lowering-/.f6496.7%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
  8. Applied egg-rr96.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  9. Taylor expanded in N around -inf

    \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(-1 \cdot \left(N \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right)\right)\right)}\right) \]
  10. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(N \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right)\right)\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot N\right)\right)\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(N\right)\right)}\right)\right) \]
    4. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot \left(-1 \cdot \color{blue}{N}\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right), \color{blue}{\left(-1 \cdot N\right)}\right)\right) \]
  11. Simplified97.1%

    \[\leadsto \frac{1}{\color{blue}{\left(\frac{-\left(0.5 - \frac{0.08333333333333333 - \frac{0.041666666666666664}{N}}{N}\right)}{N} + -1\right) \cdot \left(0 - N\right)}} \]
  12. Taylor expanded in N around 0

    \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{\frac{1}{24} + N \cdot \left(N \cdot \left(\frac{1}{2} + N\right) - \frac{1}{12}\right)}{{N}^{2}}\right)}\right) \]
  13. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{1}{24} + N \cdot \left(N \cdot \left(\frac{1}{2} + N\right) - \frac{1}{12}\right)\right), \color{blue}{\left({N}^{2}\right)}\right)\right) \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \left(N \cdot \left(N \cdot \left(\frac{1}{2} + N\right) - \frac{1}{12}\right)\right)\right), \left({\color{blue}{N}}^{2}\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \left(N \cdot \left(\frac{1}{2} + N\right) - \frac{1}{12}\right)\right)\right), \left({N}^{2}\right)\right)\right) \]
    4. sub-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \left(N \cdot \left(\frac{1}{2} + N\right) + \left(\mathsf{neg}\left(\frac{1}{12}\right)\right)\right)\right)\right), \left({N}^{2}\right)\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \left(N \cdot \left(\frac{1}{2} + N\right) + \frac{-1}{12}\right)\right)\right), \left({N}^{2}\right)\right)\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(\left(N \cdot \left(\frac{1}{2} + N\right)\right), \frac{-1}{12}\right)\right)\right), \left({N}^{2}\right)\right)\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \left(\frac{1}{2} + N\right)\right), \frac{-1}{12}\right)\right)\right), \left({N}^{2}\right)\right)\right) \]
    8. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \left(N + \frac{1}{2}\right)\right), \frac{-1}{12}\right)\right)\right), \left({N}^{2}\right)\right)\right) \]
    9. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(N, \frac{1}{2}\right)\right), \frac{-1}{12}\right)\right)\right), \left({N}^{2}\right)\right)\right) \]
    10. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(N, \frac{1}{2}\right)\right), \frac{-1}{12}\right)\right)\right), \left(N \cdot \color{blue}{N}\right)\right)\right) \]
    11. *-lowering-*.f6496.9%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(\mathsf{*.f64}\left(N, \mathsf{+.f64}\left(N, \frac{1}{2}\right)\right), \frac{-1}{12}\right)\right)\right), \mathsf{*.f64}\left(N, \color{blue}{N}\right)\right)\right) \]
  14. Simplified96.9%

    \[\leadsto \frac{1}{\color{blue}{\frac{0.041666666666666664 + N \cdot \left(N \cdot \left(N + 0.5\right) + -0.08333333333333333\right)}{N \cdot N}}} \]
  15. Add Preprocessing

Alternative 11: 96.2% accurate, 12.1× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}} \end{array} \]
(FPCore (N)
 :precision binary64
 (/ 1.0 (/ N (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N)))))
double code(double N) {
	return 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = 1.0d0 / (n / (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)))
end function
public static double code(double N) {
	return 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
}
def code(N):
	return 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)))
function code(N)
	return Float64(1.0 / Float64(N / Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N))))
end
function tmp = code(N)
	tmp = 1.0 / (N / (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)));
end
code[N_] := N[(1.0 / N[(N / N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    9. /-lowering-/.f6496.7%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
  8. Applied egg-rr96.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  9. Final simplification96.7%

    \[\leadsto \frac{1}{\frac{N}{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}} \]
  10. Add Preprocessing

Alternative 12: 96.2% accurate, 13.7× speedup?

\[\begin{array}{l} \\ \frac{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}{N} \end{array} \]
(FPCore (N)
 :precision binary64
 (/ (- 1.0 (/ (- (/ (+ (/ 0.25 N) -0.3333333333333333) N) -0.5) N)) N))
double code(double N) {
	return (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)) / N;
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = (1.0d0 - (((((0.25d0 / n) + (-0.3333333333333333d0)) / n) - (-0.5d0)) / n)) / n
end function
public static double code(double N) {
	return (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)) / N;
}
def code(N):
	return (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)) / N
function code(N)
	return Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)) / N)
end
function tmp = code(N)
	tmp = (1.0 - (((((0.25 / N) + -0.3333333333333333) / N) - -0.5) / N)) / N;
end
code[N_] := N[(N[(1.0 - N[(N[(N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}{N}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Final simplification96.7%

    \[\leadsto \frac{1 - \frac{\frac{\frac{0.25}{N} + -0.3333333333333333}{N} - -0.5}{N}}{N} \]
  8. Add Preprocessing

Alternative 13: 95.4% accurate, 13.7× speedup?

\[\begin{array}{l} \\ \frac{1}{N \cdot \left(\left(1 + \frac{0.5}{N}\right) - \frac{0.08333333333333333}{N \cdot N}\right)} \end{array} \]
(FPCore (N)
 :precision binary64
 (/ 1.0 (* N (- (+ 1.0 (/ 0.5 N)) (/ 0.08333333333333333 (* N N))))))
double code(double N) {
	return 1.0 / (N * ((1.0 + (0.5 / N)) - (0.08333333333333333 / (N * N))));
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = 1.0d0 / (n * ((1.0d0 + (0.5d0 / n)) - (0.08333333333333333d0 / (n * n))))
end function
public static double code(double N) {
	return 1.0 / (N * ((1.0 + (0.5 / N)) - (0.08333333333333333 / (N * N))));
}
def code(N):
	return 1.0 / (N * ((1.0 + (0.5 / N)) - (0.08333333333333333 / (N * N))))
function code(N)
	return Float64(1.0 / Float64(N * Float64(Float64(1.0 + Float64(0.5 / N)) - Float64(0.08333333333333333 / Float64(N * N)))))
end
function tmp = code(N)
	tmp = 1.0 / (N * ((1.0 + (0.5 / N)) - (0.08333333333333333 / (N * N))));
end
code[N_] := N[(1.0 / N[(N * N[(N[(1.0 + N[(0.5 / N), $MachinePrecision]), $MachinePrecision] - N[(0.08333333333333333 / N[(N * N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{N \cdot \left(\left(1 + \frac{0.5}{N}\right) - \frac{0.08333333333333333}{N \cdot N}\right)}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    9. /-lowering-/.f6496.7%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
  8. Applied egg-rr96.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  9. Taylor expanded in N around inf

    \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(N \cdot \left(\left(1 + \frac{1}{2} \cdot \frac{1}{N}\right) - \frac{\frac{1}{12}}{{N}^{2}}\right)\right)}\right) \]
  10. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \color{blue}{\left(\left(1 + \frac{1}{2} \cdot \frac{1}{N}\right) - \frac{\frac{1}{12}}{{N}^{2}}\right)}\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{\_.f64}\left(\left(1 + \frac{1}{2} \cdot \frac{1}{N}\right), \color{blue}{\left(\frac{\frac{1}{12}}{{N}^{2}}\right)}\right)\right)\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot \frac{1}{N}\right)\right), \left(\frac{\color{blue}{\frac{1}{12}}}{{N}^{2}}\right)\right)\right)\right) \]
    4. associate-*r/N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{\frac{1}{2} \cdot 1}{N}\right)\right), \left(\frac{\frac{1}{12}}{{N}^{2}}\right)\right)\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{\frac{1}{2}}{N}\right)\right), \left(\frac{\frac{1}{12}}{{N}^{2}}\right)\right)\right)\right) \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\frac{1}{2}, N\right)\right), \left(\frac{\frac{1}{12}}{{N}^{2}}\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\frac{1}{2}, N\right)\right), \mathsf{/.f64}\left(\frac{1}{12}, \color{blue}{\left({N}^{2}\right)}\right)\right)\right)\right) \]
    8. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\frac{1}{2}, N\right)\right), \mathsf{/.f64}\left(\frac{1}{12}, \left(N \cdot \color{blue}{N}\right)\right)\right)\right)\right) \]
    9. *-lowering-*.f6495.9%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\frac{1}{2}, N\right)\right), \mathsf{/.f64}\left(\frac{1}{12}, \mathsf{*.f64}\left(N, \color{blue}{N}\right)\right)\right)\right)\right) \]
  11. Simplified95.9%

    \[\leadsto \frac{1}{\color{blue}{N \cdot \left(\left(1 + \frac{0.5}{N}\right) - \frac{0.08333333333333333}{N \cdot N}\right)}} \]
  12. Add Preprocessing

Alternative 14: 95.4% accurate, 15.8× speedup?

\[\begin{array}{l} \\ \frac{-1}{N \cdot \left(-1 + \frac{-0.5 + \frac{0.08333333333333333}{N}}{N}\right)} \end{array} \]
(FPCore (N)
 :precision binary64
 (/ -1.0 (* N (+ -1.0 (/ (+ -0.5 (/ 0.08333333333333333 N)) N)))))
double code(double N) {
	return -1.0 / (N * (-1.0 + ((-0.5 + (0.08333333333333333 / N)) / N)));
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = (-1.0d0) / (n * ((-1.0d0) + (((-0.5d0) + (0.08333333333333333d0 / n)) / n)))
end function
public static double code(double N) {
	return -1.0 / (N * (-1.0 + ((-0.5 + (0.08333333333333333 / N)) / N)));
}
def code(N):
	return -1.0 / (N * (-1.0 + ((-0.5 + (0.08333333333333333 / N)) / N)))
function code(N)
	return Float64(-1.0 / Float64(N * Float64(-1.0 + Float64(Float64(-0.5 + Float64(0.08333333333333333 / N)) / N))))
end
function tmp = code(N)
	tmp = -1.0 / (N * (-1.0 + ((-0.5 + (0.08333333333333333 / N)) / N)));
end
code[N_] := N[(-1.0 / N[(N * N[(-1.0 + N[(N[(-0.5 + N[(0.08333333333333333 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-1}{N \cdot \left(-1 + \frac{-0.5 + \frac{0.08333333333333333}{N}}{N}\right)}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    9. /-lowering-/.f6496.7%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
  8. Applied egg-rr96.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  9. Taylor expanded in N around -inf

    \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(-1 \cdot \left(N \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right)\right)\right)}\right) \]
  10. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(N \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right)\right)\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot N\right)\right)\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(N\right)\right)}\right)\right) \]
    4. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right) \cdot \left(-1 \cdot \color{blue}{N}\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{12} - \frac{1}{24} \cdot \frac{1}{N}}{N}}{N} - 1\right), \color{blue}{\left(-1 \cdot N\right)}\right)\right) \]
  11. Simplified97.1%

    \[\leadsto \frac{1}{\color{blue}{\left(\frac{-\left(0.5 - \frac{0.08333333333333333 - \frac{0.041666666666666664}{N}}{N}\right)}{N} + -1\right) \cdot \left(0 - N\right)}} \]
  12. Taylor expanded in N around inf

    \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left(\frac{\frac{1}{12} \cdot \frac{1}{N} - \frac{1}{2}}{N}\right)}, -1\right), \mathsf{\_.f64}\left(0, N\right)\right)\right) \]
  13. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{12} \cdot \frac{1}{N} - \frac{1}{2}\right), N\right), -1\right), \mathsf{\_.f64}\left(0, N\right)\right)\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{12} \cdot \frac{1}{N} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right), N\right), -1\right), \mathsf{\_.f64}\left(0, N\right)\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{12} \cdot \frac{1}{N} + \frac{-1}{2}\right), N\right), -1\right), \mathsf{\_.f64}\left(0, N\right)\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{1}{12} \cdot \frac{1}{N}\right), \frac{-1}{2}\right), N\right), -1\right), \mathsf{\_.f64}\left(0, N\right)\right)\right) \]
    5. associate-*r/N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{12} \cdot 1}{N}\right), \frac{-1}{2}\right), N\right), -1\right), \mathsf{\_.f64}\left(0, N\right)\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{12}}{N}\right), \frac{-1}{2}\right), N\right), -1\right), \mathsf{\_.f64}\left(0, N\right)\right)\right) \]
    7. /-lowering-/.f6495.9%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{12}, N\right), \frac{-1}{2}\right), N\right), -1\right), \mathsf{\_.f64}\left(0, N\right)\right)\right) \]
  14. Simplified95.9%

    \[\leadsto \frac{1}{\left(\color{blue}{\frac{\frac{0.08333333333333333}{N} + -0.5}{N}} + -1\right) \cdot \left(0 - N\right)} \]
  15. Final simplification95.9%

    \[\leadsto \frac{-1}{N \cdot \left(-1 + \frac{-0.5 + \frac{0.08333333333333333}{N}}{N}\right)} \]
  16. Add Preprocessing

Alternative 15: 95.0% accurate, 15.8× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{N}{1 + \frac{\frac{0.3333333333333333}{N} - 0.5}{N}}} \end{array} \]
(FPCore (N)
 :precision binary64
 (/ 1.0 (/ N (+ 1.0 (/ (- (/ 0.3333333333333333 N) 0.5) N)))))
double code(double N) {
	return 1.0 / (N / (1.0 + (((0.3333333333333333 / N) - 0.5) / N)));
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = 1.0d0 / (n / (1.0d0 + (((0.3333333333333333d0 / n) - 0.5d0) / n)))
end function
public static double code(double N) {
	return 1.0 / (N / (1.0 + (((0.3333333333333333 / N) - 0.5) / N)));
}
def code(N):
	return 1.0 / (N / (1.0 + (((0.3333333333333333 / N) - 0.5) / N)))
function code(N)
	return Float64(1.0 / Float64(N / Float64(1.0 + Float64(Float64(Float64(0.3333333333333333 / N) - 0.5) / N))))
end
function tmp = code(N)
	tmp = 1.0 / (N / (1.0 + (((0.3333333333333333 / N) - 0.5) / N)));
end
code[N_] := N[(1.0 / N[(N / N[(1.0 + N[(N[(N[(0.3333333333333333 / N), $MachinePrecision] - 0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{N}{1 + \frac{\frac{0.3333333333333333}{N} - 0.5}{N}}}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    9. /-lowering-/.f6496.7%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
  8. Applied egg-rr96.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  9. Taylor expanded in N around -inf

    \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + -1 \cdot \frac{\frac{1}{2} - \frac{1}{3} \cdot \frac{1}{N}}{N}\right)}\right)\right) \]
  10. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \left(1 + \left(\mathsf{neg}\left(\frac{\frac{1}{2} - \frac{1}{3} \cdot \frac{1}{N}}{N}\right)\right)\right)\right)\right) \]
    2. unsub-negN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \left(1 - \color{blue}{\frac{\frac{1}{2} - \frac{1}{3} \cdot \frac{1}{N}}{N}}\right)\right)\right) \]
    3. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{\frac{1}{2} - \frac{1}{3} \cdot \frac{1}{N}}{N}\right)}\right)\right)\right) \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{1}{2} - \frac{1}{3} \cdot \frac{1}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \left(\frac{1}{3} \cdot \frac{1}{N}\right)\right), N\right)\right)\right)\right) \]
    6. associate-*r/N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{3} \cdot 1}{N}\right)\right), N\right)\right)\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \left(\frac{\frac{1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    8. /-lowering-/.f6495.5%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\frac{1}{3}, N\right)\right), N\right)\right)\right)\right) \]
  11. Simplified95.5%

    \[\leadsto \frac{1}{\frac{N}{\color{blue}{1 - \frac{0.5 - \frac{0.3333333333333333}{N}}{N}}}} \]
  12. Final simplification95.5%

    \[\leadsto \frac{1}{\frac{N}{1 + \frac{\frac{0.3333333333333333}{N} - 0.5}{N}}} \]
  13. Add Preprocessing

Alternative 16: 95.0% accurate, 18.6× speedup?

\[\begin{array}{l} \\ \frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{N}}{N}}{N} \end{array} \]
(FPCore (N)
 :precision binary64
 (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 N)) N)) N))
double code(double N) {
	return (1.0 + ((-0.5 + (0.3333333333333333 / N)) / N)) / N;
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = (1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / n)) / n)) / n
end function
public static double code(double N) {
	return (1.0 + ((-0.5 + (0.3333333333333333 / N)) / N)) / N;
}
def code(N):
	return (1.0 + ((-0.5 + (0.3333333333333333 / N)) / N)) / N
function code(N)
	return Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / N)) / N)) / N)
end
function tmp = code(N)
	tmp = (1.0 + ((-0.5 + (0.3333333333333333 / N)) / N)) / N;
end
code[N_] := N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{N}}{N}}{N}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \frac{1}{2} \cdot \frac{1}{N}}{N}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \frac{1}{2} \cdot \frac{1}{N}\right), \color{blue}{N}\right) \]
  7. Simplified95.5%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{N}}{N}}{N}} \]
  8. Add Preprocessing

Alternative 17: 93.0% accurate, 22.8× speedup?

\[\begin{array}{l} \\ \frac{-1}{N \cdot \left(-1 - \frac{0.5}{N}\right)} \end{array} \]
(FPCore (N) :precision binary64 (/ -1.0 (* N (- -1.0 (/ 0.5 N)))))
double code(double N) {
	return -1.0 / (N * (-1.0 - (0.5 / N)));
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = (-1.0d0) / (n * ((-1.0d0) - (0.5d0 / n)))
end function
public static double code(double N) {
	return -1.0 / (N * (-1.0 - (0.5 / N)));
}
def code(N):
	return -1.0 / (N * (-1.0 - (0.5 / N)))
function code(N)
	return Float64(-1.0 / Float64(N * Float64(-1.0 - Float64(0.5 / N))))
end
function tmp = code(N)
	tmp = -1.0 / (N * (-1.0 - (0.5 / N)));
end
code[N_] := N[(-1.0 / N[(N * N[(-1.0 - N[(0.5 / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-1}{N \cdot \left(-1 - \frac{0.5}{N}\right)}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{\frac{1}{3}}{{N}^{2}}\right) - \left(\frac{1}{2} \cdot \frac{1}{N} + \frac{1}{4} \cdot \frac{1}{{N}^{3}}\right)}{N}} \]
  6. Simplified96.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{N}{1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \color{blue}{\left(1 + \frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}}{N}\right)}\right)\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{-1}{2} - \frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right), \color{blue}{N}\right)\right)\right)\right) \]
    6. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \left(\frac{\frac{\frac{1}{4}}{N} + \frac{-1}{3}}{N}\right)\right), N\right)\right)\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\left(\frac{\frac{1}{4}}{N} + \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{1}{4}}{N}\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
    9. /-lowering-/.f6496.7%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{1}{4}, N\right), \frac{-1}{3}\right), N\right)\right), N\right)\right)\right)\right) \]
  8. Applied egg-rr96.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{N}{1 + \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}} \]
  9. Taylor expanded in N around inf

    \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(N \cdot \left(1 + \frac{1}{2} \cdot \frac{1}{N}\right)\right)}\right) \]
  10. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \color{blue}{\left(1 + \frac{1}{2} \cdot \frac{1}{N}\right)}\right)\right) \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{N}\right)}\right)\right)\right) \]
    3. associate-*r/N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, \left(\frac{\frac{1}{2} \cdot 1}{\color{blue}{N}}\right)\right)\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, \left(\frac{\frac{1}{2}}{N}\right)\right)\right)\right) \]
    5. /-lowering-/.f6493.6%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(N, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{N}\right)\right)\right)\right) \]
  11. Simplified93.6%

    \[\leadsto \frac{1}{\color{blue}{N \cdot \left(1 + \frac{0.5}{N}\right)}} \]
  12. Final simplification93.6%

    \[\leadsto \frac{-1}{N \cdot \left(-1 - \frac{0.5}{N}\right)} \]
  13. Add Preprocessing

Alternative 18: 92.4% accurate, 29.3× speedup?

\[\begin{array}{l} \\ \frac{1 + \frac{-0.5}{N}}{N} \end{array} \]
(FPCore (N) :precision binary64 (/ (+ 1.0 (/ -0.5 N)) N))
double code(double N) {
	return (1.0 + (-0.5 / N)) / N;
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = (1.0d0 + ((-0.5d0) / n)) / n
end function
public static double code(double N) {
	return (1.0 + (-0.5 / N)) / N;
}
def code(N):
	return (1.0 + (-0.5 / N)) / N
function code(N)
	return Float64(Float64(1.0 + Float64(-0.5 / N)) / N)
end
function tmp = code(N)
	tmp = (1.0 + (-0.5 / N)) / N;
end
code[N_] := N[(N[(1.0 + N[(-0.5 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 + \frac{-0.5}{N}}{N}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{1 - \frac{1}{2} \cdot \frac{1}{N}}{N}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(1 - \frac{1}{2} \cdot \frac{1}{N}\right), \color{blue}{N}\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(1 + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \frac{1}{N}\right)\right)\right), N\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(\frac{1}{2} \cdot \frac{1}{N}\right)\right)\right), N\right) \]
    4. associate-*r/N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(\frac{\frac{1}{2} \cdot 1}{N}\right)\right)\right), N\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(\frac{\frac{1}{2}}{N}\right)\right)\right), N\right) \]
    6. distribute-neg-fracN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{\mathsf{neg}\left(\frac{1}{2}\right)}{N}\right)\right), N\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{\frac{-1}{2}}{N}\right)\right), N\right) \]
    8. /-lowering-/.f6493.1%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\frac{-1}{2}, N\right)\right), N\right) \]
  7. Simplified93.1%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5}{N}}{N}} \]
  8. Add Preprocessing

Alternative 19: 84.6% accurate, 68.3× speedup?

\[\begin{array}{l} \\ \frac{1}{N} \end{array} \]
(FPCore (N) :precision binary64 (/ 1.0 N))
double code(double N) {
	return 1.0 / N;
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = 1.0d0 / n
end function
public static double code(double N) {
	return 1.0 / N;
}
def code(N):
	return 1.0 / N
function code(N)
	return Float64(1.0 / N)
end
function tmp = code(N)
	tmp = 1.0 / N;
end
code[N_] := N[(1.0 / N), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{N}
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{1}{N}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f6484.9%

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{N}\right) \]
  7. Simplified84.9%

    \[\leadsto \color{blue}{\frac{1}{N}} \]
  8. Add Preprocessing

Alternative 20: 3.3% accurate, 205.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (N) :precision binary64 0.0)
double code(double N) {
	return 0.0;
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = 0.0d0
end function
public static double code(double N) {
	return 0.0;
}
def code(N):
	return 0.0
function code(N)
	return 0.0
end
function tmp = code(N)
	tmp = 0.0;
end
code[N_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 23.4%

    \[\log \left(N + 1\right) - \log N \]
  2. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(N + 1\right), \color{blue}{\log N}\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\log \left(1 + N\right), \log N\right) \]
    3. log1p-defineN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\mathsf{log1p}\left(N\right)\right), \log \color{blue}{N}\right) \]
    4. log1p-lowering-log1p.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \log \color{blue}{N}\right) \]
    5. log-lowering-log.f6423.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{log1p.f64}\left(N\right), \mathsf{log.f64}\left(N\right)\right) \]
  3. Simplified23.4%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N} \]
  4. Add Preprocessing
  5. Applied egg-rr23.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(N\right)\right)}^{2}}{{\left(\mathsf{log1p}\left(N\right)\right)}^{3} + {\log N}^{3}}, {\left(\mathsf{log1p}\left(N\right)\right)}^{2} + \log N \cdot \log \left(\frac{N}{1 + N}\right), -\frac{1}{\log \left(N \cdot \left(1 + N\right)\right)} \cdot {\log N}^{2}\right) + \mathsf{fma}\left(-\frac{1}{\log \left(N \cdot \left(1 + N\right)\right)}, {\log N}^{2}, \frac{1}{\log \left(N \cdot \left(1 + N\right)\right)} \cdot {\log N}^{2}\right)} \]
  6. Taylor expanded in N around inf

    \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log \left(\frac{1}{N}\right) + \frac{1}{2} \cdot \log \left(\frac{1}{N}\right)} \]
  7. Step-by-step derivation
    1. distribute-rgt-outN/A

      \[\leadsto \log \left(\frac{1}{N}\right) \cdot \color{blue}{\left(\frac{-1}{2} + \frac{1}{2}\right)} \]
    2. metadata-evalN/A

      \[\leadsto \log \left(\frac{1}{N}\right) \cdot 0 \]
    3. mul0-rgt3.3%

      \[\leadsto 0 \]
  8. Simplified3.3%

    \[\leadsto \color{blue}{0} \]
  9. Add Preprocessing

Developer Target 1: 99.8% accurate, 2.0× speedup?

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

\\
\mathsf{log1p}\left(\frac{1}{N}\right)
\end{array}

Reproduce

?
herbie shell --seed 2024141 
(FPCore (N)
  :name "2log (problem 3.3.6)"
  :precision binary64
  :pre (and (> N 1.0) (< N 1e+40))

  :alt
  (! :herbie-platform default (log1p (/ 1 N)))

  (- (log (+ N 1.0)) (log N)))