Average Error: 39.8 → 0.7
Time: 16.1s
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0017805892718932015:\\ \;\;\;\;\left(e^{x} + 1\right) \cdot \frac{e^{x}}{e^{x} \cdot e^{x} - 1}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{1}{12} \cdot x} \cdot {\left(e^{\sqrt[3]{\log \left(\sqrt[3]{\frac{1}{12} \cdot x} \cdot \sqrt[3]{\frac{1}{12} \cdot x}\right)} \cdot \sqrt[3]{\log \left(\sqrt[3]{\frac{1}{12} \cdot x} \cdot \sqrt[3]{\frac{1}{12} \cdot x}\right)}}\right)}^{\left(\sqrt[3]{\log \left(\sqrt[3]{\frac{1}{12} \cdot x} \cdot \sqrt[3]{\frac{1}{12} \cdot x}\right)}\right)} + \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.4
Herbie0.7
\[\frac{1}{1 - e^{-x}}\]

Derivation

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

    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.0017805892718932015 < 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. Using strategy rm
    4. Applied add-cube-cbrt1.0

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{1}{12} \cdot x} \cdot \sqrt[3]{\frac{1}{12} \cdot x}\right) \cdot \sqrt[3]{\frac{1}{12} \cdot x}} + \left(\frac{1}{x} + \frac{1}{2}\right)\]
    5. Using strategy rm
    6. Applied add-exp-log1.0

      \[\leadsto \color{blue}{e^{\log \left(\sqrt[3]{\frac{1}{12} \cdot x} \cdot \sqrt[3]{\frac{1}{12} \cdot x}\right)}} \cdot \sqrt[3]{\frac{1}{12} \cdot x} + \left(\frac{1}{x} + \frac{1}{2}\right)\]
    7. Using strategy rm
    8. Applied add-cube-cbrt1.0

      \[\leadsto e^{\color{blue}{\left(\sqrt[3]{\log \left(\sqrt[3]{\frac{1}{12} \cdot x} \cdot \sqrt[3]{\frac{1}{12} \cdot x}\right)} \cdot \sqrt[3]{\log \left(\sqrt[3]{\frac{1}{12} \cdot x} \cdot \sqrt[3]{\frac{1}{12} \cdot x}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt[3]{\frac{1}{12} \cdot x} \cdot \sqrt[3]{\frac{1}{12} \cdot x}\right)}}} \cdot \sqrt[3]{\frac{1}{12} \cdot x} + \left(\frac{1}{x} + \frac{1}{2}\right)\]
    9. Applied exp-prod1.0

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

Reproduce

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

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

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

Details

Time bar (total: 14.8s)Debug log

sample173.0ms

Algorithm
intervals
Results
350×(pre true 80)
94×(body real 80)
92×(body exit 10240)
72×(body real 1280)
56×(body real 640)
22×(body real 320)
14×(body real 160)

simplify9.0ms

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 39.2b

localize22.0ms

Local error

Found 2 expressions with local error:

3.5b
(- (exp x) 1)
0.5b
(/ (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)

series84.0ms

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

simplify1.1s

Counts
41 → 51
Calls
41 calls:
Slowest
421.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
164.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
68.0ms
(+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1)))
41.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) (* (cbrt (- (exp x) 1)) (cbrt (- (exp x) 1))))
22.0ms
(/ (* (cbrt (exp x)) (cbrt (exp x))) 1)

prune638.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.5b

localize32.0ms

Local error

Found 2 expressions with local error:

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

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

series30.0ms

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

simplify133.0ms

Counts
7 → 26
Calls
7 calls:
Slowest
56.0ms
(* (exp (* 1/12 x)) (exp (+ (/ 1 x) 1/2)))
23.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
22.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
21.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.5b

localize30.0ms

Local error

Found 4 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Rules
pow1
pow1/3
add-cube-cbrt
add-exp-log
*-un-lft-identity
add-sqr-sqrt
cbrt-prod
add-log-exp
associate-*l*
associate-*r*
add-cbrt-cube
pow-prod-up
pow-prod-down
cbrt-unprod
*-commutative
prod-exp
pow-plus
pow2
Counts
4 → 51
Calls
4 calls:
Slowest
10.0ms
(* (cbrt (* 1/12 x)) (cbrt (* 1/12 x)))
1.0ms
(cbrt (* 1/12 x))
1.0ms
(cbrt (* 1/12 x))
1.0ms
(cbrt (* 1/12 x))

series2.0s

Counts
4 → 12
Calls
4 calls:
Slowest
578.0ms
(* (cbrt (* 1/12 x)) (cbrt (* 1/12 x)))
499.0ms
(cbrt (* 1/12 x))
487.0ms
(cbrt (* 1/12 x))
485.0ms
(cbrt (* 1/12 x))

simplify229.0ms

Counts
31 → 63
Calls
31 calls:
Slowest
21.0ms
(* (pow (pow x 2) 1/3) (pow (cbrt 1/12) 2))
21.0ms
(* (pow (pow x 2) 1/3) (pow (cbrt -1/12) 2))
21.0ms
(* (pow (pow x 2) 1/3) (pow (cbrt 1/12) 2))
18.0ms
(* (* 1/12 x) (* 1/12 x))
18.0ms
(* (* 1/12 x) (* 1/12 x))

prune941.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.5b

localize34.0ms

Local error

Found 4 expressions with local error:

5.1b
(exp (log (* (cbrt (* 1/12 x)) (cbrt (* 1/12 x)))))
0.5b
(cbrt (* 1/12 x))
0.5b
(cbrt (* 1/12 x))
0.5b
(cbrt (* 1/12 x))

rewrite22.0ms

Algorithm
rewrite-expression-head
Rules
10×exp-prod
10×pow1
log-pow
pow1/3
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
add-exp-log
add-cbrt-cube
cbrt-prod
pow-prod-up
pow-prod-down
rem-exp-log
exp-sum
pow-plus
log-prod
pow2
Counts
4 → 46
Calls
4 calls:
Slowest
19.0ms
(exp (log (* (cbrt (* 1/12 x)) (cbrt (* 1/12 x)))))
1.0ms
(cbrt (* 1/12 x))
1.0ms
(cbrt (* 1/12 x))
1.0ms
(cbrt (* 1/12 x))

series2.1s

Counts
4 → 12
Calls
4 calls:
Slowest
590.0ms
(exp (log (* (cbrt (* 1/12 x)) (cbrt (* 1/12 x)))))
495.0ms
(cbrt (* 1/12 x))
485.0ms
(cbrt (* 1/12 x))
483.0ms
(cbrt (* 1/12 x))

simplify199.0ms

Counts
27 → 58
Calls
27 calls:
Slowest
22.0ms
(* (pow (pow x 2) 1/3) (pow (cbrt 1/12) 2))
21.0ms
(* (pow (pow x 2) 1/3) (pow (cbrt -1/12) 2))
21.0ms
(* (pow (pow x 2) 1/3) (pow (cbrt 1/12) 2))
12.0ms
(* (pow (* x -1) 1/3) (cbrt -1/12))
12.0ms
(* (pow (* x -1) 1/3) (cbrt -1/12))

prune996.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.5b

regimes149.0ms

Accuracy

99% (0.2b remaining)

Error of 0.7b against oracle of 0.5b and baseline of 21.7b

bsearch76.0ms

end0.0ms

sample5.5s

Algorithm
intervals
Results
10578×(pre true 80)
2903×(body real 80)
2578×(body exit 10240)
2260×(body real 1280)
1662×(body real 640)
774×(body real 320)
401×(body real 160)