Average Error: 29.5 → 0.1
Time: 38.4s
Precision: 64
Internal Precision: 1408
\[\left(e^{x} - 2\right) + e^{-x}\]
\[\begin{array}{l} \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \le 0.13163264838209376:\\ \;\;\;\;{x}^{2} + \left(\frac{1}{12} \cdot {x}^{4} + \frac{1}{360} \cdot {x}^{6}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{3} - {2}^{3}}{2 \cdot 2 + e^{x} \cdot \left(2 + e^{x}\right)} + e^{-x}\\ \end{array}\]

Error

Bits error versus x

Target

Original29.5
Target0.0
Herbie0.1
\[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.13163264838209376

    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)}\]

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

    1. Initial program 0.2

      \[\left(e^{x} - 2\right) + e^{-x}\]
    2. Using strategy rm
    3. Applied flip3--4.3

      \[\leadsto \color{blue}{\frac{{\left(e^{x}\right)}^{3} - {2}^{3}}{e^{x} \cdot e^{x} + \left(2 \cdot 2 + e^{x} \cdot 2\right)}} + e^{-x}\]
    4. Applied simplify4.3

      \[\leadsto \frac{{\left(e^{x}\right)}^{3} - {2}^{3}}{\color{blue}{2 \cdot 2 + e^{x} \cdot \left(2 + e^{x}\right)}} + e^{-x}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 38.4s)Debug log

herbie shell --seed '#(212267722 3993171362 1093346726 3605783651 2106536041 3335990851)' 
(FPCore (x)
  :name "exp2 (problem 3.3.7)"

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

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