Average Error: 29.3 → 1.0
Time: 1.3m
Precision: 64
Internal Precision: 128
\[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}\]
\[\begin{array}{l} \mathbf{if}\;x \le 354.06473683693855:\\ \;\;\;\;\frac{(\left(x \cdot x\right) \cdot \left(\log_* (1 + (e^{(\frac{2}{3} \cdot x + -1)_*} - 1)^*)\right) + 2)_*}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{\varepsilon \cdot x - x} \cdot \left(\frac{1}{\varepsilon} + 1\right) - e^{\left(-x\right) \cdot \left(1 + \varepsilon\right)} \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Derivation

  1. Split input into 2 regimes
  2. if x < 354.06473683693855

    1. Initial program 39.0

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}\]
    2. Taylor expanded around 0 1.3

      \[\leadsto \frac{\color{blue}{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) - {x}^{2}}}{2}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity1.3

      \[\leadsto \frac{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) - \color{blue}{1 \cdot {x}^{2}}}{2}\]
    5. Applied add-sqr-sqrt2.3

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{2}{3} \cdot {x}^{3} + 2} \cdot \sqrt{\frac{2}{3} \cdot {x}^{3} + 2}} - 1 \cdot {x}^{2}}{2}\]
    6. Applied prod-diff2.3

      \[\leadsto \frac{\color{blue}{(\left(\sqrt{\frac{2}{3} \cdot {x}^{3} + 2}\right) \cdot \left(\sqrt{\frac{2}{3} \cdot {x}^{3} + 2}\right) + \left(-{x}^{2} \cdot 1\right))_* + (\left(-{x}^{2}\right) \cdot 1 + \left({x}^{2} \cdot 1\right))_*}}{2}\]
    7. Simplified1.3

      \[\leadsto \frac{\color{blue}{(\left(x \cdot x\right) \cdot \left((\frac{2}{3} \cdot x + -1)_*\right) + 2)_*} + (\left(-{x}^{2}\right) \cdot 1 + \left({x}^{2} \cdot 1\right))_*}{2}\]
    8. Simplified1.3

      \[\leadsto \frac{(\left(x \cdot x\right) \cdot \left((\frac{2}{3} \cdot x + -1)_*\right) + 2)_* + \color{blue}{0}}{2}\]
    9. Using strategy rm
    10. Applied log1p-expm1-u1.3

      \[\leadsto \frac{(\left(x \cdot x\right) \cdot \color{blue}{\left(\log_* (1 + (e^{(\frac{2}{3} \cdot x + -1)_*} - 1)^*)\right)} + 2)_* + 0}{2}\]

    if 354.06473683693855 < x

    1. Initial program 0.1

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}\]
    2. Taylor expanded around inf 0.1

      \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot \color{blue}{e^{x \cdot \varepsilon - x}} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 354.06473683693855:\\ \;\;\;\;\frac{(\left(x \cdot x\right) \cdot \left(\log_* (1 + (e^{(\frac{2}{3} \cdot x + -1)_*} - 1)^*)\right) + 2)_*}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{\varepsilon \cdot x - x} \cdot \left(\frac{1}{\varepsilon} + 1\right) - e^{\left(-x\right) \cdot \left(1 + \varepsilon\right)} \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019016 +o rules:numerics
(FPCore (x eps)
  :name "NMSE Section 6.1 mentioned, A"
  (/ (- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x))))) 2))

Details

Time bar (total: 1.3m)Debug log

sample383.0ms

Algorithm
intervals
Results
541×(pre true 80)
336×(body real 80)
77×(body exit 10240)
63×(body real 1280)
38×(body real 640)
16×(body real 320)
11×(body real 160)

simplify525.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
525.0ms
(/ (- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x))))) 2)

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.8b

localize84.0ms

Local error

Found 4 expressions with local error:

2.4b
(- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
0.0b
(exp (- (* (- 1 eps) x)))
0.0b
(exp (- (* (+ 1 eps) x)))
0.0b
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))

rewrite63.0ms

Algorithm
rewrite-expression-head
Rules
81×frac-sub
78×exp-neg
76×frac-times
59×exp-diff
59×neg-sub0
38×associate-*r/
38×associate-*l/
30×flip-+
30×flip3-+
28×flip--
28×flip3--
19×un-div-inv
12×exp-prod
10×add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-cbrt-cube
pow1
add-exp-log
rem-exp-log
log1p-expm1-u
expm1-log1p-u
associate-*l*
associate-*r*
neg-log
distribute-rgt-neg-in
neg-mul-1
distribute-lft-neg-in
cbrt-unprod
*-commutative
prod-exp
pow-prod-down
prod-diff
diff-log
fma-neg
sub-neg
Counts
4 → 163
Calls
4 calls:
Slowest
27.0ms
(- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
15.0ms
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))
7.0ms
(exp (- (* (+ 1 eps) x)))
6.0ms
(exp (- (* (- 1 eps) x)))

series179.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
113.0ms
(- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
31.0ms
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))
22.0ms
(exp (- (* (+ 1 eps) x)))
14.0ms
(exp (- (* (- 1 eps) x)))

simplify55.4s

