Average Error: 39.9 → 0.3
Time: 4.8s
Precision: binary64
Cost: 26497
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0014603342715462273:\\ \;\;\;\;\left(1 + \sqrt{e^{x}}\right) \cdot \frac{\sqrt{e^{x}} + -1}{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.0014603342715462273:\\
\;\;\;\;\left(1 + \sqrt{e^{x}}\right) \cdot \frac{\sqrt{e^{x}} + -1}{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.0014603342715462273)
   (* (+ 1.0 (sqrt (exp x))) (/ (+ (sqrt (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.0014603342715462273) {
		tmp = (1.0 + sqrt(exp(x))) * ((sqrt(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.9
Target40.3
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
Error60.5
Cost71488
\[\frac{\sqrt[3]{e^{x} + -1} \cdot \sqrt[3]{e^{x} + -1}}{\sqrt[3]{x} \cdot \sqrt[3]{x}} \cdot \frac{\sqrt[3]{e^{x} + -1}}{\log \left(e^{\sqrt[3]{x}}\right)}\]
Alternative 2
Error40.3
Cost58688
\[\frac{\sqrt[3]{e^{x} + -1} \cdot \sqrt[3]{e^{x} + -1}}{\sqrt[3]{x} \cdot \sqrt[3]{x}} \cdot \frac{\sqrt[3]{e^{x} + -1}}{\sqrt[3]{x}}\]
Alternative 3
Error40.3
Cost45632
\[\frac{1 + \sqrt{e^{x}}}{\sqrt[3]{x} \cdot \sqrt[3]{x}} \cdot \frac{\sqrt{e^{x}} + -1}{\sqrt[3]{x}}\]
Alternative 4
Error39.9
Cost39232
\[\frac{\sqrt[3]{e^{x} + -1} \cdot \left(\sqrt[3]{e^{x} + -1} \cdot \sqrt[3]{e^{x} + -1}\right)}{x}\]
Alternative 5
Error39.9
Cost26496
\[\frac{\frac{-1 + {\left(e^{x}\right)}^{3}}{1 + e^{x} \cdot \left(e^{x} + 1\right)}}{x}\]
Alternative 6
Error40.3
Cost26304
\[\frac{1}{\sqrt[3]{x} \cdot \sqrt[3]{x}} \cdot \frac{e^{x} + -1}{\sqrt[3]{x}}\]
Alternative 7
Error39.9
Cost26176
\[\left(1 + \sqrt{e^{x}}\right) \cdot \frac{\sqrt{e^{x}} + -1}{x}\]
Alternative 8
Error39.9
Cost26176
\[\frac{\left(1 + \sqrt{e^{x}}\right) \cdot \left(\sqrt{e^{x}} + -1\right)}{x}\]
Alternative 9
Error61.8
Cost26176
\[\frac{\sqrt{e^{x} + -1} \cdot \sqrt{e^{x} + -1}}{x}\]
Alternative 10
Error53.1
Cost19584
\[\sqrt[3]{{\left(\frac{e^{x} + -1}{x}\right)}^{3}}\]
Alternative 11
Error39.9
Cost19584
\[\frac{\sqrt[3]{{\left(e^{x} + -1\right)}^{3}}}{x}\]
Alternative 12
Error61.8
Cost19520
\[\frac{e^{\log \left(e^{x} + -1\right)}}{x}\]
Alternative 13
Error40.0
Cost19520
\[\frac{\log \left(e^{e^{x} + -1}\right)}{x}\]
Alternative 14
Error39.6
Cost6848
\[\frac{e^{x}}{x} - \frac{1}{x}\]
Alternative 15
Error39.9
Cost6720
\[\frac{e^{x} + -1}{x}\]
Alternative 16
Error21.6
Cost1088
\[\frac{x + \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right) \cdot \left(x \cdot x\right)}{x}\]
Alternative 17
Error21.5
Cost832
\[1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)\]
Alternative 18
Error21.3
Cost832
\[\frac{x + \left(x \cdot x\right) \cdot \left(0.5 + x \cdot 0.16666666666666666\right)}{x}\]
Alternative 19
Error21.2
Cost576
\[1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\]
Alternative 20
Error21.7
Cost576
\[\frac{x + 0.5 \cdot \left(x \cdot x\right)}{x}\]
Alternative 21
Error21.5
Cost320
\[1 + x \cdot 0.5\]
Alternative 22
Error21.2
Cost192
\[\frac{x}{x}\]
Alternative 23
Error21.2
Cost64
\[1\]
Alternative 24
Error61.5
Cost64
\[0\]
Alternative 25
Error62.9
Cost64
\[-1\]

Error

Derivation

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

    1. Initial program 0.0

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary64_21240.0

      \[\leadsto \frac{e^{x} - 1}{\color{blue}{1 \cdot x}}\]
    4. Applied add-sqr-sqrt_binary64_21460.0

      \[\leadsto \frac{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}} - 1}{1 \cdot x}\]
    5. Applied difference-of-sqr-1_binary64_20940.0

      \[\leadsto \frac{\color{blue}{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}}{1 \cdot x}\]
    6. Applied times-frac_binary64_21300.0

      \[\leadsto \color{blue}{\frac{\sqrt{e^{x}} + 1}{1} \cdot \frac{\sqrt{e^{x}} - 1}{x}}\]
    7. Simplified0.0

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

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

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

    if -0.00146033427154622733 < x

    1. Initial program 60.0

      \[\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.0014603342715462273:\\ \;\;\;\;\left(1 + \sqrt{e^{x}}\right) \cdot \frac{\sqrt{e^{x}} + -1}{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 2021022 
(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))