Average Error: 32.0 → 9.8
Time: 30.1s
Precision: 64
Internal precision: 1408
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \le -1.6430626687800177 \cdot 10^{-13}:\\ \;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left({x}^{3} \cdot \left(a \cdot \frac{1}{6}\right) + x \cdot \left(\frac{1}{2} \cdot x\right)\right) + a \cdot x\\ \end{array}\]

Error

Bits error versus a

Bits error versus x

Target

Original32.0
Comparison5.6
Herbie9.8
\[ \begin{array}{l} \mathbf{if}\;\left|a \cdot x\right| \lt \frac{1}{10}:\\ \;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(\frac{a \cdot x}{2} + \frac{{\left(a \cdot x\right)}^{2}}{6}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{a \cdot x} - 1\\ \end{array} \]

Derivation

  1. Split input into 2 regimes.
  2. if (* a x) < -1.6430626687800177e-13

    1. Initial program 0.7

      \[e^{a \cdot x} - 1\]
    2. Using strategy rm
    3. Applied add-log-exp 0.7

      \[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]

    if -1.6430626687800177e-13 < (* a x)

    1. Initial program 46.8

      \[e^{a \cdot x} - 1\]
    2. Using strategy rm
    3. Applied add-log-exp 46.8

      \[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]
    4. Applied taylor 47.6

      \[\leadsto \log \left(e^{\frac{1}{6} \cdot \left({a}^{3} \cdot {x}^{3}\right) + \left(\frac{1}{2} \cdot \left({a}^{2} \cdot {x}^{2}\right) + a \cdot x\right)}\right)\]
    5. Taylor expanded around 0 47.6

      \[\leadsto \log \left(e^{\color{blue}{\frac{1}{6} \cdot \left({a}^{3} \cdot {x}^{3}\right) + \left(\frac{1}{2} \cdot \left({a}^{2} \cdot {x}^{2}\right) + a \cdot x\right)}}\right)\]
    6. Applied simplify 14.1

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left({x}^{3} \cdot \left(a \cdot \frac{1}{6}\right) + x \cdot \left(\frac{1}{2} \cdot x\right)\right) + a \cdot x}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 30.1s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1068028399 4028058041 2917032441 2563479541 765645300 1132738916)'
(FPCore (a x)
  :name "expax (section 3.5)"

  :target
  (if (< (fabs (* a x)) 1/10) (* (* a x) (+ 1 (+ (/ (* a x) 2) (/ (pow (* a x) 2) 6)))) (- (exp (* a x)) 1))

  (- (exp (* a x)) 1))