Average Error: 29.2 → 0.7
Time: 20.4s
Precision: 64
Internal Precision: 1408
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;e^{a \cdot x} - 1 \le -1.7422210768657467 \cdot 10^{-13}:\\ \;\;\;\;\left(\sqrt{e^{a \cdot x}} + 1\right) \cdot \left(\sqrt{e^{a \cdot x}} - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) \cdot \frac{1}{2} + x \cdot a\\ \end{array}\]

Error

Bits error versus a

Bits error versus x

Target

Original29.2
Target0.2
Herbie0.7
\[\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 (- (exp (* a x)) 1) < -1.7422210768657467e-13

    1. Initial program 0.7

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

      \[\leadsto \color{blue}{\sqrt{e^{a \cdot x}} \cdot \sqrt{e^{a \cdot x}}} - 1\]
    4. Applied difference-of-sqr-10.8

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

    if -1.7422210768657467e-13 < (- (exp (* a x)) 1)

    1. Initial program 44.3

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

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

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

Runtime

Time bar (total: 20.4s)Debug logProfile

herbie shell --seed '#(1064173506 2580572819 2847706409 4129882574 1125180799 1845288547)' 
(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))