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

Error

Bits error versus a

Bits error versus x

Target

Original33.8
Comparison8.0
Herbie0.2
\[ \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.575745680979518e-08

    1. Initial program 0.3

      \[e^{a \cdot x} - 1\]
    2. Using strategy rm
    3. Applied flip-- 0.3

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

    if -1.575745680979518e-08 < (* a x)

    1. Initial program 48.1

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

      \[\leadsto \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. Taylor expanded around 0 22.0

      \[\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)}\]
    4. Applied taylor 12.5

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

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

      \[\leadsto \color{blue}{\left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right) \cdot \frac{1}{2} + a \cdot x}\]
  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 '#(1066785882 2324371342 4059510649 1466361199 2701357084 1216585281)'
(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))