Average Error: 30.0 → 0.3
Time: 4.4s
Precision: binary64
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \leq -0.2007229212737903:\\ \;\;\;\;\sqrt[3]{{\left(e^{a \cdot x} - 1\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot x + 0.16666666666666666 \cdot {\left(a \cdot x\right)}^{3}\right) + \left(0.5 \cdot {\left(a \cdot x\right)}^{2} + 0.041666666666666664 \cdot {\left(a \cdot x\right)}^{4}\right)\\ \end{array}\]
e^{a \cdot x} - 1
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -0.2007229212737903:\\
\;\;\;\;\sqrt[3]{{\left(e^{a \cdot x} - 1\right)}^{3}}\\

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

\end{array}
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
(FPCore (a x)
 :precision binary64
 (if (<= (* a x) -0.2007229212737903)
   (cbrt (pow (- (exp (* a x)) 1.0) 3.0))
   (+
    (+ (* a x) (* 0.16666666666666666 (pow (* a x) 3.0)))
    (+ (* 0.5 (pow (* a x) 2.0)) (* 0.041666666666666664 (pow (* a x) 4.0))))))
double code(double a, double x) {
	return exp(a * x) - 1.0;
}
double code(double a, double x) {
	double tmp;
	if ((a * x) <= -0.2007229212737903) {
		tmp = cbrt(pow((exp(a * x) - 1.0), 3.0));
	} else {
		tmp = ((a * x) + (0.16666666666666666 * pow((a * x), 3.0))) + ((0.5 * pow((a * x), 2.0)) + (0.041666666666666664 * pow((a * x), 4.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

Original30.0
Target0.2
Herbie0.3
\[\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.200722921273790295

    1. Initial program 0.0

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

      \[\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.0

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

    if -0.200722921273790295 < (*.f64 a x)

    1. Initial program 44.4

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

      \[\leadsto \color{blue}{a \cdot x + \left(0.16666666666666666 \cdot \left({a}^{3} \cdot {x}^{3}\right) + \left(0.5 \cdot \left({a}^{2} \cdot {x}^{2}\right) + 0.041666666666666664 \cdot \left({a}^{4} \cdot {x}^{4}\right)\right)\right)}\]
    3. Simplified0.5

      \[\leadsto \color{blue}{a \cdot x + \left(0.16666666666666666 \cdot {\left(a \cdot x\right)}^{3} + \left(0.5 \cdot {\left(a \cdot x\right)}^{2} + 0.041666666666666664 \cdot {\left(a \cdot x\right)}^{4}\right)\right)}\]
    4. Using strategy rm
    5. Applied associate-+r+_binary640.5

      \[\leadsto \color{blue}{\left(a \cdot x + 0.16666666666666666 \cdot {\left(a \cdot x\right)}^{3}\right) + \left(0.5 \cdot {\left(a \cdot x\right)}^{2} + 0.041666666666666664 \cdot {\left(a \cdot x\right)}^{4}\right)}\]
    6. Simplified0.5

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

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

Reproduce

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