Average Error: 39.3 → 0.1
Time: 1.2m
Precision: 64
Internal Precision: 1344
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot \left(x \cdot \frac{1}{6}\right) + \left(\frac{1}{2} \cdot x + 1\right)\right) \cdot \left(\left(\frac{1}{2} \cdot x - 1\right) - x \cdot \left(x \cdot \frac{1}{6}\right)\right)}{\sqrt[3]{\left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right) \cdot \left(\left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right) \cdot \left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right)\right)}} \le 0.9992327618685036:\\ \;\;\;\;\frac{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{e^{x} \cdot e^{x} + \left(1 + e^{x}\right)}}{x}\\ \mathbf{elif}\;\frac{\left(x \cdot \left(x \cdot \frac{1}{6}\right) + \left(\frac{1}{2} \cdot x + 1\right)\right) \cdot \left(\left(\frac{1}{2} \cdot x - 1\right) - x \cdot \left(x \cdot \frac{1}{6}\right)\right)}{\sqrt[3]{\left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right) \cdot \left(\left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right) \cdot \left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right)\right)}} \le 1.00028036142059:\\ \;\;\;\;\log \left(e^{\left(x \cdot x\right) \cdot \frac{1}{6} + \left(\frac{1}{2} \cdot x + 1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}{x}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.3
Target38.4
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;x \lt 1 \land x \gt -1:\\ \;\;\;\;\frac{e^{x} - 1}{\log \left(e^{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x} - 1}{x}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* (+ (* (* x 1/6) x) (+ 1 (* 1/2 x))) (- (- (* 1/2 x) 1) (* (* x 1/6) x))) (cbrt (* (* (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)) (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))) (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))))) < 0.9992327618685036

    1. Initial program 0.3

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied flip3--0.3

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

    if 0.9992327618685036 < (/ (* (+ (* (* x 1/6) x) (+ 1 (* 1/2 x))) (- (- (* 1/2 x) 1) (* (* x 1/6) x))) (cbrt (* (* (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)) (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))) (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))))) < 1.00028036142059

    1. Initial program 60.4

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)}\]
    3. Using strategy rm
    4. Applied add-log-exp0.1

      \[\leadsto \frac{1}{2} \cdot x + \color{blue}{\log \left(e^{\frac{1}{6} \cdot {x}^{2} + 1}\right)}\]
    5. Applied add-log-exp0.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{1}{2} \cdot x}\right)} + \log \left(e^{\frac{1}{6} \cdot {x}^{2} + 1}\right)\]
    6. Applied sum-log0.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{1}{2} \cdot x} \cdot e^{\frac{1}{6} \cdot {x}^{2} + 1}\right)}\]
    7. Simplified0.1

      \[\leadsto \log \color{blue}{\left(e^{\left(1 + \frac{1}{2} \cdot x\right) + \left(x \cdot x\right) \cdot \frac{1}{6}}\right)}\]

    if 1.00028036142059 < (/ (* (+ (* (* x 1/6) x) (+ 1 (* 1/2 x))) (- (- (* 1/2 x) 1) (* (* x 1/6) x))) (cbrt (* (* (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)) (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))) (- (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))))

    1. Initial program 0.0

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

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

      \[\leadsto \frac{\color{blue}{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}}{x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot \left(x \cdot \frac{1}{6}\right) + \left(\frac{1}{2} \cdot x + 1\right)\right) \cdot \left(\left(\frac{1}{2} \cdot x - 1\right) - x \cdot \left(x \cdot \frac{1}{6}\right)\right)}{\sqrt[3]{\left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right) \cdot \left(\left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right) \cdot \left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right)\right)}} \le 0.9992327618685036:\\ \;\;\;\;\frac{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{e^{x} \cdot e^{x} + \left(1 + e^{x}\right)}}{x}\\ \mathbf{elif}\;\frac{\left(x \cdot \left(x \cdot \frac{1}{6}\right) + \left(\frac{1}{2} \cdot x + 1\right)\right) \cdot \left(\left(\frac{1}{2} \cdot x - 1\right) - x \cdot \left(x \cdot \frac{1}{6}\right)\right)}{\sqrt[3]{\left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right) \cdot \left(\left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right) \cdot \left(\frac{1}{2} \cdot x - \left(1 + \frac{1}{6} \cdot {x}^{2}\right)\right)\right)}} \le 1.00028036142059:\\ \;\;\;\;\log \left(e^{\left(x \cdot x\right) \cdot \frac{1}{6} + \left(\frac{1}{2} \cdot x + 1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}{x}\\ \end{array}\]

Runtime

Time bar (total: 1.2m)Debug logProfile

herbie shell --seed 2018217 
(FPCore (x)
  :name "Kahan's exp quotient"

  :herbie-target
  (if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))

  (/ (- (exp x) 1) x))