Counts
215 → 175
Calls
215 calls:
Slowest
1.1s
(- (* (* (+ (pow 1 3) (pow (/ 1 eps) 3)) (exp 0)) (* (+ (/ 1 eps) 1) (exp (* (+ 1 eps) x)))) (* (* (+ (* 1 1) (- (* (/ 1 eps) (/ 1 eps)) (* 1 (/ 1 eps)))) (exp (* (- 1 eps) x))) (* (- (* (/ 1 eps) (/ 1 eps)) (* 1 1)) (exp 0))))
993.0ms
(- (* (* (- (* 1 1) (* (/ 1 eps) (/ 1 eps))) 1) (* (+ (/ 1 eps) 1) (exp (* (+ 1 eps) x)))) (* (* (- 1 (/ 1 eps)) (exp (* (- 1 eps) x))) (* (- (* (/ 1 eps) (/ 1 eps)) (* 1 1)) (exp 0))))
877.0ms
(- (* (* (- (* 1 1) (* (/ 1 eps) (/ 1 eps))) (exp 0)) (* (+ (/ 1 eps) 1) (exp (* (+ 1 eps) x)))) (* (* (- 1 (/ 1 eps)) (exp (* (- 1 eps) x))) (* (- (* (/ 1 eps) (/ 1 eps)) (* 1 1)) (exp 0))))
805.0ms
(cbrt (exp (- (* (- 1 eps) x))))
795.0ms
(* (* (+ (* 1 1) (- (* (/ 1 eps) (/ 1 eps)) (* 1 (/ 1 eps)))) (exp (* (- 1 eps) x))) (+ (* (/ 1 eps) (/ 1 eps)) (+ (* 1 1) (* (/ 1 eps) 1))))

prune3.1s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 1.0b

localize20.0ms

Local error

Found 2 expressions with local error:

5.4b
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
0.1b
(* 2/3 (pow x 3))

rewrite17.0ms

Algorithm
rewrite-expression-head
Rules
14×add-sqr-sqrt
13×*-un-lft-identity
12×prod-diff
11×add-cube-cbrt
associate-*r*
add-log-exp
unpow2
fma-neg
difference-of-squares
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
distribute-lft-out--
flip--
*-commutative
associate--l+
unpow3
diff-log
flip3--
sub-neg
cube-mult
Counts
2 → 48
Calls
2 calls:
Slowest
15.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
1.0ms
(* 2/3 (pow x 3))

series31.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
16.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
15.0ms
(* 2/3 (pow x 3))

simplify2.1s

Counts
43 → 54
Calls
43 calls:
Slowest
241.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* (sqrt (pow x 2)) (sqrt (pow x 2)))))
201.0ms
(fma (sqrt (+ (* 2/3 (pow x 3)) 2)) (sqrt (+ (* 2/3 (pow x 3)) 2)) (- (* (pow x 2) 1)))
175.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* x x)))
159.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* (pow x 2) 1)))
123.0ms
(fma (sqrt (+ (* 2/3 (pow x 3)) 2)) (sqrt (+ (* 2/3 (pow x 3)) 2)) (- (* (sqrt (pow x 2)) (sqrt (pow x 2)))))

prune533.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 1.0b

localize31.0ms

Local error

Found 2 expressions with local error:

0.1b
(fma 2/3 x -1)
0.0b
(fma (* x x) (fma 2/3 x -1) 2)

rewrite1.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
log1p-expm1-u
fma-udef
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
expm1-log1p-u
add-sqr-sqrt
Counts
2 → 20
Calls
2 calls:
Slowest
0.0ms
(fma 2/3 x -1)
0.0ms
(fma (* x x) (fma 2/3 x -1) 2)

series40.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
21.0ms
(fma 2/3 x -1)
18.0ms
(fma (* x x) (fma 2/3 x -1) 2)

simplify314.0ms

Counts
6 → 26
Calls
6 calls:
Slowest
109.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
99.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
83.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
9.0ms
(- (* 2/3 x) 1)
8.0ms
(- (* 2/3 x) 1)

prune305.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 1.0b

localize28.0ms

Local error

Found 4 expressions with local error:

0.8b
(log1p (expm1 (fma 2/3 x -1)))
0.1b
(fma 2/3 x -1)
0.0b
(expm1 (fma 2/3 x -1))
0.0b
(fma (* x x) (log1p (expm1 (fma 2/3 x -1))) 2)

rewrite8.0ms

Algorithm
rewrite-expression-head
Rules
log1p-expm1-u
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
expm1-log1p-u
add-sqr-sqrt
fma-udef
expm1-udef
log1p-expm1
expm1-log1p
log1p-udef
Counts
4 → 42
Calls
4 calls:
Slowest
6.0ms
(expm1 (fma 2/3 x -1))
0.0ms
(log1p (expm1 (fma 2/3 x -1)))
0.0ms
(fma (* x x) (log1p (expm1 (fma 2/3 x -1))) 2)
0.0ms
(fma 2/3 x -1)

series501.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
276.0ms
(log1p (expm1 (fma 2/3 x -1)))
179.0ms
(fma (* x x) (log1p (expm1 (fma 2/3 x -1))) 2)
24.0ms
(expm1 (fma 2/3 x -1))
23.0ms
(fma 2/3 x -1)

simplify708.0ms

Counts
13 → 54
Calls
13 calls:
Slowest
406.0ms
(- (+ (exp -1) (+ (* 2/3 (* x (exp -1))) (* 2/9 (* (pow x 2) (exp -1))))) 1)
95.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
76.0ms
(+ 2 (* (pow x 2) (fma 2/3 x -1)))
47.0ms
(+ 2 (* (pow x 2) (fma 2/3 x -1)))
18.0ms
(- (exp (fma 2/3 x -1)) 1)

prune633.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 1.0b

regimes167.0ms

Accuracy

96.2% (0.6b remaining)

Error of 1.0b against oracle of 0.4b and baseline of 16.6b

bsearch524.0ms

end0.0ms

sample11.9s

Algorithm
intervals
Results
15985×(pre true 80)
10126×(body real 80)
1949×(body exit 10240)
1693×(body real 1280)
1274×(body real 640)
643×(body real 320)
300×(body real 160)