Average Error: 29.4 → 0.0
Time: 1.3m
Precision: 64
Internal Precision: 1344
\[\left(e^{x} - 2\right) + e^{-x}\]
\[\begin{array}{l} \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \le 0.0005649456083830266:\\ \;\;\;\;(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\left({x}^{6}\right) \cdot \frac{1}{360} + \left(x \cdot x\right))_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\left(e^{x} - 2\right) + e^{-x}\right)}\\ \end{array}\]

Error

Bits error versus x

Target

Original29.4
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.0005649456083830266

    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. Applied simplify0.0

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

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

    1. Initial program 1.6

      \[\left(e^{x} - 2\right) + e^{-x}\]
    2. Using strategy rm
    3. Applied add-exp-log2.0

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

Runtime

Time bar (total: 1.3m)Debug logProfile

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

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

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