| Alternative 1 | |
|---|---|
| Error | 1.1 |
| Cost | 708 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -2059700.993233555:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} + \left(x \cdot 0.08333333333333333 + 0.5\right)\\
\end{array}
\]
(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x) :precision binary64 (/ -1.0 (expm1 (- x))))
double code(double x) {
return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
return -1.0 / expm1(-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);
}
def code(x): return math.exp(x) / (math.exp(x) - 1.0)
def code(x): return -1.0 / math.expm1(-x)
function code(x) return Float64(exp(x) / Float64(exp(x) - 1.0)) end
function code(x) return Float64(-1.0 / expm1(Float64(-x))) end
code[x_] := N[(N[Exp[x], $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(-1.0 / N[(Exp[(-x)] - 1), $MachinePrecision]), $MachinePrecision]
\frac{e^{x}}{e^{x} - 1}
\frac{-1}{\mathsf{expm1}\left(-x\right)}
Results
| Original | 41.6 |
|---|---|
| Target | 41.2 |
| Herbie | 0.0 |
Initial program 41.6
Simplified0.4
Applied egg-rr0.4
Taylor expanded in x around inf 41.6
Simplified0.0
Taylor expanded in x around inf 41.2
Simplified0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 1.1 |
| Cost | 708 |
| Alternative 2 | |
|---|---|
| Error | 0.9 |
| Cost | 452 |
| Alternative 3 | |
|---|---|
| Error | 2.4 |
| Cost | 448 |
| Alternative 4 | |
|---|---|
| Error | 2.4 |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Error | 41.8 |
| Cost | 324 |
| Alternative 6 | |
|---|---|
| Error | 1.8 |
| Cost | 324 |
| Alternative 7 | |
|---|---|
| Error | 61.9 |
| Cost | 64 |
| Alternative 8 | |
|---|---|
| Error | 42.2 |
| Cost | 64 |

herbie shell --seed 2022308
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))