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

Error

Bits error versus a

Bits error versus x

Target

Original33.1
Comparison7.9
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) < -3.0996483699306456e-06

    1. Initial program 0.1

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

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

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

    1. Initial program 47.1

      \[e^{a \cdot x} - 1\]
    2. Applied taylor 43.2

      \[\leadsto \left(x \cdot a + \left(1 + \frac{1}{2} \cdot \left({x}^2 \cdot {a}^2\right)\right)\right) - 1\]
    3. Taylor expanded around 0 43.2

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

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

Runtime

Time bar (total: 20.8s) Debug log

Please include this information when filing a bug report:

herbie shell --seed '#(3283856077 3183919125 3399458751 396155847 3688194147 1862413033)'
(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))