Average Error: 29.6 → 0.3
Time: 21.5s
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 5648266.524304729:\\ \;\;\;\;(\frac{1}{12} \cdot \left({x}^{4}\right) + \left(\sqrt{(\left({x}^{6}\right) \cdot \frac{1}{360} + \left(x \cdot x\right))_*} \cdot \sqrt{(\left({x}^{6}\right) \cdot \frac{1}{360} + \left(x \cdot x\right))_*}\right))_*\\ \mathbf{else}:\\ \;\;\;\;e^{x} + \left(\left(-2\right) + e^{-x}\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original29.6
Target0.0
Herbie0.3
\[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))) < 5648266.524304729

    1. Initial program 29.8

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

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

      \[\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))_*}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt0.3

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

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

    1. Initial program 0

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

      \[\leadsto \color{blue}{\left(e^{x} + \left(-2\right)\right)} + e^{-x}\]
    4. Applied associate-+l+0

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

Runtime

Time bar (total: 21.5s)Debug logProfile

herbie shell --seed '#(1070131407 1246090267 3027482374 2150728003 2026520792 2347815650)' +o rules:numerics
(FPCore (x)
  :name "exp2 (problem 3.3.7)"

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

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