Average Error: 40.2 → 0.8
Time: 17.2s
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{e^{x}}{e^{x} - 1} \le 131.21553089214348:\\ \;\;\;\;\sqrt[3]{\frac{e^{x}}{e^{x} - 1}} \cdot \left(\sqrt[3]{\frac{e^{x}}{e^{x} - 1}} \cdot \sqrt[3]{\frac{e^{x}}{e^{x} - 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{12} + \left(\frac{1}{x} + \frac{1}{2}\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.2
Target39.8
Herbie0.8
\[\frac{1}{1 - e^{-x}}\]

Derivation

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

    1. Initial program 1.2

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

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

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

    1. Initial program 61.3

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

      \[\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.8

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

Reproduce

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

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

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

Details

Time bar (total: 16.6s)Debug log

sample63.0ms

Algorithm
intervals
Results
20.0ms70×body1280valid
18.0ms84×body10240exit
9.0ms47×body640valid
4.0ms30×body320valid
3.0ms93×body80valid
1.0ms16×body160valid

simplify4.0ms

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 39.6b

localize33.0ms

Local error

Found 2 expressions with local error:

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

rewrite17.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
10.0ms
(/ (exp x) (- (exp x) 1))
5.0ms
(- (exp x) 1)

series38.0ms

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

simplify945.0ms

Counts
41 → 51
Calls
41 calls:
Slowest
552.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
106.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
55.0ms
(+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1)))
33.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) (* (cbrt (- (exp x) 1)) (cbrt (- (exp x) 1))))
14.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) (+ (sqrt (exp x)) 1))

prune353.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.3b

localize22.0ms

Local error

Found 2 expressions with local error:

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

rewrite14.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
13.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
0.0ms
(* 1/12 x)

series24.0ms

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

simplify78.0ms

Counts
7 → 26
Calls
7 calls:
Slowest
41.0ms
(* (exp (* 1/12 x)) (exp (+ (/ 1 x) 1/2)))
16.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
8.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
8.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
1.0ms
(* 1/12 x)

prune201.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.3b

localize20.0ms

Local error

Found 4 expressions with local error:

0.6b
(* (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))) (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)))

rewrite79.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
48.0ms
(* (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))) (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))))
10.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
9.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
9.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))

series291.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
85.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
77.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
76.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
53.0ms
(* (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))) (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))))

simplify8.3s

Counts
59 → 87
Calls
59 calls:
Slowest
501.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))))))
464.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))))))
461.0ms
(* (cbrt (+ (pow (* 1/12 x) 3) (pow (+ (/ 1 x) 1/2) 3))) (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))))
456.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))))
450.0ms
(cbrt (+ (pow (* 1/12 x) 3) (pow (+ (/ 1 x) 1/2) 3)))

prune810.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.3b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite30.0ms

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

series72.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
21.0ms
(/ (exp x) (- (exp x) 1))
18.0ms
(- (exp x) 1)
17.0ms
(- (exp x) 1)
17.0ms
(- (exp x) 1)

simplify900.0ms

Counts
49 → 81
Calls
49 calls:
Slowest
304.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
111.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
109.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
86.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
36.0ms
(+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1)))

prune793.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.3b

regimes177.0ms

Accuracy

98% (0.4b remaining)

Error of 0.8b against oracle of 0.4b and baseline of 21.3b

bsearch5.0ms

end0.0ms

sample3.2s

Algorithm
intervals
Results
1.3s2457×body10240exit
951.0ms2290×body1280valid
513.0ms1652×body640valid
182.0ms2838×body80valid
173.0ms807×body320valid
67.0ms416×body160valid