Average Error: 38.0 → 8.7
Time: 22.4s
Precision: 64
Ground Truth: 128
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \le -1.1501639825495647 \cdot 10^{-13}:\\ \;\;\;\;e^{a \cdot x} - 1\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(a \cdot x + {\left(a \cdot x\right)}^2\right)}{1 + e^{a \cdot x}}\\ \end{array}\]

Error

Bits error versus a

Bits error versus x

Target

Original38.0
Comparison15.9
Herbie8.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 (* a x) < -1.1501639825495647e-13

    1. Initial program 0.8

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

    if -1.1501639825495647e-13 < (* a x)

    1. Initial program 51.5

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

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

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

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

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

Runtime

Total time: 22.4s Debug log

Please include this information when filing a bug report:

herbie --seed '#(1964145002 3596466598 2249905545 2281660312 2216507096 1439778181)'
(FPCore (a x)
  :name "NMSE 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))