Average Error: 40.3 → 0.7
Time: 49.5s
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.001992251993699862:\\ \;\;\;\;\left(e^{x} + 1\right) \cdot \frac{e^{x}}{e^{x} \cdot e^{x} - 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{2}\right) + \frac{1}{12} \cdot 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.9
Herbie0.7
\[\frac{1}{1 - e^{-x}}\]

Derivation

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

    1. Initial program 0.0

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

      \[\leadsto \frac{e^{x}}{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}\]
    4. Applied associate-/r/0.0

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

    if -0.001992251993699862 < x

    1. Initial program 60.1

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

      \[\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}\;x \le -0.001992251993699862:\\ \;\;\;\;\left(e^{x} + 1\right) \cdot \frac{e^{x}}{e^{x} \cdot e^{x} - 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{2}\right) + \frac{1}{12} \cdot x\\ \end{array}\]

Reproduce

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

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

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

Details

Time bar (total: 48.9s)Debug log

sample95.0ms

Algorithm
intervals
Results
30.0ms74×body1280valid
28.0ms87×body10240exit
14.0ms49×body640valid
6.0ms31×body320valid
5.0ms89×body80valid
2.0ms16×body160valid

simplify4.0ms

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

prune3.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 40.3b

localize7.0ms

Local error

Found 2 expressions with local error:

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

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

series36.0ms

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

simplify519.0ms

Counts
41 → 51
Calls
41 calls:
Slowest
215.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
81.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
39.0ms
(+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1)))
27.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) (* (cbrt (- (exp x) 1)) (cbrt (- (exp x) 1))))
11.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))

prune327.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.2b

localize11.0ms

Local error

Found 3 expressions with local error:

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

rewrite9.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-+
flip3-+
+-commutative
*-commutative
sum-log
associate-+r+
Counts
3 → 30
Calls
3 calls:
Slowest
6.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
2.0ms
(+ (/ 1 x) 1/2)
0.0ms
(* 1/12 x)

series29.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
10.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
10.0ms
(+ (/ 1 x) 1/2)
9.0ms
(* 1/12 x)

simplify94.0ms

Counts
10 → 39
Calls
10 calls:
Slowest
35.0ms
(* (exp (* 1/12 x)) (exp (+ (/ 1 x) 1/2)))
18.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
14.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
12.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
2.0ms
(* 1/12 x)

prune239.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.2b

localize22.0ms

Local error

Found 4 expressions with local error:

26.6b
(/ (- (* (* 1/12 x) (* 1/12 x)) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2))) (- (* 1/12 x) (+ (/ 1 x) 1/2)))
0.3b
(* 1/12 x)
0.3b
(* 1/12 x)
0.3b
(* 1/12 x)

rewrite32.0ms

Algorithm
rewrite-expression-head
Rules
13×add-cube-cbrt
13×*-un-lft-identity
13×add-sqr-sqrt
12×times-frac
add-exp-log
add-cbrt-cube
difference-of-squares
add-log-exp
associate-/l*
pow1
*-commutative
associate-/r*
associate-/l/
flip--
associate-/r/
flip3--
div-inv
div-exp
div-sub
frac-2neg
clear-num
cbrt-undiv
Counts
4 → 60
Calls
4 calls:
Slowest
27.0ms
(/ (- (* (* 1/12 x) (* 1/12 x)) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2))) (- (* 1/12 x) (+ (/ 1 x) 1/2)))
0.0ms
(* 1/12 x)
0.0ms
(* 1/12 x)
0.0ms
(* 1/12 x)

series59.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
29.0ms
(/ (- (* (* 1/12 x) (* 1/12 x)) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2))) (- (* 1/12 x) (+ (/ 1 x) 1/2)))
10.0ms
(* 1/12 x)
10.0ms
(* 1/12 x)
10.0ms
(* 1/12 x)

simplify5.2s

Counts
49 → 72
Calls
49 calls:
Slowest
321.0ms
(/ (- (* (* 1/12 x) (* 1/12 x)) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2))) (- (* 1/12 x) (+ (/ 1 x) 1/2)))
295.0ms
(/ (- (* (* 1/12 x) (* 1/12 x)) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2))) (cbrt (- (* 1/12 x) (+ (/ 1 x) 1/2))))
294.0ms
(/ (sqrt (- (* (* 1/12 x) (* 1/12 x)) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)))) (sqrt (- (* 1/12 x) (+ (/ 1 x) 1/2))))
272.0ms
(/ (sqrt (- (* (* 1/12 x) (* 1/12 x)) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)))) (* (cbrt (- (* 1/12 x) (+ (/ 1 x) 1/2))) (cbrt (- (* 1/12 x) (+ (/ 1 x) 1/2)))))
271.0ms
(- (log (- (* (* 1/12 x) (* 1/12 x)) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)))) (log (- (* 1/12 x) (+ (/ 1 x) 1/2))))

prune503.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.2b

localize77.0ms

Local error

Found 4 expressions with local error:

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

rewrite57.0ms

Algorithm
rewrite-expression-head
Rules
81×cbrt-prod
72×times-frac
57×add-cube-cbrt
57×*-un-lft-identity
57×add-sqr-sqrt
42×associate-*l*
42×associate-*r*
16×add-exp-log
10×cbrt-div
pow1
add-cbrt-cube
flip--
flip3--
add-log-exp
cbrt-unprod
associate-/r/
prod-exp
div-exp
cbrt-undiv
pow1/3
div-inv
pow-prod-up
*-commutative
associate-*r/
associate-*l/
pow-prod-down
pow-plus
frac-times
pow2
Counts
4 → 146
Calls
4 calls:
Slowest
38.0ms
(* (/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (cbrt (- (* 1/12 x) (- (/ 1 x) -1/2)))) (/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (cbrt (- (* 1/12 x) (- (/ 1 x) -1/2)))))
5.0ms
(cbrt (- (* (* x 1/144) x) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2))))
5.0ms
(cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x)))))
5.0ms
(cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x)))))

series276.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
82.0ms
(* (/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (cbrt (- (* 1/12 x) (- (/ 1 x) -1/2)))) (/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (cbrt (- (* 1/12 x) (- (/ 1 x) -1/2)))))
78.0ms
(cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x)))))
61.0ms
(cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x)))))
55.0ms
(cbrt (- (* (* x 1/144) x) (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2))))

simplify34.4s

Counts
126 → 158
Calls
126 calls:
Slowest
768.0ms
(/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (cbrt (cbrt (- (* 1/12 x) (- (/ 1 x) -1/2)))))
525.0ms
(/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (cbrt (sqrt (- (* 1/12 x) (- (/ 1 x) -1/2)))))
520.0ms
(/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (cbrt (- (* 1/12 x) (- (/ 1 x) -1/2))))
495.0ms
(* (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (cbrt (- (* 1/12 x) (- (/ 1 x) -1/2)))))
465.0ms
(/ (cbrt (- (* (* x 1/144) x) (* (+ 1/2 (/ 1 x)) (+ 1/2 (/ 1 x))))) (sqrt (cbrt (- (* 1/12 x) (- (/ 1 x) -1/2)))))

prune2.8s

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.2b

regimes573.0ms

Accuracy

99% (0.2b remaining)

Error of 0.7b against oracle of 0.4b and baseline of 21.1b

bsearch36.0ms

end0.0ms

sample3.5s

Algorithm
intervals
Results
1.4s2535×body10240exit
1.1s2301×body1280valid
459.0ms1616×body640valid
177.0ms2836×body80valid
155.0ms828×body320valid
52.0ms421×body160valid