Average Error: 29.3 → 0.0
Time: 19.6s
Precision: 64
Internal Precision: 128
\[\left(e^{x} - 2\right) + e^{-x}\]
\[\begin{array}{l} \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \le 0.00020891152756186138:\\ \;\;\;\;\sqrt{(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*} \cdot \sqrt{(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array}\]

Error

Bits error versus x

Target

Original29.3
Target0.0
Herbie0.0
\[4 \cdot {\left(\sinh \left(\frac{x}{2}\right)\right)}^{2}\]

Derivation

  1. Split input into 2 regimes
  2. if (+ (- (exp x) 2) (exp (- x))) < 0.00020891152756186138

    1. Initial program 29.8

      \[\left(e^{x} - 2\right) + e^{-x}\]
    2. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{{x}^{2} + \left(\frac{1}{12} \cdot {x}^{4} + \frac{1}{360} \cdot {x}^{6}\right)}\]
    3. Simplified0.0

      \[\leadsto \color{blue}{(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt0.0

      \[\leadsto \color{blue}{\sqrt{(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*} \cdot \sqrt{(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*}}\]

    if 0.00020891152756186138 < (+ (- (exp x) 2) (exp (- x)))

    1. Initial program 1.8

      \[\left(e^{x} - 2\right) + e^{-x}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \le 0.00020891152756186138:\\ \;\;\;\;\sqrt{(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*} \cdot \sqrt{(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019005 +o rules:numerics
(FPCore (x)
  :name "exp2 (problem 3.3.7)"

  :herbie-target
  (* 4 (pow (sinh (/ x 2)) 2))

  (+ (- (exp x) 2) (exp (- x))))

Details

Time bar (total: 18.8s)Debug log

sample128.0ms

Algorithm
intervals

simplify38.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

38.0ms
(+ (- (exp x) 2) (exp (- x)))

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.5b

localize51.0ms

Local error

Found 2 expressions with local error:

3.0b
(+ (- (exp x) 2) (exp (- x)))
0.0b
(- (exp x) 2)

rewrite36.0ms

Algorithm
rewrite-expression-head
Counts
2 → 40
Calls

2 calls. Slowest were:

29.0ms
(+ (- (exp x) 2) (exp (- x)))
6.0ms
(- (exp x) 2)

series122.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

108.0ms
(+ (- (exp x) 2) (exp (- x)))
13.0ms
(- (exp x) 2)

simplify1.7s

Counts
23 → 46
Calls

23 calls. Slowest were:

444.0ms
(+ (* (- (pow (exp x) 3) (pow 2 3)) (exp x)) (* (+ (* (exp x) (exp x)) (+ (* 2 2) (* (exp x) 2))) (exp 0)))
260.0ms
(+ (* (- (pow (exp x) 3) (pow 2 3)) (exp x)) (* (+ (* (exp x) (exp x)) (+ (* 2 2) (* (exp x) 2))) 1))
246.0ms
(+ (* (- (* (exp x) (exp x)) (* 2 2)) (exp x)) (* (+ (exp x) 2) (exp 0)))

prune353.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize18.0ms

Local error

Found 2 expressions with local error:

0.0b
(fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))
0.0b
(fma 1/360 (pow x 6) (* x x))

rewrite1.0ms

Algorithm
rewrite-expression-head
Counts
2 → 20
Calls

2 calls. Slowest were:

0.0ms
(fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))
0.0ms
(fma 1/360 (pow x 6) (* x x))

series86.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

63.0ms
(fma 1/360 (pow x 6) (* x x))
23.0ms
(fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))

simplify123.0ms

Counts
6 → 26
Calls

6 calls. Slowest were:

32.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))
30.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))
29.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))

prune281.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0b

localize11.0ms

Local error

Found 4 expressions with local error:

25.7b
(sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))))
25.7b
(sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))))
0.0b
(* (sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))) (sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))))
0.0b
(fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

8.0ms
(* (sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))) (sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))))
1.0ms
(sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))))
1.0ms
(sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))))

series162.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

67.0ms
(sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))))
41.0ms
(sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))))
30.0ms
(* (sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))) (sqrt (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))))
24.0ms
(fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))

simplify3.0s

Counts
42 → 82
Calls

42 calls. Slowest were:

507.0ms
(* (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))) (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))))
458.0ms
(* (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))) (fma 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x))))
358.0ms
(- (+ (* 1/2 (/ 1 (* (sqrt 1/360) x))) (+ (* (sqrt 1/360) (pow x 3)) (* 1/24 (/ x (sqrt 1/360))))) (* 1/1152 (/ 1 (* (pow (sqrt 1/360) 3) x))))

prune900.0ms

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0b

localize27.0ms

Local error

Found 4 expressions with local error:

26.7b
(cbrt (fma 1/360 (pow x 6) (* x x)))
26.7b
(cbrt (fma 1/360 (pow x 6) (* x x)))
26.7b
(cbrt (fma 1/360 (pow x 6) (* x x)))
0.4b
(* (cbrt (fma 1/360 (pow x 6) (* x x))) (cbrt (fma 1/360 (pow x 6) (* x x))))

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

10.0ms
(* (cbrt (fma 1/360 (pow x 6) (* x x))) (cbrt (fma 1/360 (pow x 6) (* x x))))
6.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))
1.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))

series2.8s

Counts
4 → 12
Calls

4 calls. Slowest were:

750.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))
740.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))
666.0ms
(* (cbrt (fma 1/360 (pow x 6) (* x x))) (cbrt (fma 1/360 (pow x 6) (* x x))))
658.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))

simplify1.9s

Counts
41 → 81
Calls

41 calls. Slowest were:

214.0ms
(- (+ (* 120 (/ (exp (* 1/3 (- (log 1/360) (* 6 (log (/ -1 x)))))) (pow x 4))) (exp (* 1/3 (- (log 1/360) (* 6 (log (/ -1 x))))))) (* 14400 (/ (exp (* 1/3 (- (log 1/360) (* 6 (log (/ -1 x)))))) (pow x 8))))
193.0ms
(- (+ (* 120 (/ (exp (* 1/3 (- (log 1/360) (* 6 (log (/ -1 x)))))) (pow x 4))) (exp (* 1/3 (- (log 1/360) (* 6 (log (/ -1 x))))))) (* 14400 (/ (exp (* 1/3 (- (log 1/360) (* 6 (log (/ -1 x)))))) (pow x 8))))
163.0ms
(- (+ (* 120 (/ (exp (* 1/3 (- (log 1/360) (* 6 (log (/ 1 x)))))) (pow x 4))) (exp (* 1/3 (- (log 1/360) (* 6 (log (/ 1 x))))))) (* 14400 (/ (exp (* 1/3 (- (log 1/360) (* 6 (log (/ 1 x)))))) (pow x 8))))

prune953.0ms

Pruning

5 alts after pruning (1 fresh and 4 done)

Merged error: 0b

regimes123.0ms

Accuracy

97.9% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 0.7b

bsearch6.0ms

end0.0ms

sample5.9s

Algorithm
intervals