| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 13120 |
\[\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{e^{x}}}
\]

(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x) :precision binary64 (/ 1.0 (/ (expm1 x) (exp x))))
double code(double x) {
return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
return 1.0 / (expm1(x) / exp(x));
}
public static double code(double x) {
return Math.exp(x) / (Math.exp(x) - 1.0);
}
public static double code(double x) {
return 1.0 / (Math.expm1(x) / Math.exp(x));
}
def code(x): return math.exp(x) / (math.exp(x) - 1.0)
def code(x): return 1.0 / (math.expm1(x) / math.exp(x))
function code(x) return Float64(exp(x) / Float64(exp(x) - 1.0)) end
function code(x) return Float64(1.0 / Float64(expm1(x) / exp(x))) end
code[x_] := N[(N[Exp[x], $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(1.0 / N[(N[(Exp[x] - 1), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{e^{x}}{e^{x} - 1}
\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{e^{x}}}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 37.5% |
|---|---|
| Target | 38.2% |
| Herbie | 99.2% |
Initial program 35.6%
Simplified99.6%
[Start]35.6% | \[ \frac{e^{x}}{e^{x} - 1}
\] |
|---|---|
expm1-def [=>]99.6% | \[ \frac{e^{x}}{\color{blue}{\mathsf{expm1}\left(x\right)}}
\] |
Applied egg-rr99.6%
[Start]99.6% | \[ \frac{e^{x}}{\mathsf{expm1}\left(x\right)}
\] |
|---|---|
clear-num [=>]99.6% | \[ \color{blue}{\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{e^{x}}}}
\] |
inv-pow [=>]99.6% | \[ \color{blue}{{\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1}}
\] |
Applied egg-rr99.6%
[Start]99.6% | \[ {\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1}
\] |
|---|---|
unpow-1 [=>]99.6% | \[ \color{blue}{\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{e^{x}}}}
\] |
Final simplification99.6%
| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 13120 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.3% |
| Cost | 12992 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 7428 |
| Alternative 4 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 6916 |
| Alternative 5 | |
|---|---|
| Accuracy | 82.8% |
| Cost | 836 |
| Alternative 6 | |
|---|---|
| Accuracy | 82.8% |
| Cost | 708 |
| Alternative 7 | |
|---|---|
| Accuracy | 82.4% |
| Cost | 452 |
| Alternative 8 | |
|---|---|
| Accuracy | 66.4% |
| Cost | 320 |
| Alternative 9 | |
|---|---|
| Accuracy | 66.3% |
| Cost | 192 |
| Alternative 10 | |
|---|---|
| Accuracy | 3.4% |
| Cost | 64 |
herbie shell --seed 2023165
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))