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

(FPCore (x) :precision binary64 (- (log x) (log (log x))))
(FPCore (x) :precision binary64 (log1p (+ (/ x (log x)) -1.0)))
double code(double x) {
return log(x) - log(log(x));
}
double code(double x) {
return log1p(((x / log(x)) + -1.0));
}
public static double code(double x) {
return Math.log(x) - Math.log(Math.log(x));
}
public static double code(double x) {
return Math.log1p(((x / Math.log(x)) + -1.0));
}
def code(x): return math.log(x) - math.log(math.log(x))
def code(x): return math.log1p(((x / math.log(x)) + -1.0))
function code(x) return Float64(log(x) - log(log(x))) end
function code(x) return log1p(Float64(Float64(x / log(x)) + -1.0)) end
code[x_] := N[(N[Log[x], $MachinePrecision] - N[Log[N[Log[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_] := N[Log[1 + N[(N[(x / N[Log[x], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]
\log x - \log \log x
\mathsf{log1p}\left(\frac{x}{\log x} + -1\right)
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 99.7%
Applied egg-rr100.0%
[Start]99.7% | \[ \log x - \log \log x
\] |
|---|---|
log1p-expm1-u [=>]99.7% | \[ \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log x - \log \log x\right)\right)}
\] |
expm1-udef [=>]99.7% | \[ \mathsf{log1p}\left(\color{blue}{e^{\log x - \log \log x} - 1}\right)
\] |
diff-log [=>]100.0% | \[ \mathsf{log1p}\left(e^{\color{blue}{\log \left(\frac{x}{\log x}\right)}} - 1\right)
\] |
add-exp-log [<=]100.0% | \[ \mathsf{log1p}\left(\color{blue}{\frac{x}{\log x}} - 1\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 13120 |
| Alternative 2 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 12992 |
| Alternative 3 | |
|---|---|
| Accuracy | 0.6% |
| Cost | 6464 |
herbie shell --seed 2023178
(FPCore (x)
:name "Jmat.Real.lambertw, estimator"
:precision binary64
(- (log x) (log (log x))))