Average Error: 29.3 → 0.0
Time: 25.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{{x}^{2} + \left(\frac{1}{360} \cdot {x}^{6} + {x}^{4} \cdot \frac{1}{12}\right)} \cdot \sqrt{{x}^{2} + \left(\frac{1}{360} \cdot {x}^{6} + {x}^{4} \cdot \frac{1}{12}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. Using strategy rm
    4. Applied add-sqr-sqrt0.0

      \[\leadsto \color{blue}{\sqrt{{x}^{2} + \left(\frac{1}{12} \cdot {x}^{4} + \frac{1}{360} \cdot {x}^{6}\right)} \cdot \sqrt{{x}^{2} + \left(\frac{1}{12} \cdot {x}^{4} + \frac{1}{360} \cdot {x}^{6}\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{{x}^{2} + \left(\frac{1}{360} \cdot {x}^{6} + {x}^{4} \cdot \frac{1}{12}\right)} \cdot \sqrt{{x}^{2} + \left(\frac{1}{360} \cdot {x}^{6} + {x}^{4} \cdot \frac{1}{12}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019005 
(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: 24.8s)Debug log

sample183.0ms

Algorithm
intervals

simplify23.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.5b

localize22.0ms

Local error

Found 2 expressions with local error:

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

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
2 → 30
Calls

2 calls. Slowest were:

22.0ms
(+ (- (exp x) 2) (exp (- x)))
3.0ms
(- (exp x) 2)

series110.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

97.0ms
(+ (- (exp x) 2) (exp (- x)))
14.0ms
(- (exp x) 2)

simplify1.5s

Counts
19 → 36
Calls

19 calls. Slowest were:

395.0ms
(+ (* (- (pow (exp x) 3) (pow 2 3)) (exp x)) (* (+ (* (exp x) (exp x)) (+ (* 2 2) (* (exp x) 2))) (exp 0)))
270.0ms
(+ (* (- (pow (exp x) 3) (pow 2 3)) (exp x)) (* (+ (* (exp x) (exp x)) (+ (* 2 2) (* (exp x) 2))) 1))
247.0ms
(+ (* (- (* (exp x) (exp x)) (* 2 2)) (exp x)) (* (+ (exp x) 2) (exp 0)))

prune269.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 4 expressions with local error:

0.1b
(* 1/12 (pow x 4))
0.1b
(* 1/360 (pow x 6))
0.0b
(+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))
0.0b
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 47
Calls

4 calls. Slowest were:

7.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))
3.0ms
(+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))
1.0ms
(* 1/12 (pow x 4))

series177.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

86.0ms
(+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))
43.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))
28.0ms
(* 1/12 (pow x 4))
19.0ms
(* 1/360 (pow x 6))

simplify266.0ms

Counts
23 → 59
Calls

23 calls. Slowest were:

57.0ms
(* (exp (pow x 2)) (* (exp (* 1/12 (pow x 4))) (exp (* 1/360 (pow x 6)))))
45.0ms
(* (exp (pow x 2)) (exp (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
26.0ms
(+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))

prune641.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

25.7b
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
25.7b
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
0.1b
(* 1/12 (pow x 4))
0.1b
(* 1/12 (pow x 4))

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

10.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
8.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
2.0ms
(* 1/12 (pow x 4))

series143.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

55.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
51.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
21.0ms
(* 1/12 (pow x 4))
15.0ms
(* 1/12 (pow x 4))

simplify2.0s

Counts
32 → 64
Calls

32 calls. Slowest were:

279.0ms
(- (* 1/1152 (/ 1 (* (pow (sqrt 1/360) 3) x))) (+ (* 1/2 (/ 1 (* (sqrt 1/360) x))) (+ (* (sqrt 1/360) (pow x 3)) (* 1/24 (/ x (sqrt 1/360))))))
273.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))))
263.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))))

prune964.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 4 expressions with local error:

37.7b
(cbrt (* (* (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))) (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))) (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))))
25.7b
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
25.7b
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
25.7b
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))

rewrite96.0ms

Algorithm
rewrite-expression-head
Counts
4 → 81
Calls

4 calls. Slowest were:

48.0ms
(cbrt (* (* (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))) (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))) (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))))
15.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
15.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))

series204.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
47.0ms
(cbrt (* (* (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))) (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))) (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))))
47.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))
40.0ms
(sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))

simplify10.8s

Counts
61 → 93
Calls

61 calls. Slowest were:

869.0ms
(cbrt (* (* (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))) (sqrt (- (* (pow x 2) (pow x 2)) (* (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))))))) (sqrt (+ (pow (pow x 2) 3) (pow (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))) 3)))))
505.0ms
(cbrt (* (* (sqrt (- (* (pow x 2) (pow x 2)) (* (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))) (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))) (sqrt (+ (pow (pow x 2) 3) (pow (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))) 3)))))
503.0ms
(cbrt (* (* (sqrt (- (* (pow x 2) (pow x 2)) (* (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))) (sqrt (+ (pow (pow x 2) 3) (pow (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6))) 3)))) (sqrt (+ (pow x 2) (+ (* 1/12 (pow x 4)) (* 1/360 (pow x 6)))))))

prune1.6s

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0b

regimes80.0ms

Accuracy

98.7% (0.0b remaining)

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

bsearch4.0ms

end0.0ms

sample5.7s

Algorithm
intervals