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

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.3
Target39.5
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.00010133771583352076

    1. Initial program 0.1

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied add-log-exp0.1

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

    if -0.00010133771583352076 < x

    1. Initial program 60.2

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

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

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

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

Reproduce

herbie shell --seed 2019022 
(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: 16.0s)Debug log

sample73.0ms

Algorithm
intervals
Results
32.0ms82×body1280valid
15.0ms51×body640valid
9.0ms176×body80valid
5.0ms27×body320valid
1.0msbody160valid

simplify7.0ms

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 40.8b

localize8.0ms

Local error

Found 2 expressions with local error:

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

rewrite10.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
7.0ms
(/ (- (exp x) 1) x)
3.0ms
(- (exp x) 1)

series61.0ms

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

simplify239.0ms

Counts
13 → 35
Calls
13 calls:
Slowest
73.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
65.0ms
(* -1 (/ (- 1 (exp x)) x))
27.0ms
(- (* (exp x) (exp x)) (* 1 1))
19.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
17.0ms
(- (pow (exp x) 3) (pow 1 3))

prune185.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

1.9b
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)
0.3b
(* x 1/6)
0.1b
(* (+ (* x 1/6) 1/2) (* x x))
0.0b
(+ (* x 1/6) 1/2)

rewrite15.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
add-log-exp
associate-/l*
flip-+
associate-*l*
flip3-+
associate-/l/
*-commutative
associate-*l/
div-inv
cbrt-unprod
prod-exp
pow-prod-down
associate-*r*
frac-2neg
clear-num
+-commutative
Counts
4 → 50
Calls
4 calls:
Slowest
8.0ms
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)
5.0ms
(* (+ (* x 1/6) 1/2) (* x x))
1.0ms
(+ (* x 1/6) 1/2)
0.0ms
(* x 1/6)

series80.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
36.0ms
(* (+ (* x 1/6) 1/2) (* x x))
22.0ms
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)
14.0ms
(+ (* x 1/6) 1/2)
7.0ms
(* x 1/6)

simplify2.3s

Counts
23 → 62
Calls
23 calls:
Slowest
500.0ms
(* (- (* (* x 1/6) (* x 1/6)) (* 1/2 1/2)) (* x x))
487.0ms
(+ (pow x 3) (pow (* (+ (* x 1/6) 1/2) (* x x)) 3))
394.0ms
(* (+ (pow (* x 1/6) 3) (pow 1/2 3)) (* x x))
381.0ms
(- (* x x) (* (* (+ (* x 1/6) 1/2) (* x x)) (* (+ (* x 1/6) 1/2) (* x x))))
113.0ms
(sqrt (+ x (* (+ (* x 1/6) 1/2) (* x x))))

prune413.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.0b

localize13.0ms

Local error

Found 4 expressions with local error:

10.3b
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
10.3b
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
1.9b
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)
1.9b
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)

rewrite40.0ms

Algorithm
rewrite-expression-head
Rules
10×add-sqr-sqrt
sqrt-prod
add-cube-cbrt
*-un-lft-identity
associate-/l*
associate-/l/
add-log-exp
div-inv
add-exp-log
add-cbrt-cube
pow1
flip-+
sqrt-div
pow1/2
flip3-+
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 58
Calls
4 calls:
Slowest
20.0ms
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)
17.0ms
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)
1.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
1.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))

series151.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
62.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
40.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
31.0ms
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)
18.0ms
(/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x)

simplify4.6s

Counts
32 → 70
Calls
32 calls:
Slowest
920.0ms
(+ (pow x 3) (pow (* (+ (* x 1/6) 1/2) (* x x)) 3))
554.0ms
(+ (pow x 3) (pow (* (+ (* x 1/6) 1/2) (* x x)) 3))
356.0ms
(- (* x x) (* (* (+ (* x 1/6) 1/2) (* x x)) (* (+ (* x 1/6) 1/2) (* x x))))
355.0ms
(- (* x x) (* (* (+ (* x 1/6) 1/2) (* x x)) (* (+ (* x 1/6) 1/2) (* x x))))
234.0ms
(- (* 1/32 (/ 1 (* x (pow (sqrt 1/6) 3)))) (+ (* 1/2 (/ 1 (* x (sqrt 1/6)))) (+ (* 1/4 (/ 1 (sqrt 1/6))) (* x (sqrt 1/6)))))

prune670.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize32.0ms

Local error

Found 4 expressions with local error:

10.3b
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
10.3b
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
10.3b
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
10.3b
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))

rewrite7.0ms

Algorithm
rewrite-expression-head
Rules
16×sqrt-prod
12×add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
div-inv
add-exp-log
sqrt-div
pow1/2
add-cbrt-cube
rem-sqrt-square
pow1
Counts
4 → 56
Calls
4 calls:
Slowest
2.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
1.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
1.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
1.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))

series224.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
64.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
58.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
53.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))
48.0ms
(sqrt (/ (+ x (* (+ (* x 1/6) 1/2) (* x x))) x))

simplify3.6s

Counts
36 → 68
Calls
36 calls:
Slowest
253.0ms
(- (+ (* 1/2 (/ 1 (* x (sqrt 1/6)))) (+ (* 1/4 (/ 1 (sqrt 1/6))) (* x (sqrt 1/6)))) (* 1/32 (/ 1 (* x (pow (sqrt 1/6) 3)))))
225.0ms
(- (* 1/32 (/ 1 (* x (pow (sqrt 1/6) 3)))) (+ (* 1/2 (/ 1 (* x (sqrt 1/6)))) (+ (* 1/4 (/ 1 (sqrt 1/6))) (* x (sqrt 1/6)))))
222.0ms
(- (+ (* 1/2 (/ 1 (* x (sqrt 1/6)))) (+ (* 1/4 (/ 1 (sqrt 1/6))) (* x (sqrt 1/6)))) (* 1/32 (/ 1 (* x (pow (sqrt 1/6) 3)))))
214.0ms
(- (* 1/32 (/ 1 (* x (pow (sqrt 1/6) 3)))) (+ (* 1/2 (/ 1 (* x (sqrt 1/6)))) (+ (* 1/4 (/ 1 (sqrt 1/6))) (* x (sqrt 1/6)))))
212.0ms
(- (* 1/32 (/ 1 (* x (pow (sqrt 1/6) 3)))) (+ (* 1/2 (/ 1 (* x (sqrt 1/6)))) (+ (* 1/4 (/ 1 (sqrt 1/6))) (* x (sqrt 1/6)))))

prune745.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

regimes106.0ms

Accuracy

98.6% (0.3b remaining)

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

bsearch57.0ms

end0.0ms

sample2.3s

Algorithm
intervals
Results
1.1s2268×body1280valid
544.0ms1694×body640valid
337.0ms5437×body80valid
175.0ms889×body320valid
47.0ms383×body160valid