Average Error: 40.2 → 0.3
Time: 5.9s
Precision: 64
Internal Precision: 128
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00017968162493656685:\\ \;\;\;\;\left(e^{x} - 1\right) \cdot \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + {x}^{2} \cdot \frac{1}{6}\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

Original40.2
Target39.3
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.00017968162493656685

    1. Initial program 0.0

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

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

    if -0.00017968162493656685 < x

    1. Initial program 60.3

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

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

Reproduce

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

sample92.0ms

Algorithm
intervals

simplify16.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 43.5b

localize17.0ms

Local error

Found 2 expressions with local error:

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

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
2 → 29
Calls

2 calls. Slowest were:

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

series46.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify308.0ms

Counts
13 → 35
Calls

13 calls. Slowest were:

103.0ms
(+ x (+ (* 1/6 (pow x 3)) (* 1/2 (pow x 2))))
69.0ms
(* -1 (/ (- 1 (exp x)) x))
38.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))

prune211.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0b

localize24.0ms

Local error

Found 1 expressions with local error:

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

rewrite3.0ms

Algorithm
rewrite-expression-head
Counts
1 → 12
Calls

1 calls. Slowest were:

3.0ms
(* 1/6 (pow x 2))

series24.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

24.0ms
(* 1/6 (pow x 2))

simplify30.0ms

Counts
6 → 15
Calls

6 calls. Slowest were:

7.0ms
(* 1/6 (pow x 2))
7.0ms
(* 1/6 (pow x 2))
7.0ms
(* 1/6 (pow x 2))

prune120.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize11.0ms

Local error

Found 2 expressions with local error:

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

rewrite22.0ms

Algorithm
rewrite-expression-head
Counts
2 → 37
Calls

2 calls. Slowest were:

15.0ms
(* (- (exp x) 1) (/ 1 x))
6.0ms
(- (exp x) 1)

series40.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

28.0ms
(* (- (exp x) 1) (/ 1 x))
12.0ms
(- (exp x) 1)

simplify1.3s

Counts
23 → 43
Calls

23 calls. Slowest were:

389.0ms
(* (* (* (- (exp x) 1) (- (exp x) 1)) (- (exp x) 1)) (* (* (/ 1 x) (/ 1 x)) (/ 1 x)))
196.0ms
(* (+ (* (exp x) (exp x)) (+ (* 1 1) (* (exp x) 1))) x)
173.0ms
(* (- (pow (exp x) 3) (pow 1 3)) (/ 1 x))

prune298.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes37.0ms

Accuracy

98.8% (0.3b remaining)

Error of 0.3b against oracle of 0.0b and baseline of 20.8b

bsearch55.0ms

end0.0ms

sample2.8s

Algorithm
intervals