Average Error: 40.7 → 0.3
Time: 5.9s
Precision: 64
Internal Precision: 128
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0001541232739399493:\\ \;\;\;\;\frac{e^{x} + -1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot x + \left({x}^{2} \cdot \frac{1}{6} + 1\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.7
Target39.8
Herbie0.3
\[\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 2 regimes
  2. if x < -0.0001541232739399493

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\frac{e^{x}}{x} - \frac{1}{x}}\]
    4. Taylor expanded around -inf 0.1

      \[\leadsto \color{blue}{-1 \cdot \frac{1 - e^{x}}{x}}\]
    5. Simplified0.1

      \[\leadsto \color{blue}{\frac{e^{x} + -1}{x}}\]

    if -0.0001541232739399493 < x

    1. Initial program 60.3

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

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

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

Reproduce

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

Details

Time bar (total: 5.4s)Debug log

sample103.0ms

Algorithm
intervals

simplify15.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
14.0ms
(/ (- (exp x) 1) x)

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 39.9b

localize16.0ms

Local error

Found 2 expressions with local error:

3.6b
(- (exp x) 1)
0.0b
(/ (- (exp x) 1) x)

rewrite20.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
associate-/l*
add-cube-cbrt
*-un-lft-identity
associate-/l/
add-log-exp
flip--
add-exp-log
difference-of-sqr-1
add-cbrt-cube
flip3--
pow1
div-inv
div-sub
frac-2neg
sub-neg
clear-num
Counts
2 → 29
Calls
2 calls:
Slowest
13.0ms
(/ (- (exp x) 1) x)
6.0ms
(- (exp x) 1)

series54.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
35.0ms
(/ (- (exp x) 1) x)
19.0ms
(- (exp x) 1)

simplify327.0ms

Counts
13 → 35
Calls
13 calls:
Slowest
126.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
72.0ms
(* -1 (/ (- 1 (exp x)) x))
40.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
15.0ms
(/ (- (exp x) 1) x)
15.0ms
(- (* (exp x) (exp x)) (* 1 1))

prune262.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 2 expressions with local error:

0.2b
(* 1/6 (pow x 2))
0.0b
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
associate-*r*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
pow1
unpow2
flip-+
*-commutative
flip3-+
sum-log
associate-+r+
+-commutative
Counts
2 → 24
Calls
2 calls:
Slowest
10.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
3.0ms
(* 1/6 (pow x 2))

series31.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
19.0ms
(* 1/6 (pow x 2))
11.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

simplify136.0ms

Counts
10 → 30
Calls
10 calls:
Slowest
45.0ms
(* (exp (* 1/2 x)) (exp (+ (* 1/6 (pow x 2)) 1)))
35.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
20.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
19.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
4.0ms
(* 1/6 (pow x 2))

prune250.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 2 expressions with local error:

3.2b
(- (/ (exp x) x) (/ 1 x))
0.0b
(/ (exp x) x)

rewrite14.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
div-inv
add-sqr-sqrt
add-log-exp
associate-/l*
add-cube-cbrt
distribute-lft-out--
add-exp-log
distribute-rgt-out--
add-cbrt-cube
pow1
difference-of-squares
sub-div
flip--
frac-sub
diff-log
flip3--
frac-2neg
sub-neg
clear-num
Counts
2 → 32
Calls
2 calls:
Slowest
9.0ms
(- (/ (exp x) x) (/ 1 x))
4.0ms
(/ (exp x) x)

series34.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
21.0ms
(- (/ (exp x) x) (/ 1 x))
13.0ms
(/ (exp x) x)

simplify184.0ms

Counts
20 → 38
Calls
20 calls:
Slowest
65.0ms
(* -1 (/ (- 1 (exp x)) x))
22.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
17.0ms
(+ (* 1/2 x) (+ (/ 1 x) 1))
13.0ms
(/ (exp (/ (exp x) x)) (exp (/ 1 x)))
9.0ms
(- (/ (exp x) x) (/ 1 x))

prune318.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize8.0ms

Local error

Found 2 expressions with local error:

3.6b
(+ (exp x) -1)
0.0b
(/ (+ (exp x) -1) x)

rewrite11.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
associate-/l*
add-cube-cbrt
*-un-lft-identity
associate-/l/
add-log-exp
flip-+
add-exp-log
add-cbrt-cube
flip3-+
difference-of-sqr--1
pow1
div-inv
frac-2neg
clear-num
+-commutative
Counts
2 → 27
Calls
2 calls:
Slowest
9.0ms
(/ (+ (exp x) -1) x)
2.0ms
(+ (exp x) -1)

series32.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
21.0ms
(/ (+ (exp x) -1) x)
11.0ms
(+ (exp x) -1)

simplify327.0ms

Counts
12 → 33
Calls
12 calls:
Slowest
131.0ms
(* -1 (/ (- 1 (exp x)) x))
95.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
30.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
25.0ms
(- (* (exp x) (exp x)) (* -1 -1))
17.0ms
(/ (- (exp x) 1) x)

prune211.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

regimes55.0ms

Accuracy

98.9% (0.2b remaining)

Error of 0.3b against oracle of 0.0b and baseline of 20.3b

bsearch43.0ms

end0.0ms

sample2.9s

Algorithm
intervals