| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6464 |
\[\mathsf{log1p}\left(x\right)
\]

(FPCore (x) :precision binary64 (log (+ 1.0 x)))
(FPCore (x) :precision binary64 (log1p x))
double code(double x) {
return log((1.0 + x));
}
double code(double x) {
return log1p(x);
}
public static double code(double x) {
return Math.log((1.0 + x));
}
public static double code(double x) {
return Math.log1p(x);
}
def code(x): return math.log((1.0 + x))
def code(x): return math.log1p(x)
function code(x) return log(Float64(1.0 + x)) end
function code(x) return log1p(x) end
code[x_] := N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]
code[x_] := N[Log[1 + x], $MachinePrecision]
\log \left(1 + x\right)
\mathsf{log1p}\left(x\right)
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 38.1% |
|---|---|
| Target | 99.6% |
| Herbie | 100.0% |
Initial program 35.0%
Simplified100.0%
[Start]35.0% | \[ \log \left(1 + x\right)
\] |
|---|---|
log1p-def [=>]100.0% | \[ \color{blue}{\mathsf{log1p}\left(x\right)}
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6464 |
| Alternative 2 | |
|---|---|
| Accuracy | 67.9% |
| Cost | 64 |
herbie shell --seed 2023269
(FPCore (x)
:name "ln(1 + x)"
:precision binary64
:herbie-target
(if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0)))
(log (+ 1.0 x)))