?

Average Error: 41.7 → 0.0
Time: 2.6s
Precision: binary64
Cost: 13056

?

\[\frac{e^{x}}{e^{x} - 1} \]
\[{\left(-\mathsf{expm1}\left(-x\right)\right)}^{-1} \]
(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x) :precision binary64 (pow (- (expm1 (- x))) -1.0))
double code(double x) {
	return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
	return pow(-expm1(-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), -1.0);
}
def code(x):
	return math.exp(x) / (math.exp(x) - 1.0)
def code(x):
	return math.pow(-math.expm1(-x), -1.0)
function code(x)
	return Float64(exp(x) / Float64(exp(x) - 1.0))
end
function code(x)
	return Float64(-expm1(Float64(-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[(Exp[(-x)] - 1), $MachinePrecision]), -1.0], $MachinePrecision]
\frac{e^{x}}{e^{x} - 1}
{\left(-\mathsf{expm1}\left(-x\right)\right)}^{-1}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original41.7
Target41.2
Herbie0.0
\[\frac{1}{1 - e^{-x}} \]

Derivation?

  1. Initial program 41.7

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

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

    [Start]41.7

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

    expm1-def [=>]0.5

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

    \[\leadsto \color{blue}{{\left(\frac{\mathsf{expm1}\left(x\right)}{e^{x}}\right)}^{-1}} \]
  4. Taylor expanded in x around inf 41.7

    \[\leadsto {\color{blue}{\left(\frac{e^{x} - 1}{e^{x}}\right)}}^{-1} \]
  5. Simplified0.0

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

    [Start]41.7

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

    expm1-def [=>]0.5

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

    *-lft-identity [<=]0.5

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

    metadata-eval [<=]0.5

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

    times-frac [<=]0.5

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

    neg-mul-1 [<=]0.5

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

    associate-*r/ [<=]0.5

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

    neg-mul-1 [<=]0.5

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

    expm1-def [<=]41.7

    \[ {\left(-\frac{\color{blue}{e^{x} - 1}}{-e^{x}}\right)}^{-1} \]

    div-sub [=>]62.3

    \[ {\left(-\color{blue}{\left(\frac{e^{x}}{-e^{x}} - \frac{1}{-e^{x}}\right)}\right)}^{-1} \]

    neg-mul-1 [=>]62.3

    \[ {\left(-\left(\frac{e^{x}}{-e^{x}} - \frac{1}{\color{blue}{-1 \cdot e^{x}}}\right)\right)}^{-1} \]

    associate-/r* [=>]62.3

    \[ {\left(-\left(\frac{e^{x}}{-e^{x}} - \color{blue}{\frac{\frac{1}{-1}}{e^{x}}}\right)\right)}^{-1} \]

    metadata-eval [=>]62.3

    \[ {\left(-\left(\frac{e^{x}}{-e^{x}} - \frac{\color{blue}{-1}}{e^{x}}\right)\right)}^{-1} \]

    metadata-eval [<=]62.3

    \[ {\left(-\left(\frac{e^{x}}{-e^{x}} - \frac{\color{blue}{-1}}{e^{x}}\right)\right)}^{-1} \]

    distribute-neg-frac [<=]62.3

    \[ {\left(-\left(\frac{e^{x}}{-e^{x}} - \color{blue}{\left(-\frac{1}{e^{x}}\right)}\right)\right)}^{-1} \]

    exp-neg [<=]62.2

    \[ {\left(-\left(\frac{e^{x}}{-e^{x}} - \left(-\color{blue}{e^{-x}}\right)\right)\right)}^{-1} \]

    neg-sub0 [=>]62.2

    \[ {\left(-\left(\frac{e^{x}}{-e^{x}} - \color{blue}{\left(0 - e^{-x}\right)}\right)\right)}^{-1} \]

    associate--r- [=>]62.2

    \[ {\left(-\color{blue}{\left(\left(\frac{e^{x}}{-e^{x}} - 0\right) + e^{-x}\right)}\right)}^{-1} \]
  6. Final simplification0.0

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

Alternatives

Alternative 1
Error0.5
Cost12992
\[\frac{e^{x}}{\mathsf{expm1}\left(x\right)} \]
Alternative 2
Error21.1
Cost192
\[\frac{1}{x} \]

Error

Reproduce?

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

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

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