Average Error: 39.5 → 0.3
Time: 11.2s
Precision: 64
Internal Precision: 128
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00020187990748026416:\\ \;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(1 + \frac{1}{36} \cdot {x}^{2}\right) + \frac{1}{6} \cdot x\right) \cdot \left(\left(1 + \frac{1}{36} \cdot {x}^{2}\right) + \frac{1}{6} \cdot x\right)\right) \cdot \sqrt[3]{\left(\frac{1}{6} \cdot {x}^{2} + 1\right) + x \cdot \frac{1}{2}}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.5
Target38.6
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;x \lt 1 \land x \gt -1:\\ \;\;\;\;\frac{e^{x} - 1}{\log \left(e^{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x} - 1}{x}\\ \end{array}\]

Derivation

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

    1. Initial program 0.1

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

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

    if -0.00020187990748026416 < x

    1. Initial program 59.9

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt0.5

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)} \cdot \sqrt[3]{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)}\right) \cdot \sqrt[3]{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)}}\]
    5. Taylor expanded around 0 0.5

      \[\leadsto \left(\sqrt[3]{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)} \cdot \color{blue}{\left(\frac{1}{6} \cdot x + \left(\frac{1}{36} \cdot {x}^{2} + 1\right)\right)}\right) \cdot \sqrt[3]{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)}\]
    6. Taylor expanded around 0 0.5

      \[\leadsto \left(\color{blue}{\left(\frac{1}{6} \cdot x + \left(\frac{1}{36} \cdot {x}^{2} + 1\right)\right)} \cdot \left(\frac{1}{6} \cdot x + \left(\frac{1}{36} \cdot {x}^{2} + 1\right)\right)\right) \cdot \sqrt[3]{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

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

Reproduce

herbie shell --seed 2019008 
(FPCore (x)
  :name "Kahan's exp quotient"

  :herbie-target
  (if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))

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

Details

Time bar (total: 10.7s)Debug log

sample76.0ms

Algorithm
intervals

simplify7.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 41.8b

localize8.0ms

Local error

Found 2 expressions with local error:

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
2 → 29
Calls

2 calls. Slowest were:

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

series55.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify296.0ms

Counts
13 → 35
Calls

13 calls. Slowest were:

106.0ms
(* -1 (/ (- 1 (exp x)) x))
78.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
34.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

prune217.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.1b

localize14.0ms

Local error

Found 2 expressions with local error:

0.2b
(* 1/6 (pow x 2))
0.0b
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
2 → 24
Calls

2 calls. Slowest were:

5.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
1.0ms
(* 1/6 (pow x 2))

series24.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

13.0ms
(* 1/6 (pow x 2))
11.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

simplify198.0ms

Counts
10 → 30
Calls

10 calls. Slowest were:

80.0ms
(* (exp (* 1/2 x)) (exp (+ (* 1/6 (pow x 2)) 1)))
37.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
31.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

prune233.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize11.0ms

Local error

Found 4 expressions with local error:

10.8b
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
10.8b
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
10.8b
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
0.2b
(* 1/6 (pow x 2))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 51
Calls

4 calls. Slowest were:

4.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
4.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
3.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))

series185.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
52.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
43.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
21.0ms
(* 1/6 (pow x 2))

simplify2.9s

Counts
30 → 63
Calls

30 calls. Slowest were:

380.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))
353.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))
290.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))

prune642.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize35.0ms

Local error

Found 4 expressions with local error:

10.8b
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
10.8b
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
0.4b
(* 1/6 x)
0.2b
(* 1/6 (pow x 2))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 46
Calls

4 calls. Slowest were:

7.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
7.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
2.0ms
(* 1/6 (pow x 2))

series133.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

58.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
55.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
12.0ms
(* 1/6 (pow x 2))
7.0ms
(* 1/6 x)

simplify2.1s

Counts
25 → 58
Calls

25 calls. Slowest were:

425.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))
319.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))
265.0ms
(+ (/ (exp (* 1/3 (- (log 1/6) (* 2 (log (/ -1 x)))))) x) (+ (/ (exp (* 1/3 (- (log 1/6) (* 2 (log (/ -1 x)))))) (pow x 2)) (exp (* 1/3 (- (log 1/6) (* 2 (log (/ -1 x))))))))

prune743.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

regimes36.0ms

Accuracy

99.1% (0.2b remaining)

Error of 0.3b against oracle of 0.1b and baseline of 21.4b

bsearch64.0ms

end0.0ms

sample2.6s

Algorithm
intervals