?

Average Accuracy: 52.0% → 100.0%
Time: 2.5s
Precision: binary64
Cost: 19392

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original52.0%
Target51.5%
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 50.0%

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

    \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(x\right)}{x}} \]
    Step-by-step derivation

    [Start]50.0

    \[ \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}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{expm1}\left(x\right)}{x}\right)\right)} \]
    Step-by-step derivation

    [Start]100.0

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

    expm1-log1p-u [=>]100.0

    \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{expm1}\left(x\right)}{x}\right)\right)} \]
  4. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy100.0%
Cost6592
\[\frac{\mathsf{expm1}\left(x\right)}{x} \]
Alternative 2
Accuracy52.5%
Cost320
\[x \cdot 0.5 + 1 \]
Alternative 3
Accuracy52.3%
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023164 
(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))