Average Error: 39.8 → 0.7
Time: 23.5s
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{e^{x}}{e^{x} - 1} \le 110.28947505214752:\\ \;\;\;\;\frac{e^{x}}{e^{x} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{12} \cdot x + \left(\frac{1}{2} + \frac{1}{x}\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.8
Target39.5
Herbie0.7
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (exp x) (- (exp x) 1)) < 110.28947505214752

    1. Initial program 1.1

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

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

    if 110.28947505214752 < (/ (exp x) (- (exp x) 1))

    1. Initial program 61.4

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

      \[\leadsto \color{blue}{\frac{1}{12} \cdot x + \left(\frac{1}{x} + \frac{1}{2}\right)}\]
    3. Taylor expanded around 0 0.4

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

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

Reproduce

herbie shell --seed 323378853 
(FPCore (x)
  :name "expq2 (section 3.11)"

  :herbie-target
  (/ 1 (- 1 (exp (- x))))

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

Details

Time bar (total: 22.7s)Debug log

sample152.0ms

Algorithm
intervals
Results
48.0ms84×body10240exit
45.0ms72×body1280valid
23.0ms51×body640valid
9.0ms94×body80valid
8.0ms26×body320valid
3.0ms13×body160valid

simplify8.0ms

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 39.6b

localize22.0ms

Local error

Found 2 expressions with local error:

3.5b
(- (exp x) 1)
0.3b
(/ (exp x) (- (exp x) 1))

rewrite21.0ms

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

series82.0ms

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

simplify1000.0ms

Counts
41 → 51
Calls
41 calls:
Slowest
409.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
156.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
65.0ms
(+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1)))
38.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) (* (cbrt (- (exp x) 1)) (cbrt (- (exp x) 1))))
20.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) 1)

prune639.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.2b

localize30.0ms

Local error

Found 2 expressions with local error:

0.4b
(* 1/12 x)
0.0b
(+ (* 1/12 x) (+ (/ 1 x) 1/2))

rewrite20.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
flip-+
*-commutative
flip3-+
sum-log
associate-+r+
+-commutative
Counts
2 → 20
Calls
2 calls:
Slowest
19.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
1.0ms
(* 1/12 x)

series30.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
15.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
15.0ms
(* 1/12 x)

simplify120.0ms

Counts
7 → 26
Calls
7 calls:
Slowest
50.0ms
(* (exp (* 1/12 x)) (exp (+ (/ 1 x) 1/2)))
20.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
20.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
20.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
3.0ms
(* 1/12 x)

prune286.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.2b

localize1.0ms

Local error

Found 2 expressions with local error:

0.4b
(* 1/12 x)
0.0b
(+ (* 1/12 x) (+ (/ 1 x) 1/2))

rewrite18.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
flip-+
*-commutative
flip3-+
sum-log
associate-+r+
+-commutative
Counts
2 → 20
Calls
2 calls:
Slowest
17.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
0.0ms
(* 1/12 x)

series33.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
17.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
16.0ms
(* 1/12 x)

simplify121.0ms

Counts
7 → 26
Calls
7 calls:
Slowest
51.0ms
(* (exp (* 1/12 x)) (exp (+ (/ 1 x) 1/2)))
21.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
20.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
20.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
3.0ms
(* 1/12 x)

prune271.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.2b

localize25.0ms

Local error

Found 4 expressions with local error:

0.5b
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
0.5b
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
0.5b
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
0.5b
(* (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))) (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))))

rewrite93.0ms

Algorithm
rewrite-expression-head
Rules
18×cbrt-div
15×cbrt-prod
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
flip-+
flip3-+
pow1
pow1/3
add-exp-log
associate-*l*
associate-*r*
add-log-exp
add-cbrt-cube
frac-times
pow-prod-up
associate-*r/
associate-*l/
pow-prod-down
cbrt-unprod
*-commutative
prod-exp
pow-plus
pow2
Counts
4 → 75
Calls
4 calls:
Slowest
56.0ms
(* (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))) (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))))
12.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
12.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
12.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))

series444.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
123.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
121.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
119.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
80.0ms
(* (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))) (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))))

simplify12.6s

Counts
59 → 87
Calls
59 calls:
Slowest
774.0ms
(- (+ (exp (* 1/3 (- (log -1/12) (log (/ -1 x))))) (* 2 (/ (exp (* 1/3 (- (log -1/12) (log (/ -1 x))))) x))) (* 8/3 (/ (exp (* 1/3 (- (log -1/12) (log (/ -1 x))))) (pow x 3))))
739.0ms
(* (cbrt (+ (* (* 1/12 x) (* 1/12 x)) (- (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)) (* (* 1/12 x) (+ (/ 1 x) 1/2))))) (cbrt (- (* 1/12 x) (+ (/ 1 x) 1/2))))
709.0ms
(* (cbrt (- (* 1/12 x) (+ (/ 1 x) 1/2))) (cbrt (+ (* (* 1/12 x) (* 1/12 x)) (- (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)) (* (* 1/12 x) (+ (/ 1 x) 1/2))))))
668.0ms
(cbrt (+ (* (* 1/12 x) (* 1/12 x)) (- (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)) (* (* 1/12 x) (+ (/ 1 x) 1/2)))))
644.0ms
(* (cbrt (+ (* (* 1/12 x) (* 1/12 x)) (- (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)) (* (* 1/12 x) (+ (/ 1 x) 1/2))))) (cbrt (+ (* (* 1/12 x) (* 1/12 x)) (- (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)) (* (* 1/12 x) (+ (/ 1 x) 1/2))))))

prune1.3s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.2b

regimes266.0ms

Accuracy

98.1% (0.4b remaining)

Error of 0.7b against oracle of 0.3b and baseline of 21.6b

bsearch5.0ms

end0.0ms

sample5.1s

Algorithm
intervals
Results
1.6s2583×body10240exit
1.5s2233×body1280valid
1.2s1650×body640valid
286.0ms820×body320valid
268.0ms2881×body80valid
135.0ms416×body160valid