Average Error: 29.1 → 0.9
Time: 1.6m
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 2.84808728349047:\\ \;\;\;\;\frac{\frac{\sqrt{\left(4 + \frac{8}{3} \cdot {x}^{3}\right) - {x}^{4}}}{\frac{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) + {x}^{2}}{\sqrt{\left(4 + \frac{8}{3} \cdot {x}^{3}\right) - {x}^{4}}}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(e^{\left(\varepsilon + -1\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 < 2.84808728349047

    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.0

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

      \[\leadsto \frac{\color{blue}{\frac{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) \cdot \left(\frac{2}{3} \cdot {x}^{3} + 2\right) - {x}^{2} \cdot {x}^{2}}{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) + {x}^{2}}}}{2}\]
    5. Taylor expanded around 0 1.0

      \[\leadsto \frac{\frac{\color{blue}{\left(\frac{8}{3} \cdot {x}^{3} + 4\right) - {x}^{4}}}{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) + {x}^{2}}}{2}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt1.0

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\left(\frac{8}{3} \cdot {x}^{3} + 4\right) - {x}^{4}} \cdot \sqrt{\left(\frac{8}{3} \cdot {x}^{3} + 4\right) - {x}^{4}}}}{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) + {x}^{2}}}{2}\]
    8. Applied associate-/l*1.0

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{\left(\frac{8}{3} \cdot {x}^{3} + 4\right) - {x}^{4}}}{\frac{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) + {x}^{2}}{\sqrt{\left(\frac{8}{3} \cdot {x}^{3} + 4\right) - {x}^{4}}}}}}{2}\]

    if 2.84808728349047 < 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 simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 2.84808728349047:\\ \;\;\;\;\frac{\frac{\sqrt{\left(4 + \frac{8}{3} \cdot {x}^{3}\right) - {x}^{4}}}{\frac{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) + {x}^{2}}{\sqrt{\left(4 + \frac{8}{3} \cdot {x}^{3}\right) - {x}^{4}}}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(e^{\left(\varepsilon + -1\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 2019010 +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.6m)Debug log

sample451.0ms

Algorithm
intervals

simplify171.0ms

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.3b

localize37.0ms

Local error

Found 4 expressions with local error:

0.5b
(- (* (+ 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)

rewrite46.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
25.0ms
(- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
12.0ms
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))
3.0ms
(* (- 1 eps) x)
2.0ms
(* (+ 1 eps) x)

series200.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
141.0ms
(- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
24.0ms
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))
22.0ms
(* (- 1 eps) x)
13.0ms
(* (+ 1 eps) x)

simplify54.8s

Counts
207 → 167
Calls
207 calls:
Slowest
1.0s
(- (* (* (+ (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))))
984.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))))
865.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))))
859.0ms
(* (* (+ (* 1 1) (- (* (/ 1 eps) (/ 1 eps)) (* 1 (/ 1 eps)))) (exp (* (- 1 eps) x))) (+ (* (/ 1 eps) (/ 1 eps)) (+ (* 1 1) (* (/ 1 eps) 1))))
853.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)))

prune2.6s

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.3b

localize16.0ms

Local error

Found 2 expressions with local error:

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

rewrite28.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
25.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
2.0ms
(* 2/3 (pow x 3))

series35.0ms

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

simplify2.3s

Counts
43 → 54
Calls
43 calls:
Slowest
221.0ms
(fma (sqrt (+ (* 2/3 (pow x 3)) 2)) (sqrt (+ (* 2/3 (pow x 3)) 2)) (- (* (pow x 2) 1)))
218.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* (pow x 2) 1)))
173.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* (sqrt (pow x 2)) (sqrt (pow x 2)))))
172.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* x x)))
145.0ms
(fma (sqrt (+ (* 2/3 (pow x 3)) 2)) (sqrt (+ (* 2/3 (pow x 3)) 2)) (- (* (sqrt (pow x 2)) (sqrt (pow x 2)))))

prune655.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.3b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite81.0ms

