?

Average Error: 36.6% → 100.0%
Time: 3.1s
Precision: binary64
Cost: 6720.00

?

\[\frac{e^{x} - 1}{x} \]
\[\frac{1}{\frac{x}{\mathsf{expm1}\left(x\right)}} \]
(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)}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original36.6%
Target36.1%
Herbie100.0%
\[\begin{array}{l} \mathbf{if}\;x < 1 \land x > -1:\\ \;\;\;\;\frac{e^{x} - 1}{\log \left(e^{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x} - 1}{x}\\ \end{array} \]

Derivation?

  1. Initial program 36.6

    \[\frac{e^{x} - 1}{x} \]
  2. Simplified100.0

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

    [Start]36.6

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

    expm1-def [=>]100.0

    \[ \frac{\color{blue}{\mathsf{expm1}\left(x\right)}}{x} \]
  3. Applied egg-rr100.0

    \[\leadsto \color{blue}{{\left(\frac{x}{\mathsf{expm1}\left(x\right)}\right)}^{-1}} \]
  4. Applied egg-rr100.0

    \[\leadsto \color{blue}{\frac{1}{\frac{x}{\mathsf{expm1}\left(x\right)}}} \]
  5. Final simplification100.0

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

Alternatives

Alternative 1
Error100.0%
Cost6592.00
\[\frac{\mathsf{expm1}\left(x\right)}{x} \]
Alternative 2
Error73.0%
Cost452.00
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;\frac{-2}{x}\\ \mathbf{else}:\\ \;\;\;\;1 + x \cdot 0.5\\ \end{array} \]
Alternative 3
Error73.0%
Cost448.00
\[\frac{1}{1 + x \cdot -0.5} \]
Alternative 4
Error72.2%
Cost324.00
\[\begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\frac{-2}{x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error68.0%
Cost64.00
\[1 \]

Error

Reproduce?

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))