Average Error: 29.3 → 0.3
Time: 19.6s
Precision: 64
Internal Precision: 128
\[\left(e^{x} - 2\right) + e^{-x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.035151046141674525:\\ \;\;\;\;\left(e^{x} + -2\right) + e^{-x}\\ \mathbf{else}:\\ \;\;\;\;(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*\\ \end{array}\]

Error

Bits error versus x

Target

Original29.3
Target0.1
Herbie0.3
\[4 \cdot {\left(\sinh \left(\frac{x}{2}\right)\right)}^{2}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -0.035151046141674525

    1. Initial program 1.3

      \[\left(e^{x} - 2\right) + e^{-x}\]
    2. Initial simplification1.5

      \[\leadsto \left(e^{x} - 2\right) - \frac{-1}{e^{x}}\]
    3. Taylor expanded around -inf 1.6

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

      \[\leadsto \color{blue}{e^{-x} + \left(e^{x} + -2\right)}\]

    if -0.035151046141674525 < x

    1. Initial program 29.5

      \[\left(e^{x} - 2\right) + e^{-x}\]
    2. Initial simplification29.5

      \[\leadsto \left(e^{x} - 2\right) - \frac{-1}{e^{x}}\]
    3. 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)}\]
    4. Simplified0.3

      \[\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))_*}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.035151046141674525:\\ \;\;\;\;\left(e^{x} + -2\right) + e^{-x}\\ \mathbf{else}:\\ \;\;\;\;(\frac{1}{12} \cdot \left({x}^{4}\right) + \left((\frac{1}{360} \cdot \left({x}^{6}\right) + \left(x \cdot x\right))_*\right))_*\\ \end{array}\]

Runtime

Time bar (total: 19.6s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes0.60.30.00.659.1%
herbie shell --seed 2018354 +o rules:numerics
(FPCore (x)
  :name "exp2 (problem 3.3.7)"

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

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