Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\log \left(N + 1\right) - \log N
\]
↓
\[\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0001:\\
\;\;\;\;\left(\frac{1}{N} + \frac{0.3333333333333333}{{N}^{3}}\right) - \left(\frac{0.5}{N \cdot N} + \frac{0.25}{{N}^{4}}\right)\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{N}{N + 1}\right)\\
\end{array}
\]
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N))) ↓
(FPCore (N)
:precision binary64
(if (<= (- (log (+ N 1.0)) (log N)) 0.0001)
(-
(+ (/ 1.0 N) (/ 0.3333333333333333 (pow N 3.0)))
(+ (/ 0.5 (* N N)) (/ 0.25 (pow N 4.0))))
(- (log (/ N (+ N 1.0)))))) double code(double N) {
return log((N + 1.0)) - log(N);
}
↓
double code(double N) {
double tmp;
if ((log((N + 1.0)) - log(N)) <= 0.0001) {
tmp = ((1.0 / N) + (0.3333333333333333 / pow(N, 3.0))) - ((0.5 / (N * N)) + (0.25 / pow(N, 4.0)));
} else {
tmp = -log((N / (N + 1.0)));
}
return tmp;
}
real(8) function code(n)
real(8), intent (in) :: n
code = log((n + 1.0d0)) - log(n)
end function
↓
real(8) function code(n)
real(8), intent (in) :: n
real(8) :: tmp
if ((log((n + 1.0d0)) - log(n)) <= 0.0001d0) then
tmp = ((1.0d0 / n) + (0.3333333333333333d0 / (n ** 3.0d0))) - ((0.5d0 / (n * n)) + (0.25d0 / (n ** 4.0d0)))
else
tmp = -log((n / (n + 1.0d0)))
end if
code = tmp
end function
public static double code(double N) {
return Math.log((N + 1.0)) - Math.log(N);
}
↓
public static double code(double N) {
double tmp;
if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0001) {
tmp = ((1.0 / N) + (0.3333333333333333 / Math.pow(N, 3.0))) - ((0.5 / (N * N)) + (0.25 / Math.pow(N, 4.0)));
} else {
tmp = -Math.log((N / (N + 1.0)));
}
return tmp;
}
def code(N):
return math.log((N + 1.0)) - math.log(N)
↓
def code(N):
tmp = 0
if (math.log((N + 1.0)) - math.log(N)) <= 0.0001:
tmp = ((1.0 / N) + (0.3333333333333333 / math.pow(N, 3.0))) - ((0.5 / (N * N)) + (0.25 / math.pow(N, 4.0)))
else:
tmp = -math.log((N / (N + 1.0)))
return tmp
function code(N)
return Float64(log(Float64(N + 1.0)) - log(N))
end
↓
function code(N)
tmp = 0.0
if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0001)
tmp = Float64(Float64(Float64(1.0 / N) + Float64(0.3333333333333333 / (N ^ 3.0))) - Float64(Float64(0.5 / Float64(N * N)) + Float64(0.25 / (N ^ 4.0))));
else
tmp = Float64(-log(Float64(N / Float64(N + 1.0))));
end
return tmp
end
function tmp = code(N)
tmp = log((N + 1.0)) - log(N);
end
↓
function tmp_2 = code(N)
tmp = 0.0;
if ((log((N + 1.0)) - log(N)) <= 0.0001)
tmp = ((1.0 / N) + (0.3333333333333333 / (N ^ 3.0))) - ((0.5 / (N * N)) + (0.25 / (N ^ 4.0)));
else
tmp = -log((N / (N + 1.0)));
end
tmp_2 = tmp;
end
code[N_] := N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]
↓
code[N_] := If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0001], N[(N[(N[(1.0 / N), $MachinePrecision] + N[(0.3333333333333333 / N[Power[N, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 / N[(N * N), $MachinePrecision]), $MachinePrecision] + N[(0.25 / N[Power[N, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Log[N[(N / N[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\log \left(N + 1\right) - \log N
↓
\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0001:\\
\;\;\;\;\left(\frac{1}{N} + \frac{0.3333333333333333}{{N}^{3}}\right) - \left(\frac{0.5}{N \cdot N} + \frac{0.25}{{N}^{4}}\right)\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{N}{N + 1}\right)\\
\end{array}
Alternatives Alternative 1 Accuracy 99.9% Cost 27204
\[\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0001:\\
\;\;\;\;\left(\frac{1}{N} + \frac{0.3333333333333333}{{N}^{3}}\right) - \left(\frac{0.5}{N \cdot N} + \frac{0.25}{{N}^{4}}\right)\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{N}{N + 1}\right)\\
\end{array}
\]
Alternative 2 Accuracy 99.9% Cost 20484
\[\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0001:\\
\;\;\;\;\frac{1}{N} + \left(\frac{0.3333333333333333}{{N}^{3}} - \frac{0.5}{N \cdot N}\right)\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{N}{N + 1}\right)\\
\end{array}
\]
Alternative 3 Accuracy 99.9% Cost 6916
\[\begin{array}{l}
\mathbf{if}\;N \leq 300000:\\
\;\;\;\;-\log \left(\frac{N}{N + 1}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{N} - \frac{\frac{0.5}{N}}{N}\\
\end{array}
\]
Alternative 4 Accuracy 99.8% Cost 6852
\[\begin{array}{l}
\mathbf{if}\;N \leq 195000:\\
\;\;\;\;\log \left(\frac{N + 1}{N}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{N} - \frac{\frac{0.5}{N}}{N}\\
\end{array}
\]
Alternative 5 Accuracy 99.0% Cost 6724
\[\begin{array}{l}
\mathbf{if}\;N \leq 0.9:\\
\;\;\;\;N - \log N\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{N} - \frac{\frac{0.5}{N}}{N}\\
\end{array}
\]
Alternative 6 Accuracy 98.6% Cost 6660
\[\begin{array}{l}
\mathbf{if}\;N \leq 0.68:\\
\;\;\;\;-\log N\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{N} - \frac{\frac{0.5}{N}}{N}\\
\end{array}
\]
Alternative 7 Accuracy 51.6% Cost 192
\[\frac{1}{N}
\]
Alternative 8 Accuracy 1.9% Cost 64
\[-0.5
\]