Average Error: 29.8 → 9.3
Time: 5.2s
Precision: 64
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \le -6.4881712685880057 \cdot 10^{-15}:\\ \;\;\;\;\sqrt[3]{\frac{{\left(e^{\left(a \cdot x\right) \cdot 3} - {1}^{3}\right)}^{3}}{{\left(\mathsf{fma}\left(1, e^{a \cdot x} + 1, e^{a \cdot x + a \cdot x}\right)\right)}^{3}}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, {a}^{2} \cdot {x}^{2}, \mathsf{fma}\left(\frac{1}{6}, {a}^{3} \cdot {x}^{3}, a \cdot x\right)\right)\\ \end{array}\]
e^{a \cdot x} - 1
\begin{array}{l}
\mathbf{if}\;a \cdot x \le -6.4881712685880057 \cdot 10^{-15}:\\
\;\;\;\;\sqrt[3]{\frac{{\left(e^{\left(a \cdot x\right) \cdot 3} - {1}^{3}\right)}^{3}}{{\left(\mathsf{fma}\left(1, e^{a \cdot x} + 1, e^{a \cdot x + a \cdot x}\right)\right)}^{3}}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{2}, {a}^{2} \cdot {x}^{2}, \mathsf{fma}\left(\frac{1}{6}, {a}^{3} \cdot {x}^{3}, a \cdot x\right)\right)\\

\end{array}
double code(double a, double x) {
	return (exp((a * x)) - 1.0);
}
double code(double a, double x) {
	double VAR;
	if (((a * x) <= -6.488171268588006e-15)) {
		VAR = cbrt((pow((exp(((a * x) * 3.0)) - pow(1.0, 3.0)), 3.0) / pow(fma(1.0, (exp((a * x)) + 1.0), exp(((a * x) + (a * x)))), 3.0)));
	} else {
		VAR = fma(0.5, (pow(a, 2.0) * pow(x, 2.0)), fma(0.16666666666666666, (pow(a, 3.0) * pow(x, 3.0)), (a * x)));
	}
	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.8
Target0.2
Herbie9.3
\[\begin{array}{l} \mathbf{if}\;\left|a \cdot x\right| \lt 0.10000000000000001:\\ \;\;\;\;\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) < -6.488171268588006e-15

    1. Initial program 0.8

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

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(e^{a \cdot x} - 1\right) \cdot \left(e^{a \cdot x} - 1\right)\right) \cdot \left(e^{a \cdot x} - 1\right)}}\]
    4. Simplified0.8

      \[\leadsto \sqrt[3]{\color{blue}{{\left(e^{a \cdot x} - 1\right)}^{3}}}\]
    5. Using strategy rm
    6. Applied flip3--0.8

      \[\leadsto \sqrt[3]{{\color{blue}{\left(\frac{{\left(e^{a \cdot x}\right)}^{3} - {1}^{3}}{e^{a \cdot x} \cdot e^{a \cdot x} + \left(1 \cdot 1 + e^{a \cdot x} \cdot 1\right)}\right)}}^{3}}\]
    7. Applied cube-div0.8

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

      \[\leadsto \sqrt[3]{\frac{{\left({\left(e^{a \cdot x}\right)}^{3} - {1}^{3}\right)}^{3}}{\color{blue}{{\left(\mathsf{fma}\left(1, e^{a \cdot x} + 1, e^{a \cdot x + a \cdot x}\right)\right)}^{3}}}}\]
    9. Using strategy rm
    10. Applied pow-exp0.7

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

    if -6.488171268588006e-15 < (* a x)

    1. Initial program 45.1

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {a}^{2} \cdot {x}^{2}, \mathsf{fma}\left(\frac{1}{6}, {a}^{3} \cdot {x}^{3}, a \cdot x\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification9.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot x \le -6.4881712685880057 \cdot 10^{-15}:\\ \;\;\;\;\sqrt[3]{\frac{{\left(e^{\left(a \cdot x\right) \cdot 3} - {1}^{3}\right)}^{3}}{{\left(\mathsf{fma}\left(1, e^{a \cdot x} + 1, e^{a \cdot x + a \cdot x}\right)\right)}^{3}}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, {a}^{2} \cdot {x}^{2}, \mathsf{fma}\left(\frac{1}{6}, {a}^{3} \cdot {x}^{3}, a \cdot x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020106 +o rules:numerics
(FPCore (a x)
  :name "expax (section 3.5)"
  :precision binary64
  :herbie-expected 14

  :herbie-target
  (if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1 (+ (/ (* a x) 2) (/ (pow (* a x) 2) 6)))) (- (exp (* a x)) 1))

  (- (exp (* a x)) 1))