Algorithm
rewrite-expression-head
Rules
26×*-un-lft-identity
16×add-cube-cbrt
16×times-frac
16×add-sqr-sqrt
10×associate-*r*
difference-of-squares
add-log-exp
add-exp-log
add-cbrt-cube
distribute-lft-out
associate-/l*
log1p-expm1-u
associate-/r*
pow1
expm1-log1p-u
associate-/l/
flip--
*-commutative
associate-/r/
associate--l+
unpow3
flip3--
cube-mult
div-inv
flip-+
prod-diff
div-exp
div-sub
diff-log
fma-neg
flip3-+
distribute-lft-in
frac-2neg
sub-neg
clear-num
cbrt-undiv
distribute-rgt-in
Counts
4 → 92
Calls
4 calls:
Slowest
64.0ms
(/ (- (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (* (pow x 2) (pow x 2))) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2)))
14.0ms
(- (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (* (pow x 2) (pow x 2)))
1.0ms
(* 2/3 (pow x 3))
1.0ms
(* 2/3 (pow x 3))

series132.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
42.0ms
(/ (- (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (* (pow x 2) (pow x 2))) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2)))
37.0ms
(- (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (* (pow x 2) (pow x 2)))
27.0ms
(* 2/3 (pow x 3))
26.0ms
(* 2/3 (pow x 3))

simplify12.9s

Counts
74 → 104
Calls
74 calls:
Slowest
654.0ms
(/ (* (cbrt (- (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (* (pow x 2) (pow x 2)))) (cbrt (- (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (* (pow x 2) (pow x 2))))) 1)
576.0ms
(/ (- (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (* (pow x 2) (pow x 2))) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2)))
522.0ms
(/ (- (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (* (pow x 2) (pow x 2))) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2)))
512.0ms
(+ (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (- (* (pow x 2) (pow x 2)) (* (+ (* 2/3 (pow x 3)) 2) (pow x 2))))
489.0ms
(fma (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2) (- (* (pow x 2) (pow x 2))))

prune1.1s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.3b

localize16.0ms

Local error

Found 4 expressions with local error:

11.4b
(/ (- (+ (* 8/3 (pow x 3)) 4) (pow x 4)) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2)))
10.3b
(- (+ (* 8/3 (pow x 3)) 4) (pow x 4))
0.1b
(* 2/3 (pow x 3))
0.1b
(* 8/3 (pow x 3))

rewrite78.0ms

Algorithm
rewrite-expression-head
Rules
48×*-un-lft-identity
36×add-sqr-sqrt
24×add-cube-cbrt
20×times-frac
10×associate-*r*
prod-diff
difference-of-squares
add-log-exp
distribute-lft-out--
distribute-lft-out
add-exp-log
add-cbrt-cube
associate-/l*
log1p-expm1-u
associate-/r*
pow1
expm1-log1p-u
fma-neg
associate-/l/
flip--
*-commutative
associate-/r/
unpow3
flip3--
cube-mult
div-inv
flip-+
associate--l+
div-exp
div-sub
diff-log
flip3-+
frac-2neg
sub-neg
clear-num
cbrt-undiv
Counts
4 → 107
Calls
4 calls:
Slowest
40.0ms
(/ (- (+ (* 8/3 (pow x 3)) 4) (pow x 4)) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2)))
30.0ms
(- (+ (* 8/3 (pow x 3)) 4) (pow x 4))
2.0ms
(* 8/3 (pow x 3))
2.0ms
(* 2/3 (pow x 3))

series118.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
44.0ms
(/ (- (+ (* 8/3 (pow x 3)) 4) (pow x 4)) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2)))
28.0ms
(* 8/3 (pow x 3))
25.0ms
(* 2/3 (pow x 3))
21.0ms
(- (+ (* 8/3 (pow x 3)) 4) (pow x 4))

simplify7.3s

Counts
99 → 119
Calls
99 calls:
Slowest
590.0ms
(+ (* (+ (* 2/3 (pow x 3)) 2) (+ (* 2/3 (pow x 3)) 2)) (- (* (pow x 2) (pow x 2)) (* (+ (* 2/3 (pow x 3)) 2) (pow x 2))))
221.0ms
(- (* (+ (* 8/3 (pow x 3)) 4) (+ (* 8/3 (pow x 3)) 4)) (* (pow x 4) (pow x 4)))
220.0ms
(/ (* (* (- (+ (* 8/3 (pow x 3)) 4) (pow x 4)) (- (+ (* 8/3 (pow x 3)) 4) (pow x 4))) (- (+ (* 8/3 (pow x 3)) 4) (pow x 4))) (* (* (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2)) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2))) (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2))))
192.0ms
(- (pow (+ (* 8/3 (pow x 3)) 4) 3) (pow (pow x 4) 3))
171.0ms
(/ (sqrt (- (+ (* 8/3 (pow x 3)) 4) (pow x 4))) (sqrt (+ (+ (* 2/3 (pow x 3)) 2) (pow x 2))))

prune1.6s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.3b

regimes104.0ms

Accuracy

96.8% (0.5b remaining)

Error of 0.9b against oracle of 0.3b and baseline of 16.7b

bsearch681.0ms

end0.0ms

sample12.7s

Algorithm
intervals