Average Error: 39.6 → 0.6
Time: 11.6s
Precision: 64
Internal Precision: 128
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;\frac{e^{x} - 1}{x} \le -0.0:\\ \;\;\;\;\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x}}{x} - \frac{1}{x}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.6
Target38.7
Herbie0.6
\[\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 (/ (- (exp x) 1) x) < -0.0

    1. Initial program 62.0

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)}\]

    if -0.0 < (/ (- (exp x) 1) x)

    1. Initial program 2.5

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied div-sub1.5

      \[\leadsto \color{blue}{\frac{e^{x}}{x} - \frac{1}{x}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

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

Reproduce

herbie shell --seed 2019004 
(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: 11.0s)Debug log

sample50.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: 35.0b

localize17.0ms

Local error

Found 2 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
2 → 29
Calls

2 calls. Slowest were:

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

series45.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify332.0ms

Counts
13 → 35
Calls

13 calls. Slowest were:

130.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
79.0ms
(* -1 (/ (- 1 (exp x)) x))
34.0ms
(- (* (exp x) (exp x)) (* 1 1))

prune228.0ms

Pruning

6 alts after pruning (5 fresh and 1 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))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
2 → 24
Calls

2 calls. Slowest were:

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

series21.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

12.0ms
(* 1/6 (pow x 2))
10.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

simplify191.0ms

Counts
10 → 30
Calls

10 calls. Slowest were:

74.0ms
(* (exp (* 1/2 x)) (exp (+ (* 1/6 (pow x 2)) 1)))
39.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
38.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

prune311.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 0.1b

localize10.0ms

Local error

Found 4 expressions with local error:

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

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 51
Calls

4 calls. Slowest were:

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

series168.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

62.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
53.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
41.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
11.0ms
(* 1/6 (pow x 2))

simplify3.0s

Counts
30 → 63
Calls

30 calls. Slowest were:

391.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))
370.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))
346.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))

prune649.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 0.1b

localize19.0ms

Local error

Found 4 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
4 → 46
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)))
1.0ms
(* 1/36 (pow x 2))

series114.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

49.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
42.0ms
(cbrt (+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1)))
16.0ms
(* 1/36 (pow x 2))
7.0ms
(* 1/6 x)

simplify2.2s

Counts
25 → 58
Calls

25 calls. Slowest were:

359.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))
354.0ms
(cbrt (+ (pow (* 1/2 x) 3) (pow (+ (* 1/6 (pow x 2)) 1) 3)))
261.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))))))))

prune698.0ms

Pruning

7 alts after pruning (4 fresh and 3 done)

Merged error: 0.1b

regimes112.0ms

Accuracy

97.5% (0.5b remaining)

Error of 0.6b against oracle of 0.0b and baseline of 21.3b

bsearch7.0ms

end0.0ms

sample2.8s

Algorithm
intervals