Average Error: 30.0 → 0.9
Time: 5.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 334.68650982699563:\\ \;\;\;\;\frac{\frac{\sqrt[3]{{\left(2 + \frac{2}{3} \cdot {x}^{3}\right)}^{3} - {\left({x}^{2}\right)}^{3}} \cdot \sqrt[3]{{\left(2 + \frac{2}{3} \cdot {x}^{3}\right)}^{3} - {\left({x}^{2}\right)}^{3}}}{\sqrt{\left(\left(2 + \frac{2}{3} \cdot {x}^{3}\right) \cdot {x}^{2} + {x}^{2} \cdot {x}^{2}\right) + \left(2 + \frac{2}{3} \cdot {x}^{3}\right) \cdot \left(2 + \frac{2}{3} \cdot {x}^{3}\right)}} \cdot \frac{\sqrt[3]{{\left(2 + \frac{2}{3} \cdot {x}^{3}\right)}^{3} - {\left({x}^{2}\right)}^{3}}}{\sqrt{\left(\left(2 + \frac{2}{3} \cdot {x}^{3}\right) \cdot {x}^{2} + {x}^{2} \cdot {x}^{2}\right) + \left(2 + \frac{2}{3} \cdot {x}^{3}\right) \cdot \left(2 + \frac{2}{3} \cdot {x}^{3}\right)}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(-x\right) \cdot \left(1 - \varepsilon\right)} - e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)} \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    1. Initial program 39.5

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

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

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

      \[\leadsto \frac{\frac{{\left(\frac{2}{3} \cdot {x}^{3} + 2\right)}^{3} - {\left({x}^{2}\right)}^{3}}{\color{blue}{\sqrt{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) \cdot \left(\frac{2}{3} \cdot {x}^{3} + 2\right) + \left({x}^{2} \cdot {x}^{2} + \left(\frac{2}{3} \cdot {x}^{3} + 2\right) \cdot {x}^{2}\right)} \cdot \sqrt{\left(\frac{2}{3} \cdot {x}^{3} + 2\right) \cdot \left(\frac{2}{3} \cdot {x}^{3} + 2\right) + \left({x}^{2} \cdot {x}^{2} + \left(\frac{2}{3} \cdot {x}^{3} + 2\right) \cdot {x}^{2}\right)}}}}{2}\]
    7. Applied add-cube-cbrt1.1

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

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

    if 334.68650982699563 < x

    1. Initial program 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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

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

Reproduce

herbie shell --seed 2018362 +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: 5.1m)Debug log

start511.0ms

Algorithm
intervals

setup239.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 29.9b

localize66.0ms

Local error

Found 4 expressions with local error:

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

rewrite43.0ms

Algorithm
rewrite-expression-head
Counts
4 → 155
Calls

4 calls. Slowest were:

22.0ms
(- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
13.0ms
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))
3.0ms
(* (- 1 eps) x)

series193.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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))))
27.0ms
(* (- 1 eps) x)
22.0ms
(* (+ 1 eps) x)

simplify1.0m

Counts
207 → 167
Calls

207 calls. Slowest were:

1.3s
(- (* (* (+ (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))))
1.1s
(- (* (* (- (* 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))))
1.0s
(- (* (* (- (* 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))))

prune3.2s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize34.0ms

Local error

Found 2 expressions with local error:

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

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
2 → 48
Calls

2 calls. Slowest were:

35.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))
2.0ms
(* 2/3 (pow x 3))

series54.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

28.0ms
(* 2/3 (pow x 3))
26.0ms
(- (+ (* 2/3 (pow x 3)) 2) (pow x 2))

simplify2.3s

Counts
43 → 54
Calls

43 calls. Slowest were:

273.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* (pow x 2) 1)))
221.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* (sqrt (pow x 2)) (sqrt (pow x 2)))))
205.0ms
(fma 1 (+ (* 2/3 (pow x 3)) 2) (- (* x x)))

prune654.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.1b

localize26.0ms

Local error

Found 4 expressions with local error:

13.4b
(/ (- (pow (+ (* 2/3 (pow x 3)) 2) 3) (pow (pow x 2) 3)) (+ (* (+ (* 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)))))
12.4b
(- (pow (+ (* 2/3 (pow x 3)) 2) 3) (pow (pow x 2) 3))
0.1b
(* (pow x 2) (pow x 2))
0.1b
(pow (pow x 2) 3)

rewrite150.0ms

