Average Error: 29.3 → 0.8
Time: 4.3s
Precision: binary64
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \leq -178940.03251794667:\\ \;\;\;\;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 -178940.03251794667:\\
\;\;\;\;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}
double code(double a, double x) {
	return ((double) (((double) exp(((double) (a * x)))) - 1.0));
}
double code(double a, double x) {
	double VAR;
	if ((((double) (a * x)) <= -178940.03251794667)) {
		VAR = ((double) (((double) exp(((double) (a * x)))) - 1.0));
	} else {
		VAR = ((double) (((double) (a * x)) + ((double) (a * ((double) (x * ((double) (a * ((double) (x * 0.5))))))))));
	}
	return VAR;
}

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.8
\[\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) < -178940.03251794667

    1. Initial program 0

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

    if -178940.03251794667 < (* a x)

    1. Initial program 43.4

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

      \[\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. Simplified7.8

      \[\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 8.8

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

      \[\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*1.2

      \[\leadsto a \cdot x + a \cdot \color{blue}{\left(\left(\left(a \cdot 0.5\right) \cdot x\right) \cdot x\right)}\]
    8. Simplified1.2

      \[\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 simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot x \leq -178940.03251794667:\\ \;\;\;\;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 2020196 
(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))