| Alternative 1 | |
|---|---|
| Accuracy | 99.3% |
| Cost | 12992 |
\[\frac{e^{x}}{\mathsf{expm1}\left(x\right)}
\]
(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(Float64(1.0 / expm1(x)) / exp(Float64(-x))) end
code[x_] := N[(N[Exp[x], $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(1.0 / N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] / N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\frac{e^{x}}{e^{x} - 1}
\frac{\frac{1}{\mathsf{expm1}\left(x\right)}}{e^{-x}}
Results
| Original | 34.6% |
|---|---|
| Target | 35.2% |
| Herbie | 99.3% |
Initial program 34.6%
Simplified99.3%
[Start]34.6 | \[ \frac{e^{x}}{e^{x} - 1}
\] |
|---|---|
expm1-def [=>]99.3 | \[ \frac{e^{x}}{\color{blue}{\mathsf{expm1}\left(x\right)}}
\] |
Applied egg-rr99.3%
[Start]99.3 | \[ \frac{e^{x}}{\mathsf{expm1}\left(x\right)}
\] |
|---|---|
clear-num [=>]99.3 | \[ \color{blue}{\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{e^{x}}}}
\] |
inv-pow [=>]99.3 | \[ \color{blue}{{\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1}}
\] |
Applied egg-rr99.3%
[Start]99.3 | \[ {\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1}
\] |
|---|---|
unpow-1 [=>]99.3 | \[ \color{blue}{\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{e^{x}}}}
\] |
div-inv [=>]99.3 | \[ \frac{1}{\color{blue}{\mathsf{expm1}\left(x\right) \cdot \frac{1}{e^{x}}}}
\] |
associate-/r* [=>]99.3 | \[ \color{blue}{\frac{\frac{1}{\mathsf{expm1}\left(x\right)}}{\frac{1}{e^{x}}}}
\] |
rec-exp [=>]99.3 | \[ \frac{\frac{1}{\mathsf{expm1}\left(x\right)}}{\color{blue}{e^{-x}}}
\] |
Final simplification99.3%
| Alternative 1 | |
|---|---|
| Accuracy | 99.3% |
| Cost | 12992 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 6916 |
| Alternative 3 | |
|---|---|
| Accuracy | 97.9% |
| Cost | 6592 |
| Alternative 4 | |
|---|---|
| Accuracy | 67.3% |
| Cost | 576 |
| Alternative 5 | |
|---|---|
| Accuracy | 67.3% |
| Cost | 320 |
| Alternative 6 | |
|---|---|
| Accuracy | 67.3% |
| Cost | 192 |
| Alternative 7 | |
|---|---|
| Accuracy | 3.3% |
| Cost | 64 |
| Alternative 8 | |
|---|---|
| Accuracy | 3.9% |
| Cost | 64 |
herbie shell --seed 2023133
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))