| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 7300 |
\[\begin{array}{l}
\mathbf{if}\;N \leq 954.8915609233318:\\
\;\;\;\;\log \left(\frac{N + 1}{N}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{{N}^{3}} + \frac{1 + \frac{-0.5}{N}}{N}\\
\end{array}
\]
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
(FPCore (N) :precision binary64 (if (<= N 954.8915609233318) (+ (* 0.5 (- (log1p N) (log N))) (log (sqrt (/ (+ N 1.0) N)))) (+ (/ 0.3333333333333333 (pow N 3.0)) (/ (+ 1.0 (/ -0.5 N)) N))))
double code(double N) {
return log((N + 1.0)) - log(N);
}
double code(double N) {
double tmp;
if (N <= 954.8915609233318) {
tmp = (0.5 * (log1p(N) - log(N))) + log(sqrt(((N + 1.0) / N)));
} else {
tmp = (0.3333333333333333 / pow(N, 3.0)) + ((1.0 + (-0.5 / N)) / N);
}
return tmp;
}
public static double code(double N) {
return Math.log((N + 1.0)) - Math.log(N);
}
public static double code(double N) {
double tmp;
if (N <= 954.8915609233318) {
tmp = (0.5 * (Math.log1p(N) - Math.log(N))) + Math.log(Math.sqrt(((N + 1.0) / N)));
} else {
tmp = (0.3333333333333333 / Math.pow(N, 3.0)) + ((1.0 + (-0.5 / N)) / N);
}
return tmp;
}
def code(N): return math.log((N + 1.0)) - math.log(N)
def code(N): tmp = 0 if N <= 954.8915609233318: tmp = (0.5 * (math.log1p(N) - math.log(N))) + math.log(math.sqrt(((N + 1.0) / N))) else: tmp = (0.3333333333333333 / math.pow(N, 3.0)) + ((1.0 + (-0.5 / N)) / N) return tmp
function code(N) return Float64(log(Float64(N + 1.0)) - log(N)) end
function code(N) tmp = 0.0 if (N <= 954.8915609233318) tmp = Float64(Float64(0.5 * Float64(log1p(N) - log(N))) + log(sqrt(Float64(Float64(N + 1.0) / N)))); else tmp = Float64(Float64(0.3333333333333333 / (N ^ 3.0)) + Float64(Float64(1.0 + Float64(-0.5 / N)) / N)); end return tmp end
code[N_] := N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]
code[N_] := If[LessEqual[N, 954.8915609233318], N[(N[(0.5 * N[(N[Log[1 + N], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Log[N[Sqrt[N[(N[(N + 1.0), $MachinePrecision] / N), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(0.3333333333333333 / N[Power[N, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + N[(-0.5 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]]
\log \left(N + 1\right) - \log N
\begin{array}{l}
\mathbf{if}\;N \leq 954.8915609233318:\\
\;\;\;\;0.5 \cdot \left(\mathsf{log1p}\left(N\right) - \log N\right) + \log \left(\sqrt{\frac{N + 1}{N}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{{N}^{3}} + \frac{1 + \frac{-0.5}{N}}{N}\\
\end{array}
Results
if N < 954.89156092333178Initial program 0.1
Simplified0.1
Applied egg-rr0.1
Applied egg-rr0.1
Applied egg-rr0.1
if 954.89156092333178 < N Initial program 59.3
Simplified59.3
Taylor expanded in N around inf 0.1
Simplified0.1
Applied egg-rr0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 7300 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 6852 |
| Alternative 3 | |
|---|---|
| Error | 0.9 |
| Cost | 6724 |
| Alternative 4 | |
|---|---|
| Error | 1.2 |
| Cost | 6660 |
| Alternative 5 | |
|---|---|
| Error | 30.8 |
| Cost | 192 |
| Alternative 6 | |
|---|---|
| Error | 61.1 |
| Cost | 64 |

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