Average Error: 29.0 → 0.4
Time: 2.3s
Precision: binary64
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \leq -1.2065385524619287 \cdot 10^{-05}:\\ \;\;\;\;\sqrt[3]{e^{a \cdot x}} \cdot \left(\sqrt[3]{e^{a \cdot x}} \cdot \sqrt[3]{e^{a \cdot x}}\right) - 1\\ \mathbf{else}:\\ \;\;\;\;a \cdot x + 0.5 \cdot {\left(a \cdot x\right)}^{2}\\ \end{array}\]
e^{a \cdot x} - 1
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -1.2065385524619287 \cdot 10^{-05}:\\
\;\;\;\;\sqrt[3]{e^{a \cdot x}} \cdot \left(\sqrt[3]{e^{a \cdot x}} \cdot \sqrt[3]{e^{a \cdot x}}\right) - 1\\

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

\end{array}
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
(FPCore (a x)
 :precision binary64
 (if (<= (* a x) -1.2065385524619287e-05)
   (-
    (* (cbrt (exp (* a x))) (* (cbrt (exp (* a x))) (cbrt (exp (* a x)))))
    1.0)
   (+ (* a x) (* 0.5 (pow (* a x) 2.0)))))
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)) <= -1.2065385524619287e-05)) {
		tmp = ((double) (((double) (((double) cbrt(((double) exp(((double) (a * x)))))) * ((double) (((double) cbrt(((double) exp(((double) (a * x)))))) * ((double) cbrt(((double) exp(((double) (a * x)))))))))) - 1.0));
	} else {
		tmp = ((double) (((double) (a * x)) + ((double) (0.5 * ((double) pow(((double) (a * x)), 2.0))))));
	}
	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.0
Target0.1
Herbie0.4
\[\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) < -1.20653855246192871e-5

    1. Initial program 0.1

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

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

    if -1.20653855246192871e-5 < (*.f64 a x)

    1. Initial program 44.2

      \[e^{a \cdot x} - 1\]
    2. Taylor expanded around 0 13.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.3

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

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

      \[\leadsto \color{blue}{a \cdot x + 0.5 \cdot \left(\left(a \cdot a\right) \cdot \left(x \cdot x\right)\right)}\]
    6. Using strategy rm
    7. Applied pow2_binary647.9

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

      \[\leadsto a \cdot x + 0.5 \cdot \left(\color{blue}{{a}^{2}} \cdot {x}^{2}\right)\]
    9. Applied pow-prod-down_binary640.5

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

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

Reproduce

herbie shell --seed 2020205 
(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))