Average Error: 39.7 → 0.7
Time: 1.2m
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0017673800546397962:\\ \;\;\;\;\frac{e^{x}}{\frac{\log \left(e^{e^{x} \cdot e^{x} - 1}\right)}{e^{x} + 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{12} \cdot x + \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

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

Derivation

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

    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. Using strategy rm
    5. Applied add-log-exp0.0

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

    if -0.0017673800546397962 < x

    1. Initial program 60.1

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

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

Reproduce

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

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

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

Details

Time bar (total: 1.2m)Debug log

sample172.0ms

Algorithm
intervals
Results
84×54.0ms(body real 1280)
80×49.0ms(body exit 10240)
39×18.0ms(body real 640)
33×11.0ms(body real 320)
336×10.0ms(pre true 80)
87×9.0ms(body real 80)
13×3.0ms(body real 160)

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: 41.2b

localize23.0ms

Local error

Found 2 expressions with local error:

4.9b
(- (exp x) 1)
0.0b
(/ (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
14.0ms
(/ (exp x) (- (exp x) 1))
7.0ms
(- (exp x) 1)

series84.0ms

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

simplify1000.0ms

Counts
41 → 51
Calls
41 calls:
Slowest
412.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
160.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
66.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
(+ (* 1/12 x) (+ (/ 1 x) 1/2))

prune669.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize30.0ms

Local error

Found 1 expressions with local error:

0.4b
(* 1/12 x)

rewrite1.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-cube-cbrt
*-commutative
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
Counts
1 → 8
Calls
1 calls:
Slowest
0.0ms
(* 1/12 x)

series19.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
19.0ms
(* 1/12 x)

simplify9.0ms

Counts
3 → 11
Calls
3 calls:
Slowest
3.0ms
(* 1/12 x)
3.0ms
(* 1/12 x)
3.0ms
(* 1/12 x)

prune127.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.0b

localize44.0ms

Local error

Found 4 expressions with local error:

4.9b
(- (* (exp x) (exp x)) (* 1 1))
0.0b
(/ (exp x) (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1)))
0.0b
(* (exp x) (exp x))
0.0b
(/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1))

rewrite84.0ms

Algorithm
rewrite-expression-head
Rules
114×times-frac
66×add-cube-cbrt
66×*-un-lft-identity
66×add-sqr-sqrt
21×associate-/r*
17×difference-of-squares
13×add-cbrt-cube
11×associate-/r/
add-exp-log
pow1
associate-/l*
add-log-exp
div-inv
flip-+
flip3-+
div-exp
cbrt-undiv
associate-*l*
associate-*r*
associate-/l/
flip--
flip3--
frac-2neg
clear-num
cbrt-unprod
pow-prod-up
*-commutative
prod-exp
pow-prod-down
div-sub
diff-log
pow-plus
sub-neg
pow2
Counts
4 → 159
Calls
4 calls:
Slowest
33.0ms
(/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1))
24.0ms
(/ (exp x) (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1)))
13.0ms
(- (* (exp x) (exp x)) (* 1 1))
9.0ms
(* (exp x) (exp x))

series205.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
92.0ms
(/ (exp x) (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1)))
61.0ms
(/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1))
33.0ms
(- (* (exp x) (exp x)) (* 1 1))
19.0ms
(* (exp x) (exp x))

simplify22.0s

Counts
196 → 171
Calls
196 calls:
Slowest
1.4s
(/ 1 (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (pow (exp x) 3) (pow 1 3))))
855.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1)) (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1))) (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1))))
772.0ms
(/ (* (* (- (* (exp x) (exp x)) (* 1 1)) (- (* (exp x) (exp x)) (* 1 1))) (- (* (exp x) (exp x)) (* 1 1))) (* (* (+ (exp x) 1) (+ (exp x) 1)) (+ (exp x) 1)))
543.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) (/ (* (cbrt (- (* (exp x) (exp x)) (* 1 1))) (cbrt (- (* (exp x) (exp x)) (* 1 1)))) (* (cbrt (+ (exp x) 1)) (cbrt (+ (exp x) 1)))))
420.0ms
(/ (exp x) (+ (* (exp x) (exp x)) (- (* 1 1) (* (exp x) 1))))

prune2.3s

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize31.0ms

Local error

Found 4 expressions with local error:

4.9b
(log (exp (- (* (exp x) (exp x)) (* 1 1))))
4.9b
(- (* (exp x) (exp x)) (* 1 1))
0.0b
(* (exp x) (exp x))
0.0b
(/ (exp x) (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (+ (exp x) 1)))

rewrite96.0ms

Algorithm
rewrite-expression-head
Rules
186×times-frac
99×add-cube-cbrt
99×*-un-lft-identity
99×add-sqr-sqrt
65×log-pow
52×exp-prod
30×associate-/r*
22×pow1
14×difference-of-squares
11×add-cbrt-cube
associate-/r/
add-exp-log
add-log-exp
div-inv
log-prod
flip-+
flip3-+
associate-/l*
associate-*l*
associate-*r*
div-exp
cbrt-undiv
exp-sum
sub-neg
flip--
cbrt-unprod
pow-prod-up
*-commutative
prod-exp
pow-prod-down
rem-log-exp
diff-log
exp-diff
flip3--
pow-plus
frac-2neg
clear-num
log-div
pow2
Counts
4 → 190
Calls
4 calls:
Slowest
45.0ms
(/ (exp x) (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (+ (exp x) 1)))
20.0ms
(log (exp (- (* (exp x) (exp x)) (* 1 1))))
13.0ms
(- (* (exp x) (exp x)) (* 1 1))
9.0ms
(* (exp x) (exp x))

series171.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
86.0ms
(/ (exp x) (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (+ (exp x) 1)))
33.0ms
(log (exp (- (* (exp x) (exp x)) (* 1 1))))
33.0ms
(- (* (exp x) (exp x)) (* 1 1))
19.0ms
(* (exp x) (exp x))

simplify35.4s

Counts
254 → 202
Calls
254 calls:
Slowest
706.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (+ (exp x) 1)) (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (+ (exp x) 1))) (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (+ (exp x) 1))))
602.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (- (* (exp x) (exp x)) (* 1 1))))
590.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) (/ (* (cbrt (log (exp (- (* (exp x) (exp x)) (* 1 1))))) (cbrt (log (exp (- (* (exp x) (exp x)) (* 1 1)))))) (* (cbrt (+ (exp x) 1)) (cbrt (+ (exp x) 1)))))
510.0ms
(/ (cbrt (exp x)) (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (+ (exp x) 1)))
507.0ms
(/ (sqrt (exp x)) (/ (log (exp (- (* (exp x) (exp x)) (* 1 1)))) (+ (exp x) 1)))

prune3.1s

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes100.0ms

Accuracy

99.6% (0.1b remaining)

Error of 0.7b against oracle of 0.6b and baseline of 21.9b

bsearch63.0ms

end0.0ms

sample5.6s

Algorithm
intervals
Results
2605×1.7s(body exit 10240)
2247×1.5s(body real 1280)
1578×726.0ms(body real 640)
10608×665.0ms(pre true 80)
818×321.0ms(body real 320)
2913×293.0ms(body real 80)
447×94.0ms(body real 160)