Average Error: 29.6 → 0.5
Time: 2.3s
Precision: binary64
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \leq -0.04069334585048068:\\ \;\;\;\;e^{a \cdot x} - 1\\ \mathbf{else}:\\ \;\;\;\;a \cdot x + a \cdot \left(x \cdot \left(a \cdot \left(x \cdot 0.5\right)\right)\right)\\ \end{array}\]
e^{a \cdot x} - 1
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -0.04069334585048068:\\
\;\;\;\;e^{a \cdot x} - 1\\

\mathbf{else}:\\
\;\;\;\;a \cdot x + a \cdot \left(x \cdot \left(a \cdot \left(x \cdot 0.5\right)\right)\right)\\

\end{array}
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
(FPCore (a x)
 :precision binary64
 (if (<= (* a x) -0.04069334585048068)
   (- (exp (* a x)) 1.0)
   (+ (* a x) (* a (* x (* a (* x 0.5)))))))
double code(double a, double x) {
	return ((double) (((double) exp(((double) (a * x)))) - 1.0));
}
double code(double a, double x) {
	double tmp;
	if ((((double) (a * x)) <= -0.04069334585048068)) {
		tmp = ((double) (((double) exp(((double) (a * x)))) - 1.0));
	} else {
		tmp = ((double) (((double) (a * x)) + ((double) (a * ((double) (x * ((double) (a * ((double) (x * 0.5))))))))));
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.6
Target0.2
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;\left|a \cdot x\right| < 0.1:\\ \;\;\;\;\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) < -0.040693345850480678

    1. Initial program Error: 0.0 bits

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

    if -0.040693345850480678 < (* a x)

    1. Initial program Error: 44.7 bits

      \[e^{a \cdot x} - 1\]
    2. Taylor expanded around 0 Error: 14.3 bits

      \[\leadsto \color{blue}{0.5 \cdot \left({a}^{2} \cdot {x}^{2}\right) + \left(0.16666666666666666 \cdot \left({a}^{3} \cdot {x}^{3}\right) + a \cdot x\right)}\]
    3. SimplifiedError: 8.0 bits

      \[\leadsto \color{blue}{x \cdot \left(a + x \cdot \left(a \cdot \left(a \cdot 0.5\right) + x \cdot \left(0.16666666666666666 \cdot {a}^{3}\right)\right)\right)}\]
    4. Taylor expanded around 0 Error: 8.3 bits

      \[\leadsto \color{blue}{0.5 \cdot \left({a}^{2} \cdot {x}^{2}\right) + a \cdot x}\]
    5. SimplifiedError: 4.4 bits

      \[\leadsto \color{blue}{a \cdot x + a \cdot \left(\left(a \cdot 0.5\right) \cdot \left(x \cdot x\right)\right)}\]
    6. Using strategy rm
    7. Applied associate-*r*Error: 0.7 bits

      \[\leadsto a \cdot x + a \cdot \color{blue}{\left(\left(\left(a \cdot 0.5\right) \cdot x\right) \cdot x\right)}\]
    8. SimplifiedError: 0.7 bits

      \[\leadsto a \cdot x + a \cdot \left(\color{blue}{\left(a \cdot \left(0.5 \cdot x\right)\right)} \cdot x\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplificationError: 0.5 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot x \leq -0.04069334585048068:\\ \;\;\;\;e^{a \cdot x} - 1\\ \mathbf{else}:\\ \;\;\;\;a \cdot x + a \cdot \left(x \cdot \left(a \cdot \left(x \cdot 0.5\right)\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020203 
(FPCore (a x)
  :name "expax (section 3.5)"
  :precision binary64
  :herbie-expected 14

  :herbie-target
  (if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1.0 (+ (/ (* a x) 2.0) (/ (pow (* a x) 2.0) 6.0)))) (- (exp (* a x)) 1.0))

  (- (exp (* a x)) 1.0))