Average Error: 40.4 → 0.6
Time: 23.6s
Precision: 64
Internal Precision: 128
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0019474786431094154:\\ \;\;\;\;\frac{e^{x}}{\frac{e^{x} \cdot e^{x} - 1}{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.4
Target40.0
Herbie0.6
\[\frac{1}{1 - e^{-x}}\]

Derivation

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

    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}}}\]

    if -0.0019474786431094154 < x

    1. Initial program 60.4

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

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

Reproduce

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

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

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

Details

Time bar (total: 23.2s)Debug log

sample145.0ms

Algorithm
intervals

simplify8.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 43.8b

localize36.0ms

Local error

Found 2 expressions with local error:

4.5b
(- (exp x) 1)
0.0b
(/ (exp x) (- (exp x) 1))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
2 → 45
Calls

2 calls. Slowest were:

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

series41.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

29.0ms
(/ (exp x) (- (exp x) 1))
12.0ms
(- (exp x) 1)

simplify959.0ms

Counts
41 → 51
Calls

41 calls. Slowest were:

641.0ms
(/ (* (* (exp x) (exp x)) (exp x)) (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)))
96.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
33.0ms
(+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1)))

prune373.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0b

localize17.0ms

Local error

Found 2 expressions with local error:

0.3b
(* 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:

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

simplify56.0ms

Counts
7 → 26
Calls

7 calls. Slowest were:

22.0ms
(* (exp (* 1/12 x)) (exp (+ (/ 1 x) 1/2)))
12.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))
8.0ms
(+ (* 1/12 x) (+ (/ 1 x) 1/2))

prune147.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize29.0ms

Local error

Found 4 expressions with local error:

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

rewrite39.0ms

Algorithm
rewrite-expression-head
Counts
4 → 159
Calls

4 calls. Slowest were:

13.0ms
(/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1))
12.0ms
(/ (exp x) (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1)))
9.0ms
(- (* (exp x) (exp x)) (* 1 1))

series130.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

69.0ms
(/ (exp x) (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1)))
36.0ms
(/ (- (* (exp x) (exp x)) (* 1 1)) (+ (exp x) 1))
17.0ms
(- (* (exp x) (exp x)) (* 1 1))
9.0ms
(* (exp x) (exp x))

simplify16.1s

Counts
196 → 171
Calls

196 calls. Slowest were:

939.0ms
(/ 1 (/ (- (* (exp x) (exp x)) (* 1 1)) (+ (pow (exp x) 3) (pow 1 3))))
696.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))))
616.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)))

prune1.5s

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes57.0ms

Accuracy

99.1% (0.2b remaining)

Error of 0.6b against oracle of 0.4b and baseline of 21.2b

bsearch42.0ms

end0.0ms

sample3.5s

Algorithm
intervals