| Alternative 1 | |
|---|---|
| Error | 0.4 |
| 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(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{1}{\mathsf{expm1}\left(x\right)} \cdot e^{x}
Results
| Original | 41.4 |
|---|---|
| Target | 41.0 |
| Herbie | 0.4 |
Initial program 41.4
Simplified0.4
[Start]41.4 | \[ \frac{e^{x}}{e^{x} - 1}
\] |
|---|---|
expm1-def [=>]0.4 | \[ \frac{e^{x}}{\color{blue}{\mathsf{expm1}\left(x\right)}}
\] |
Applied egg-rr0.4
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 12992 |
| Alternative 2 | |
|---|---|
| Error | 1.6 |
| Cost | 6592 |
| Alternative 3 | |
|---|---|
| Error | 21.0 |
| Cost | 832 |
| Alternative 4 | |
|---|---|
| Error | 21.2 |
| Cost | 320 |
| Alternative 5 | |
|---|---|
| Error | 21.3 |
| Cost | 192 |
herbie shell --seed 2023060
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))