Average Error: 29.7 → 0.7
Time: 7.5s
Precision: binary64
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \leq -24.510704068554325:\\ \;\;\;\;\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 + \sqrt[3]{0.125 \cdot {\left(a \cdot x\right)}^{6}}\\ \end{array}\]
e^{a \cdot x} - 1
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -24.510704068554325:\\
\;\;\;\;\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 + \sqrt[3]{0.125 \cdot {\left(a \cdot x\right)}^{6}}\\

\end{array}
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
(FPCore (a x)
 :precision binary64
 (if (<= (* a x) -24.510704068554325)
   (-
    (* (cbrt (exp (* a x))) (* (cbrt (exp (* a x))) (cbrt (exp (* a x)))))
    1.0)
   (+ (* a x) (cbrt (* 0.125 (pow (* a x) 6.0))))))
double code(double a, double x) {
	return exp(a * x) - 1.0;
}
double code(double a, double x) {
	double tmp;
	if ((a * x) <= -24.510704068554325) {
		tmp = (cbrt(exp(a * x)) * (cbrt(exp(a * x)) * cbrt(exp(a * x)))) - 1.0;
	} else {
		tmp = (a * x) + cbrt(0.125 * pow((a * x), 6.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.7
Target0.2
Herbie0.7
\[\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) < -24.510704068554325

    1. Initial program 0

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

      \[\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 -24.510704068554325 < (*.f64 a x)

    1. Initial program 44.4

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

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

      \[\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_13821.1

      \[\leadsto a \cdot \left(x + 0.5 \cdot \color{blue}{\left(\left(a \cdot x\right) \cdot x\right)}\right)\]
    6. Using strategy rm
    7. Applied distribute-rgt-in_binary64_13921.1

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

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

      \[\leadsto a \cdot x + \color{blue}{a \cdot \left(0.5 \cdot \left(x \cdot \left(a \cdot x\right)\right)\right)}\]
    10. Using strategy rm
    11. Applied add-cbrt-cube_binary64_14781.1

      \[\leadsto a \cdot x + \color{blue}{\sqrt[3]{\left(\left(a \cdot \left(0.5 \cdot \left(x \cdot \left(a \cdot x\right)\right)\right)\right) \cdot \left(a \cdot \left(0.5 \cdot \left(x \cdot \left(a \cdot x\right)\right)\right)\right)\right) \cdot \left(a \cdot \left(0.5 \cdot \left(x \cdot \left(a \cdot x\right)\right)\right)\right)}}\]
    12. Simplified1.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot x \leq -24.510704068554325:\\ \;\;\;\;\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 + \sqrt[3]{0.125 \cdot {\left(a \cdot x\right)}^{6}}\\ \end{array}\]

Reproduce

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