Average Error: 39.6 → 0.3
Time: 3.5s
Precision: binary64
Cost: 39553
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0012877939694746442:\\ \;\;\;\;\frac{\sqrt[3]{e^{x} + -1} \cdot \left(\sqrt[3]{e^{x} + -1} \cdot \sqrt[3]{e^{x} + -1}\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)\\ \end{array}\]
\frac{e^{x} - 1}{x}
\begin{array}{l}
\mathbf{if}\;x \leq -0.0012877939694746442:\\
\;\;\;\;\frac{\sqrt[3]{e^{x} + -1} \cdot \left(\sqrt[3]{e^{x} + -1} \cdot \sqrt[3]{e^{x} + -1}\right)}{x}\\

\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)\\

\end{array}
(FPCore (x) :precision binary64 (/ (- (exp x) 1.0) x))
(FPCore (x)
 :precision binary64
 (if (<= x -0.0012877939694746442)
   (/
    (*
     (cbrt (+ (exp x) -1.0))
     (* (cbrt (+ (exp x) -1.0)) (cbrt (+ (exp x) -1.0))))
    x)
   (+
    1.0
    (* x (+ 0.5 (* x (+ 0.16666666666666666 (* x 0.041666666666666664))))))))
double code(double x) {
	return (exp(x) - 1.0) / x;
}
double code(double x) {
	double tmp;
	if (x <= -0.0012877939694746442) {
		tmp = (cbrt(exp(x) + -1.0) * (cbrt(exp(x) + -1.0) * cbrt(exp(x) + -1.0))) / x;
	} else {
		tmp = 1.0 + (x * (0.5 + (x * (0.16666666666666666 + (x * 0.041666666666666664)))));
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.6
Target40.1
Herbie0.3
\[\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}\]

Alternatives

Alternative 1
Error40.1
Cost45632
\[\frac{1 + \sqrt{e^{x}}}{\sqrt[3]{x} \cdot \sqrt[3]{x}} \cdot \frac{\sqrt{e^{x}} + -1}{\sqrt[3]{x}}\]
Alternative 2
Error39.6
Cost39232
\[\frac{\sqrt[3]{e^{x} + -1} \cdot \left(\sqrt[3]{e^{x} + -1} \cdot \sqrt[3]{e^{x} + -1}\right)}{x}\]
Alternative 3
Error39.7
Cost26496
\[\frac{\frac{-1 + {\left(e^{x}\right)}^{3}}{1 + e^{x} \cdot \left(1 + e^{x}\right)}}{x}\]
Alternative 4
Error39.8
Cost26304
\[\sqrt{\frac{e^{x} + -1}{x}} \cdot \sqrt{\frac{e^{x} + -1}{x}}\]
Alternative 5
Error39.6
Cost26176
\[\frac{\left(1 + \sqrt{e^{x}}\right) \cdot \left(\sqrt{e^{x}} + -1\right)}{x}\]
Alternative 6
Error39.7
Cost19648
\[\log \left(e^{e^{x} + -1}\right) \cdot \frac{1}{x}\]
Alternative 7
Error39.7
Cost19584
\[\frac{\sqrt[3]{{\left(e^{x} + -1\right)}^{3}}}{x}\]
Alternative 8
Error39.7
Cost19520
\[\frac{\log \left(e^{e^{x} + -1}\right)}{x}\]
Alternative 9
Error39.3
Cost6848
\[\frac{e^{x}}{x} - \frac{1}{x}\]
Alternative 10
Error39.6
Cost6720
\[\frac{e^{x} + -1}{x}\]
Alternative 11
Error21.9
Cost1088
\[\frac{x + \left(x \cdot x\right) \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)}{x}\]
Alternative 12
Error21.7
Cost832
\[\frac{x + \left(x \cdot x\right) \cdot \left(0.5 + x \cdot 0.16666666666666666\right)}{x}\]
Alternative 13
Error21.9
Cost832
\[1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)\]
Alternative 14
Error22.0
Cost576
\[\frac{x + \left(x \cdot x\right) \cdot 0.5}{x}\]
Alternative 15
Error21.6
Cost576
\[1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\]
Alternative 16
Error21.9
Cost320
\[1 + x \cdot 0.5\]
Alternative 17
Error21.5
Cost192
\[\frac{x}{x}\]
Alternative 18
Error21.5
Cost64
\[1\]
Alternative 19
Error61.5
Cost64
\[0\]
Alternative 20
Error62.9
Cost64
\[-1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if x < -0.00128779396947464419

    1. Initial program 0.0

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary64_34360.0

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

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

    if -0.00128779396947464419 < x

    1. Initial program 60.1

      \[\frac{e^{x} - 1}{x}\]
    2. Taylor expanded around 0 0.4

      \[\leadsto \color{blue}{0.5 \cdot x + \left(0.16666666666666666 \cdot {x}^{2} + \left(0.041666666666666664 \cdot {x}^{3} + 1\right)\right)}\]
    3. Simplified0.4

      \[\leadsto \color{blue}{1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)}\]
    4. Simplified0.4

      \[\leadsto \color{blue}{1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.0012877939694746442:\\ \;\;\;\;\frac{\sqrt[3]{e^{x} + -1} \cdot \left(\sqrt[3]{e^{x} + -1} \cdot \sqrt[3]{e^{x} + -1}\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)\\ \end{array}\]

Reproduce

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