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

Error

Bits error versus a

Bits error versus x

Target

Original32.1
Target5.6
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) < -1.4691043195228787e-06

    1. Initial program 0.1

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

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

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

    1. Initial program 46.8

      \[e^{a \cdot x} - 1\]
    2. Taylor expanded around 0 17.6

      \[\leadsto \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)}\]
    3. Using strategy rm
    4. Applied pow-prod-down11.3

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

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

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

Runtime

Time bar (total: 1.9m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (a x)
  :name "expax (section 3.5)"

  :herbie-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))