Algorithm
rewrite-expression-head
Counts
4 → 373
Calls

4 calls. Slowest were:

91.0ms
(/ (- (pow (+ (* 2/3 (pow x 3)) 2) 3) (pow (pow x 2) 3)) (+ (* (+ (* 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)))))
35.0ms
(- (pow (+ (* 2/3 (pow x 3)) 2) 3) (pow (pow x 2) 3))
8.0ms
(* (pow x 2) (pow x 2))

series199.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

66.0ms
(- (pow (+ (* 2/3 (pow x 3)) 2) 3) (pow (pow x 2) 3))
65.0ms
(/ (- (pow (+ (* 2/3 (pow x 3)) 2) 3) (pow (pow x 2) 3)) (+ (* (+ (* 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)))))
36.0ms
(* (pow x 2) (pow x 2))
32.0ms
(pow (pow x 2) 3)

simplify2.4m

Counts
565 → 385
Calls

565 calls. Slowest were:

1.2s
(/ (+ (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3)) (* (cbrt (+ (* (+ (* 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))))) (cbrt (+ (* (+ (* 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)))))))
948.0ms
(fma (pow 1 3) (pow (+ (* 2/3 (pow x 3)) 2) 3) (- (* (pow (pow x 2) 3) 1)))
934.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))))

prune7.6s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.1b

localize138.0ms

Local error

Found 4 expressions with local error:

14.9b
(/ (fma (sqrt (fma (* 2/3 x) (* x x) 2)) (fma (* 2/3 x) (* x x) 2) (pow x 3)) (* (cbrt (fma (fma (* 2/3 x) (* x x) 2) (fma (fma x 2/3 1) (* x x) 2) (pow x 4))) (cbrt (fma (fma (* 2/3 x) (* x x) 2) (fma (fma x 2/3 1) (* x x) 2) (pow x 4)))))
11.9b
(/ (- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3)) (cbrt (+ (* (+ (* 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))))))
10.2b
(- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3))
5.6b
(sqrt (fma (* 2/3 x) (* x x) 2))

rewrite147.0ms

Algorithm
rewrite-expression-head
Counts
4 → 271
Calls

4 calls. Slowest were:

98.0ms
(/ (- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3)) (cbrt (+ (* (+ (* 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))))))
32.0ms
(- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3))
11.0ms
(/ (fma (sqrt (fma (* 2/3 x) (* x x) 2)) (fma (* 2/3 x) (* x x) 2) (pow x 3)) (* (cbrt (fma (fma (* 2/3 x) (* x x) 2) (fma (fma x 2/3 1) (* x x) 2) (pow x 4))) (cbrt (fma (fma (* 2/3 x) (* x x) 2) (fma (fma x 2/3 1) (* x x) 2) (pow x 4)))))

series425.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

199.0ms
(/ (fma (sqrt (fma (* 2/3 x) (* x x) 2)) (fma (* 2/3 x) (* x x) 2) (pow x 3)) (* (cbrt (fma (fma (* 2/3 x) (* x x) 2) (fma (fma x 2/3 1) (* x x) 2) (pow x 4))) (cbrt (fma (fma (* 2/3 x) (* x x) 2) (fma (fma x 2/3 1) (* x x) 2) (pow x 4)))))
159.0ms
(/ (- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3)) (cbrt (+ (* (+ (* 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))))))
40.0ms
(- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3))
27.0ms
(sqrt (fma (* 2/3 x) (* x x) 2))

simplify1.3m

Counts
386 → 283
Calls

386 calls. Slowest were:

1.0s
(/ (cbrt (- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3))) (cbrt (+ (* (+ (* 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))))))
1.0s
(/ (fma (sqrt (fma (* 2/3 x) (* x x) 2)) (fma (* 2/3 x) (* x x) 2) (pow x 3)) (cbrt (fma (fma (* 2/3 x) (* x x) 2) (fma (fma x 2/3 1) (* x x) 2) (pow x 4))))
883.0ms
(/ (* (cbrt (- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3))) (cbrt (- (pow (sqrt (+ (* 2/3 (pow x 3)) 2)) 3) (pow x 3)))) (cbrt (* (cbrt (+ (* (+ (* 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))))) (cbrt (+ (* (+ (* 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))))))))

prune5.8s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.1b

regimes284.0ms

Accuracy

97.1% (0.4b remaining)

Error of 0.9b against oracle of 0.4b and baseline of 16.1b

bsearch624.0ms