Average Error: 30.0 → 0.6
Time: 17.0s
Precision: 64
Internal Precision: 128
\[\left(e^{x} - 2\right) + e^{-x}\]
\[(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*\]

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 30.0

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

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

    \[\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. Final simplification0.6

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

Reproduce

herbie shell --seed 2019010 +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: 16.3s)Debug log

sample132.0ms

Algorithm
intervals

simplify31.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
31.0ms
(+ (- (exp x) 2) (exp (- x)))

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.6b

localize23.0ms

Local error

Found 2 expressions with local error:

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

rewrite51.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
add-log-exp
add-cube-cbrt
frac-add
add-sqr-sqrt
flip--
fma-neg
flip3--
fma-def
log1p-expm1-u
add-exp-log
exp-diff
add-cbrt-cube
sub-neg
associate-+l+
pow1
expm1-log1p-u
exp-neg
neg-sub0
distribute-lft-out
flip-+
associate-+l-
flip3-+
sum-log
+-commutative
Counts
2 → 40
Calls
2 calls:
Slowest
45.0ms
(+ (- (exp x) 2) (exp (- x)))
6.0ms
(- (exp x) 2)

series100.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
91.0ms
(+ (- (exp x) 2) (exp (- x)))
8.0ms
(- (exp x) 2)

simplify1.7s

Counts
23 → 46
Calls
23 calls:
Slowest
493.0ms
(+ (* (- (* (exp x) (exp x)) (* 2 2)) (exp x)) (* (+ (exp x) 2) (exp 0)))
350.0ms
(+ (* (- (pow (exp x) 3) (pow 2 3)) (exp x)) (* (+ (* (exp x) (exp x)) (+ (* 2 2) (* (exp x) 2))) (exp 0)))
163.0ms
(+ (* (- (pow (exp x) 3) (pow 2 3)) (exp x)) (* (+ (* (exp x) (exp x)) (+ (* 2 2) (* (exp x) 2))) 1))
142.0ms
(+ (* (- (* (exp x) (exp x)) (* 2 2)) (exp x)) (* (+ (exp x) 2) 1))
121.0ms
(* (+ (* (exp x) (exp x)) (+ (* 2 2) (* (exp x) 2))) (exp x))

prune402.0ms

Pruning

1 alts after pruning (1 fresh and 0 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
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 1/12 (pow x 4) (fma 1/360 (pow x 6) (* x x)))
0.0ms
(fma 1/360 (pow x 6) (* x x))

series79.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
56.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)))

simplify83.0ms

Counts
6 → 26
Calls
6 calls:
Slowest
28.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))
22.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))
17.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))
5.0ms
(+ (pow x 2) (* 1/360 (pow x 6)))
5.0ms
(+ (pow x 2) (* 1/360 (pow x 6)))

prune253.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize12.0ms

Local error

Found 4 expressions with local error:

30.1b
(cbrt (fma 1/360 (pow x 6) (* x x)))
30.1b
(cbrt (fma 1/360 (pow x 6) (* x x)))
30.1b
(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))))

rewrite11.0ms

Algorithm
rewrite-expression-head
Rules
15×cbrt-prod
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
pow1
pow1/3
add-exp-log
associate-*l*
associate-*r*
add-log-exp
log1p-expm1-u
add-cbrt-cube
expm1-log1p-u
pow-prod-up
pow-prod-down
cbrt-unprod
*-commutative
prod-exp
pow-plus
pow2
Counts
4 → 69
Calls
4 calls:
Slowest
9.0ms
(* (cbrt (fma 1/360 (pow x 6) (* x x))) (cbrt (fma 1/360 (pow x 6) (* x x))))
1.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))
0.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))
0.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))

series2.6s

Counts
4 → 12
Calls
4 calls:
Slowest
715.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))
631.0ms
(* (cbrt (fma 1/360 (pow x 6) (* x x))) (cbrt (fma 1/360 (pow x 6) (* x x))))
630.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))
630.0ms
(cbrt (fma 1/360 (pow x 6) (* x x)))

simplify2.1s

Counts
41 → 81
Calls
41 calls:
Slowest
237.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))))
227.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))))
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))))
203.0ms
(- (+ (exp (* 1/3 (- (log 1/129600) (* 12 (log (/ -1 x)))))) (* 240 (/ (exp (* 1/3 (- (log 1/129600) (* 12 (log (/ -1 x)))))) (pow x 4)))) (* 14400 (/ (exp (* 1/3 (- (log 1/129600) (* 12 (log (/ -1 x)))))) (pow x 8))))
171.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))))

prune955.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

localize22.0ms

Local error

Found 4 expressions with local error:

30.1b
(log (fma 1/360 (pow x 6) (* x x)))
3.0b
(exp (log (fma 1/360 (pow x 6) (* x x))))
0.0b
(fma 1/12 (pow x 4) (exp (log (fma 1/360 (pow x 6) (* x x)))))
0.0b
(fma 1/360 (pow x 6) (* x x))

rewrite8.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
log-prod
pow1
add-exp-log
add-log-exp
log1p-expm1-u
add-cbrt-cube
exp-prod
expm1-log1p-u
exp-sum
fma-udef
log-pow
rem-exp-log
rem-log-exp
Counts
4 → 51
Calls
4 calls:
Slowest
4.0ms
(exp (log (fma 1/360 (pow x 6) (* x x))))
2.0ms
(log (fma 1/360 (pow x 6) (* x x)))
0.0ms
(fma 1/12 (pow x 4) (exp (log (fma 1/360 (pow x 6) (* x x)))))
0.0ms
(fma 1/360 (pow x 6) (* x x))

series591.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
423.0ms
(log (fma 1/360 (pow x 6) (* x x)))
71.0ms
(fma 1/360 (pow x 6) (* x x))
61.0ms
(exp (log (fma 1/360 (pow x 6) (* x x))))
36.0ms
(fma 1/12 (pow x 4) (exp (log (fma 1/360 (pow x 6) (* x x)))))

simplify787.0ms

Counts
23 → 63
Calls
23 calls:
Slowest
317.0ms
(- (+ (log 1/360) (* 360 (/ 1 (pow x 4)))) (+ (* 6 (log (/ -1 x))) (* 64800 (/ 1 (pow x 8)))))
214.0ms
(- (+ (log 1/360) (* 360 (/ 1 (pow x 4)))) (+ (* 6 (log (/ 1 x))) (* 64800 (/ 1 (pow x 8)))))
45.0ms
(- (+ (* 1/360 (pow x 4)) (* 2 (log x))) (* 1/259200 (pow x 8)))
29.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))
24.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))

prune662.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

regimes49.0ms

Accuracy

0% (0.0b remaining)

Error of 0.6b against oracle of 0.6b and baseline of 0.6b

bsearch1.0ms

end0.0ms

sample5.6s

Algorithm
intervals