| Alternative 1 | |
|---|---|
| Error | 0.63% |
| 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 (* (exp (- x)) (expm1 x))))
double code(double x) {
return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
return 1.0 / (exp(-x) * 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.exp(-x) * Math.expm1(x));
}
def code(x): return math.exp(x) / (math.exp(x) - 1.0)
def code(x): return 1.0 / (math.exp(-x) * math.expm1(x))
function code(x) return Float64(exp(x) / Float64(exp(x) - 1.0)) end
function code(x) return Float64(1.0 / Float64(exp(Float64(-x)) * expm1(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)], $MachinePrecision] * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{e^{x}}{e^{x} - 1}
\frac{1}{e^{-x} \cdot \mathsf{expm1}\left(x\right)}
Results
| Original | 64.31% |
|---|---|
| Target | 63.7% |
| Herbie | 0.64% |
Initial program 64.31
Simplified0.63
[Start]64.31 | \[ \frac{e^{x}}{e^{x} - 1}
\] |
|---|---|
expm1-def [=>]0.63 | \[ \frac{e^{x}}{\color{blue}{\mathsf{expm1}\left(x\right)}}
\] |
Applied egg-rr0.69
Applied egg-rr67.29
Simplified0.64
[Start]67.29 | \[ \frac{\frac{1}{\sqrt{\mathsf{expm1}\left(x\right)}}}{\frac{1}{\frac{e^{x}}{\sqrt{\mathsf{expm1}\left(x\right)}}}}
\] |
|---|---|
associate-/l/ [=>]67.24 | \[ \color{blue}{\frac{1}{\frac{1}{\frac{e^{x}}{\sqrt{\mathsf{expm1}\left(x\right)}}} \cdot \sqrt{\mathsf{expm1}\left(x\right)}}}
\] |
associate-/r/ [=>]67.22 | \[ \frac{1}{\color{blue}{\left(\frac{1}{e^{x}} \cdot \sqrt{\mathsf{expm1}\left(x\right)}\right)} \cdot \sqrt{\mathsf{expm1}\left(x\right)}}
\] |
associate-*l* [=>]67.21 | \[ \frac{1}{\color{blue}{\frac{1}{e^{x}} \cdot \left(\sqrt{\mathsf{expm1}\left(x\right)} \cdot \sqrt{\mathsf{expm1}\left(x\right)}\right)}}
\] |
rec-exp [=>]67.21 | \[ \frac{1}{\color{blue}{e^{-x}} \cdot \left(\sqrt{\mathsf{expm1}\left(x\right)} \cdot \sqrt{\mathsf{expm1}\left(x\right)}\right)}
\] |
rem-square-sqrt [=>]0.64 | \[ \frac{1}{e^{-x} \cdot \color{blue}{\mathsf{expm1}\left(x\right)}}
\] |
Final simplification0.64
| Alternative 1 | |
|---|---|
| Error | 0.63% |
| Cost | 12992 |
| Alternative 2 | |
|---|---|
| Error | 1.33% |
| Cost | 7104 |
| Alternative 3 | |
|---|---|
| Error | 0.88% |
| Cost | 6916 |
| Alternative 4 | |
|---|---|
| Error | 2.44% |
| Cost | 6720 |
| Alternative 5 | |
|---|---|
| Error | 2.44% |
| Cost | 6592 |
| Alternative 6 | |
|---|---|
| Error | 33.48% |
| Cost | 576 |
| Alternative 7 | |
|---|---|
| Error | 33.56% |
| Cost | 320 |
| Alternative 8 | |
|---|---|
| Error | 33.57% |
| Cost | 192 |
herbie shell --seed 2023102
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))