| Alternative 1 | |
|---|---|
| Error | 100.0% |
| Cost | 6592.00 |
\[\frac{\mathsf{expm1}\left(x\right)}{x}
\]
(FPCore (x) :precision binary64 (/ (- (exp x) 1.0) x))
(FPCore (x) :precision binary64 (/ 1.0 (/ x (expm1 x))))
double code(double x) {
return (exp(x) - 1.0) / x;
}
double code(double x) {
return 1.0 / (x / expm1(x));
}
public static double code(double x) {
return (Math.exp(x) - 1.0) / x;
}
public static double code(double x) {
return 1.0 / (x / Math.expm1(x));
}
def code(x): return (math.exp(x) - 1.0) / x
def code(x): return 1.0 / (x / math.expm1(x))
function code(x) return Float64(Float64(exp(x) - 1.0) / x) end
function code(x) return Float64(1.0 / Float64(x / expm1(x))) end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision] / x), $MachinePrecision]
code[x_] := N[(1.0 / N[(x / N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{e^{x} - 1}{x}
\frac{1}{\frac{x}{\mathsf{expm1}\left(x\right)}}
Results
| Original | 36.6% |
|---|---|
| Target | 36.1% |
| Herbie | 100.0% |
Initial program 36.6
Simplified100.0
[Start]36.6 | \[ \frac{e^{x} - 1}{x}
\] |
|---|---|
expm1-def [=>]100.0 | \[ \frac{\color{blue}{\mathsf{expm1}\left(x\right)}}{x}
\] |
Applied egg-rr100.0
Applied egg-rr100.0
Final simplification100.0
| Alternative 1 | |
|---|---|
| Error | 100.0% |
| Cost | 6592.00 |
| Alternative 2 | |
|---|---|
| Error | 73.0% |
| Cost | 452.00 |
| Alternative 3 | |
|---|---|
| Error | 73.0% |
| Cost | 448.00 |
| Alternative 4 | |
|---|---|
| Error | 72.2% |
| Cost | 324.00 |
| Alternative 5 | |
|---|---|
| Error | 68.0% |
| Cost | 64.00 |
herbie shell --seed 2023097
(FPCore (x)
:name "Kahan's exp quotient"
:precision binary64
:herbie-target
(if (and (< x 1.0) (> x -1.0)) (/ (- (exp x) 1.0) (log (exp x))) (/ (- (exp x) 1.0) x))
(/ (- (exp x) 1.0) x))