Average Error: 39.6 → 0.1
Time: 10.0s
Precision: 64
Internal Precision: 128
\[\frac{e^{x} - 1}{x}\]
\[\log_* (1 + (e^{\frac{(e^{x} - 1)^*}{x}} - 1)^*)\]

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.1
\[\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. Initial program 39.6

    \[\frac{e^{x} - 1}{x}\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\frac{(e^{x} - 1)^*}{x}}\]
  3. Using strategy rm
  4. Applied log1p-expm1-u0.1

    \[\leadsto \color{blue}{\log_* (1 + (e^{\frac{(e^{x} - 1)^*}{x}} - 1)^*)}\]
  5. Final simplification0.1

    \[\leadsto \log_* (1 + (e^{\frac{(e^{x} - 1)^*}{x}} - 1)^*)\]

Reproduce

herbie shell --seed 2019004 +o rules:numerics
(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: 9.6s)Debug log

sample105.0ms

Algorithm
intervals

simplify16.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune14.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 1 expressions with local error:

0.0b
(/ (expm1 x) x)

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
1 → 16
Calls

1 calls. Slowest were:

5.0ms
(/ (expm1 x) x)

series36.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

35.0ms
(/ (expm1 x) x)

simplify192.0ms

Counts
6 → 19
Calls

6 calls. Slowest were:

107.0ms
(* -1 (/ (- 1 (exp x)) x))
67.0ms
(+ (* 1/2 x) (+ (* 1/6 (pow x 2)) 1))
14.0ms
(/ (- (exp x) 1) x)

prune116.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0b

localize12.0ms

Local error

Found 3 expressions with local error:

0.6b
(expm1 (/ (expm1 x) x))
0.0b
(log1p (expm1 (/ (expm1 x) x)))
0.0b
(/ (expm1 x) x)

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
3 → 38
Calls

3 calls. Slowest were:

5.0ms
(/ (expm1 x) x)
1.0ms
(expm1 (/ (expm1 x) x))
0.0ms
(log1p (expm1 (/ (expm1 x) x)))

series336.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

262.0ms
(log1p (expm1 (/ (expm1 x) x)))
50.0ms
(expm1 (/ (expm1 x) x))
24.0ms
(/ (expm1 x) x)

simplify1.3s

Counts
14 → 47
Calls

14 calls. Slowest were:

402.0ms
(- (+ (* 7/24 (* (pow x 2) E)) (+ E (* 1/2 (* x E)))) 1)
302.0ms
(- (+ (/ (exp x) x) (+ (* 1/2 (/ 1 (pow x 2))) (+ (* 1/6 (/ (pow (exp x) 3) (pow x 3))) (+ (* 1/2 (/ (pow (exp x) 2) (pow x 2))) (* 1/2 (/ (exp x) (pow x 3))))))) (+ (/ (exp x) (pow x 2)) (+ (* 1/2 (/ (pow (exp x) 2) (pow x 3))) (+ (* 1/6 (/ 1 (pow x 3))) (/ 1 x)))))
243.0ms
(- (+ (/ (exp x) x) (+ (* 1/2 (/ 1 (pow x 2))) (+ (* 1/6 (/ (pow (exp x) 3) (pow x 3))) (+ (* 1/2 (/ (pow (exp x) 2) (pow x 2))) (* 1/2 (/ (exp x) (pow x 3))))))) (+ (/ (exp x) (pow x 2)) (+ (* 1/2 (/ (pow (exp x) 2) (pow x 3))) (+ (* 1/6 (/ 1 (pow x 3))) (/ 1 x)))))

prune387.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize15.0ms

Local error

Found 4 expressions with local error:

0.8b
(* (sqrt (expm1 (/ (expm1 x) x))) (sqrt (expm1 (/ (expm1 x) x))))
0.6b
(expm1 (/ (expm1 x) x))
0.6b
(expm1 (/ (expm1 x) x))
0.1b
(sqrt (expm1 (/ (expm1 x) x)))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

10.0ms
(* (sqrt (expm1 (/ (expm1 x) x))) (sqrt (expm1 (/ (expm1 x) x))))
1.0ms
(sqrt (expm1 (/ (expm1 x) x)))
1.0ms
(expm1 (/ (expm1 x) x))

series192.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

56.0ms
(sqrt (expm1 (/ (expm1 x) x)))
48.0ms
(expm1 (/ (expm1 x) x))
46.0ms
(* (sqrt (expm1 (/ (expm1 x) x))) (sqrt (expm1 (/ (expm1 x) x))))
41.0ms
(expm1 (/ (expm1 x) x))

simplify3.1s

Counts
40 → 80
Calls

40 calls. Slowest were:

429.0ms
(- (+ (* 7/24 (* (pow x 2) E)) (+ E (* 1/2 (* x E)))) 1)
390.0ms
(- (+ (* 7/24 (* (pow x 2) E)) (+ E (* 1/2 (* x E)))) 1)
375.0ms
(- (+ (* 7/24 (* (pow x 2) E)) (+ E (* 1/2 (* x E)))) 1)

prune875.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes34.0ms

Accuracy

0% (0.0b remaining)

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

bsearch1.0ms

end0.0ms

sample2.9s

Algorithm
intervals