| Alternative 1 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 6660 |
\[\begin{array}{l}
\mathbf{if}\;N \leq 0.27:\\
\;\;\;\;-\log N\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{N + 0.5}\\
\end{array}
\]

(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
(FPCore (N) :precision binary64 (log1p (/ 1.0 N)))
double code(double N) {
return log((N + 1.0)) - log(N);
}
double code(double N) {
return log1p((1.0 / N));
}
public static double code(double N) {
return Math.log((N + 1.0)) - Math.log(N);
}
public static double code(double N) {
return Math.log1p((1.0 / N));
}
def code(N): return math.log((N + 1.0)) - math.log(N)
def code(N): return math.log1p((1.0 / N))
function code(N) return Float64(log(Float64(N + 1.0)) - log(N)) end
function code(N) return log1p(Float64(1.0 / N)) end
code[N_] := N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]
code[N_] := N[Log[1 + N[(1.0 / N), $MachinePrecision]], $MachinePrecision]
\log \left(N + 1\right) - \log N
\mathsf{log1p}\left(\frac{1}{N}\right)
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 54.1%
Simplified54.1%
Applied egg-rr54.2%
Applied egg-rr54.1%
Simplified100.0%
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 6660 |
| Alternative 2 | |
|---|---|
| Accuracy | 57.1% |
| Cost | 324 |
| Alternative 3 | |
|---|---|
| Accuracy | 57.6% |
| Cost | 320 |
| Alternative 4 | |
|---|---|
| Accuracy | 9.8% |
| Cost | 64 |
herbie shell --seed 2023161
(FPCore (N)
:name "2log (problem 3.3.6)"
:precision binary64
(- (log (+ N 1.0)) (log N)))