Average Error: 32.5 → 0.1
Time: 7.8s
Precision: 64
Internal precision: 1408
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \le -4.709279699649899 \cdot 10^{-06}:\\ \;\;\;\;e^{a \cdot x} - 1\\ \mathbf{else}:\\ \;\;\;\;x \cdot a + \left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) \cdot \left(\frac{1}{2} + \left(a \cdot \frac{1}{6}\right) \cdot x\right)\\ \end{array}\]

Error

Bits error versus a

Bits error versus x

Target

Original32.5
Comparison5.8
Herbie0.1
\[ \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) < -4.709279699649899e-06

    1. Initial program 0.1

      \[e^{a \cdot x} - 1\]

    if -4.709279699649899e-06 < (* a x)

    1. Initial program 47.1

      \[e^{a \cdot x} - 1\]
    2. Using strategy rm
    3. Applied add-cbrt-cube 47.1

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

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

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

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

Runtime

Time bar (total: 7.8s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064875752 1442698706 3150723005 1316518582 2592983078 3835530843)'
(FPCore (a x)
  :name "expax (section 3.5)"

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

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