?

Average Error: 65.38% → 0.72%
Time: 6.1s
Precision: binary64
Cost: 19456

?

\[\frac{e^{x}}{e^{x} - 1} \]
\[{\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1} \]
(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x) :precision binary64 (pow (/ (expm1 x) (exp x)) -1.0))
double code(double x) {
	return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
	return pow((expm1(x) / exp(x)), -1.0);
}
public static double code(double x) {
	return Math.exp(x) / (Math.exp(x) - 1.0);
}
public static double code(double x) {
	return Math.pow((Math.expm1(x) / Math.exp(x)), -1.0);
}
def code(x):
	return math.exp(x) / (math.exp(x) - 1.0)
def code(x):
	return math.pow((math.expm1(x) / math.exp(x)), -1.0)
function code(x)
	return Float64(exp(x) / Float64(exp(x) - 1.0))
end
function code(x)
	return Float64(expm1(x) / exp(x)) ^ -1.0
end
code[x_] := N[(N[Exp[x], $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[Power[N[(N[(Exp[x] - 1), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\frac{e^{x}}{e^{x} - 1}
{\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original65.38%
Target64.69%
Herbie0.72%
\[\frac{1}{1 - e^{-x}} \]

Derivation?

  1. Initial program 65.38

    \[\frac{e^{x}}{e^{x} - 1} \]
  2. Simplified0.72

    \[\leadsto \color{blue}{\frac{e^{x}}{\mathsf{expm1}\left(x\right)}} \]
    Proof

    [Start]65.38

    \[ \frac{e^{x}}{e^{x} - 1} \]

    expm1-def [=>]0.72

    \[ \frac{e^{x}}{\color{blue}{\mathsf{expm1}\left(x\right)}} \]
  3. Applied egg-rr0.72

    \[\leadsto \color{blue}{{\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1}} \]
  4. Final simplification0.72

    \[\leadsto {\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1} \]

Alternatives

Alternative 1
Error0.72%
Cost12992
\[\frac{e^{x}}{\mathsf{expm1}\left(x\right)} \]
Alternative 2
Error0.84%
Cost6916
\[\begin{array}{l} \mathbf{if}\;x \leq -0.00175:\\ \;\;\;\;\frac{1}{1 - e^{-x}}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot 0.08333333333333333 + \frac{1}{x}\right)\\ \end{array} \]
Alternative 3
Error32.71%
Cost192
\[\frac{1}{x} \]

Error

Reproduce?

herbie shell --seed 2023089 
(FPCore (x)
  :name "expq2 (section 3.11)"
  :precision binary64

  :herbie-target
  (/ 1.0 (- 1.0 (exp (- x))))

  (/ (exp x) (- (exp x) 1.0)))