Average Error: 39.8 → 0.6
Time: 15.9s
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.002285063158101973:\\ \;\;\;\;\frac{e^{x}}{\left(\sqrt{e^{x}} - 1\right) \cdot \left(1 + \sqrt{e^{x}}\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

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

Derivation

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

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{\frac{e^{x}}{e^{x} - 1}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt0.0

      \[\leadsto \frac{e^{x}}{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}} - 1}\]
    5. Applied difference-of-sqr-10.0

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

    if -0.002285063158101973 < x

    1. Initial program 60.1

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

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

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

Reproduce

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

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

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

Details

Time bar (total: 15.5s)Debug log

sample66.0ms

Algorithm
intervals

simplify4.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

4.0ms
(/ (exp x) (- (exp x) 1))

prune24.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 35.5b

localize18.0ms

Local error

Found 2 expressions with local error:

2.8b
(- (exp x) 1)
0.5b
(/ (exp x) (- (exp x) 1))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
2 → 45
Calls

2 calls. Slowest were:

11.0ms
(/ (exp x) (- (exp x) 1))
6.0ms
(- (exp x) 1)

series55.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

34.0ms
(/ (exp x) (- (exp x) 1))
20.0ms
(- (exp x) 1)

simplify756.0ms

Counts
41 → 51
Calls

41 calls. Slowest were:

326.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
117.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
40.0ms
(+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1)))

prune429.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.5b

localize15.0ms

Local error

Found 2 expressions with local error:

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

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
2 → 20
Calls

2 calls. Slowest were:

6.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
0.0ms
(* 1/12 x)

series15.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

7.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
7.0ms
(* 1/12 x)

simplify79.0ms

Counts
7 → 26
Calls

7 calls. Slowest were:

27.0ms
(* (exp (* 1/12 x)) (exp (+ (/ 1 x) 1/2)))
17.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
17.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))

prune202.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.5b

localize19.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))))

rewrite79.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

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

series309.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

104.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
83.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
75.0ms
(cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2)))
47.0ms
(* (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))) (cbrt (+ (* 1/12 x) (+ (/ 1 x) 1/2))))

simplify8.8s

Counts
59 → 87
Calls

59 calls. Slowest were:

690.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))))
594.0ms
(cbrt (+ (* (* 1/12 x) (* 1/12 x)) (- (* (+ (/ 1 x) 1/2) (+ (/ 1 x) 1/2)) (* (* 1/12 x) (+ (/ 1 x) 1/2)))))
577.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))))))

prune623.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 0.5b

localize0.0ms

Local error

Found 2 expressions with local error:

2.8b
(- (exp x) 1)
0.5b
(/ (exp x) (- (exp x) 1))

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
2 → 45
Calls

2 calls. Slowest were:

5.0ms
(/ (exp x) (- (exp x) 1))
3.0ms
(- (exp x) 1)

series50.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

34.0ms
(/ (exp x) (- (exp x) 1))
17.0ms
(- (exp x) 1)

simplify622.0ms

Counts
41 → 51
Calls

41 calls. Slowest were:

204.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
86.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
52.0ms
(+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1)))

prune340.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 0.5b

regimes170.0ms

Accuracy

98.9% (0.2b remaining)

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

bsearch34.0ms

end0.0ms

sample2.8s

Algorithm
intervals