Average Error: 29.5 → 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 10.26670485440381:\\ \;\;\;\;\frac{\log_* (1 + (e^{(\left(x \cdot x\right) \cdot \left((\frac{2}{3} \cdot x + -1)_*\right) + 2)_*} - 1)^*)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(e^{\left(-1 + \varepsilon\right) \cdot x}\right) \cdot \left(\frac{1}{\varepsilon} + 1\right) + \left(\frac{\frac{-1}{\varepsilon} + 1}{e^{(x \cdot \varepsilon + x)_*}}\right))_*}{2}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Derivation

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

    1. Initial program 38.9

      \[\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.2

      \[\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.2

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\frac{2}{3} \cdot {x}^{3} + 2\right)} - 1 \cdot {x}^{2}}{2}\]
    6. Applied prod-diff1.2

      \[\leadsto \frac{\color{blue}{(1 \cdot \left(\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.2

      \[\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.2

      \[\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.2

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

    if 10.26670485440381 < x

    1. Initial program 0.4

      \[\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. Using strategy rm
    3. Applied prod-diff0.4

      \[\leadsto \frac{\color{blue}{(\left(1 + \frac{1}{\varepsilon}\right) \cdot \left(e^{-\left(1 - \varepsilon\right) \cdot x}\right) + \left(-e^{-\left(1 + \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)\right))_* + (\left(-e^{-\left(1 + \varepsilon\right) \cdot x}\right) \cdot \left(\frac{1}{\varepsilon} - 1\right) + \left(e^{-\left(1 + \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)\right))_*}}{2}\]
    4. Simplified0.4

      \[\leadsto \frac{\color{blue}{(\left(e^{x \cdot \left(-1 + \varepsilon\right)}\right) \cdot \left(1 + \frac{1}{\varepsilon}\right) + \left(\frac{1 + \frac{-1}{\varepsilon}}{e^{(x \cdot \varepsilon + x)_*}}\right))_*} + (\left(-e^{-\left(1 + \varepsilon\right) \cdot x}\right) \cdot \left(\frac{1}{\varepsilon} - 1\right) + \left(e^{-\left(1 + \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)\right))_*}{2}\]
    5. Simplified0.4

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

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

Reproduce

herbie shell --seed 2019022 +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

sample373.0ms

Algorithm
intervals
Results
128.0ms71×body10240exit
64.0ms320×body80valid
58.0ms49×body1280valid
55.0ms23×body320valid
43.0ms43×body640valid
6.0ms13×body160valid

simplify191.0ms

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

prune359.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.2b

localize46.0ms

Local error

Found 4 expressions with local error:

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

rewrite43.0ms

Algorithm
rewrite-expression-head
Rules
81×frac-sub
76×frac-times
76×exp-neg
57×exp-diff
57×neg-sub0
42×associate-*l/
38×associate-*r/
31×flip-+
31×flip3-+
29×flip--
29×flip3--
19×un-div-inv
associate-*l*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
add-cbrt-cube
pow1
add-exp-log
log1p-expm1-u
expm1-log1p-u
*-commutative
associate-*r*
cbrt-unprod
prod-exp
pow-prod-down
prod-diff
diff-log
fma-neg
sub-neg
Counts
4 → 155
Calls
4 calls:
Slowest
19.0ms
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))
13.0ms
(- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
4.0ms
(* (+ 1 eps) x)
3.0ms
(* (- 1 eps) x)

series146.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
89.0ms
(- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
24.0ms
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))
17.0ms
(* (+ 1 eps) x)
15.0ms
(* (- 1 eps) x)

simplify52.7s

Counts
207 → 167
Calls
207 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))))
841.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)) 1)))
830.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))))
783.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))))
780.0ms
(* (- 1 (/ 1 eps)) (* (+ (* (/ 1 eps) (/ 1 eps)) (+ (* 1 1) (* (/ 1 eps) 1))) (exp (* (+ 1 eps) x))))

prune2.7s

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.6b

localize31.0ms

Local error

Found 3 expressions with local error:

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

rewrite28.0ms

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

series81.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
41.0ms
(+ (* 2/3 (pow x 3)) 2)
21.0ms
(* 2/3 (pow x 3))
19.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))

simplify2.3s

Counts
46 → 70
Calls
46 calls:
Slowest
234.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* (sqrt (pow x 2)) (sqrt (pow x 2)))))
225.0ms
(fma (sqrt (+ (* 2/3 (pow x 3)) 2)) (sqrt (+ (* 2/3 (pow x 3)) 2)) (- (* (pow x 2) 1)))
189.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* (pow x 2) 1)))
141.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* x x)))
127.0ms
(fma (sqrt (+ (* 2/3 (pow x 3)) 2)) (sqrt (+ (* 2/3 (pow x 3)) 2)) (- (* (sqrt (pow x 2)) (sqrt (pow x 2)))))

prune633.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.6b

localize17.0ms

Local error

Found 2 expressions with local error:

0.1b
(fma 2/3 x -1)
0.1b
(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)

series42.0ms

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

simplify259.0ms

Counts
6 → 26
Calls
6 calls:
Slowest
98.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
83.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
65.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
4.0ms
(- (* 2/3 x) 1)
4.0ms
(- (* 2/3 x) 1)

prune266.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.6b

localize27.0ms

Local error

Found 4 expressions with local error:

43.7b
(cbrt (pow x 3))
43.7b
(cbrt (pow x 3))
7.8b
(- (+ (* (* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3)))) x) 2) (pow x 2))
0.1b
(* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3))))

rewrite67.0ms

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

series166.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
82.0ms
(* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3))))
44.0ms
(- (+ (* (* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3)))) x) 2) (pow x 2))
20.0ms
(cbrt (pow x 3))
20.0ms
(cbrt (pow x 3))

simplify3.5s

Counts
56 → 88
Calls
56 calls:
Slowest
399.0ms
(fma 1 (+ (* (* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3)))) x) 2) (- (* (cbrt (pow x 2)) (* (cbrt (pow x 2)) (cbrt (pow x 2))))))
395.0ms
(- (+ (* 2/3 (* (pow x 3) (pow (cbrt -1) 2))) 2) (pow x 2))
298.0ms
(fma 1 (+ (* (* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3)))) x) 2) (- (* (sqrt (pow x 2)) (sqrt (pow x 2)))))
287.0ms
(fma 1 (+ (* (* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3)))) x) 2) (- (* (pow x 2) 1)))
191.0ms
(fma (sqrt (+ (* (* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3)))) x) 2)) (sqrt (+ (* (* 2/3 (* (cbrt (pow x 3)) (cbrt (pow x 3)))) x) 2)) (- (* (cbrt (pow x 2)) (* (cbrt (pow x 2)) (cbrt (pow x 2))))))

prune1.0s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.6b

regimes171.0ms

Accuracy

96.2% (0.6b remaining)

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

bsearch280.0ms

end0.0ms

sample11.5s

Algorithm
intervals
Results
3.5s1935×body10240exit
3.1s1705×body1280valid
2.8s9925×body80valid
1.2s1263×body640valid
416.0ms672×body320valid
192.0ms339×body160valid