Average Error: 29.3 → 0.5
Time: 3.7s
Precision: binary64
\[[a, x]=\mathsf{sort}([a, x])\]
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \leq -0.055700088526127754:\\ \;\;\;\;\frac{{\left(e^{a \cdot x}\right)}^{2} + -1}{e^{a \cdot x} + 1}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(x + 0.5 \cdot \left(x \cdot \left(a \cdot x\right)\right)\right)\\ \end{array}\]
e^{a \cdot x} - 1
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -0.055700088526127754:\\
\;\;\;\;\frac{{\left(e^{a \cdot x}\right)}^{2} + -1}{e^{a \cdot x} + 1}\\

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

\end{array}
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
(FPCore (a x)
 :precision binary64
 (if (<= (* a x) -0.055700088526127754)
   (/ (+ (pow (exp (* a x)) 2.0) -1.0) (+ (exp (* a x)) 1.0))
   (* a (+ x (* 0.5 (* x (* a x)))))))
double code(double a, double x) {
	return exp(a * x) - 1.0;
}
double code(double a, double x) {
	double tmp;
	if ((a * x) <= -0.055700088526127754) {
		tmp = (pow(exp(a * x), 2.0) + -1.0) / (exp(a * x) + 1.0);
	} else {
		tmp = a * (x + (0.5 * (x * (a * x))));
	}
	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.3
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 (*.f64 a x) < -0.0557000885261277542

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{\frac{e^{a \cdot x} \cdot e^{a \cdot x} - 1 \cdot 1}{e^{a \cdot x} + 1}}\]
    4. Simplified0.0

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

    if -0.0557000885261277542 < (*.f64 a x)

    1. Initial program 43.7

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

      \[\leadsto \color{blue}{a \cdot x + 0.5 \cdot \left({a}^{2} \cdot {x}^{2}\right)}\]
    3. Simplified4.7

      \[\leadsto \color{blue}{a \cdot \left(x + 0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right)}\]
    4. Using strategy rm
    5. Applied associate-*r*_binary64_7000.8

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

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

Reproduce

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

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