Average Error: 29.4 → 9.4
Time: 4.2s
Precision: 64
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \le -1.252602566255028 \cdot 10^{-12}:\\ \;\;\;\;\frac{\log \left(e^{{\left(e^{a \cdot x}\right)}^{3} - {1}^{3}}\right)}{e^{a \cdot x} \cdot \left(e^{a \cdot x} + 1\right) + 1 \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(a + \left(\frac{1}{2} \cdot {a}^{2}\right) \cdot x\right) + \frac{1}{6} \cdot \left({a}^{3} \cdot {x}^{3}\right)\\ \end{array}\]
e^{a \cdot x} - 1
\begin{array}{l}
\mathbf{if}\;a \cdot x \le -1.252602566255028 \cdot 10^{-12}:\\
\;\;\;\;\frac{\log \left(e^{{\left(e^{a \cdot x}\right)}^{3} - {1}^{3}}\right)}{e^{a \cdot x} \cdot \left(e^{a \cdot x} + 1\right) + 1 \cdot 1}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(a + \left(\frac{1}{2} \cdot {a}^{2}\right) \cdot x\right) + \frac{1}{6} \cdot \left({a}^{3} \cdot {x}^{3}\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) <= -1.252602566255028e-12)) {
		VAR = (log(exp((pow(exp((a * x)), 3.0) - pow(1.0, 3.0)))) / ((exp((a * x)) * (exp((a * x)) + 1.0)) + (1.0 * 1.0)));
	} else {
		VAR = ((x * (a + ((0.5 * pow(a, 2.0)) * x))) + (0.16666666666666666 * (pow(a, 3.0) * pow(x, 3.0))));
	}
	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.4
Target0.2
Herbie9.4
\[\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) < -1.252602566255028e-12

    1. Initial program 0.6

      \[e^{a \cdot x} - 1\]
    2. Using strategy rm
    3. Applied flip3--0.6

      \[\leadsto \color{blue}{\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)}}\]
    4. Simplified0.6

      \[\leadsto \frac{{\left(e^{a \cdot x}\right)}^{3} - {1}^{3}}{\color{blue}{e^{a \cdot x} \cdot \left(e^{a \cdot x} + 1\right) + 1 \cdot 1}}\]
    5. Using strategy rm
    6. Applied add-log-exp0.6

      \[\leadsto \frac{{\left(e^{a \cdot x}\right)}^{3} - \color{blue}{\log \left(e^{{1}^{3}}\right)}}{e^{a \cdot x} \cdot \left(e^{a \cdot x} + 1\right) + 1 \cdot 1}\]
    7. Applied add-log-exp0.6

      \[\leadsto \frac{\color{blue}{\log \left(e^{{\left(e^{a \cdot x}\right)}^{3}}\right)} - \log \left(e^{{1}^{3}}\right)}{e^{a \cdot x} \cdot \left(e^{a \cdot x} + 1\right) + 1 \cdot 1}\]
    8. Applied diff-log0.6

      \[\leadsto \frac{\color{blue}{\log \left(\frac{e^{{\left(e^{a \cdot x}\right)}^{3}}}{e^{{1}^{3}}}\right)}}{e^{a \cdot x} \cdot \left(e^{a \cdot x} + 1\right) + 1 \cdot 1}\]
    9. Simplified0.6

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

    if -1.252602566255028e-12 < (* a x)

    1. Initial program 44.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot x \le -1.252602566255028 \cdot 10^{-12}:\\ \;\;\;\;\frac{\log \left(e^{{\left(e^{a \cdot x}\right)}^{3} - {1}^{3}}\right)}{e^{a \cdot x} \cdot \left(e^{a \cdot x} + 1\right) + 1 \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(a + \left(\frac{1}{2} \cdot {a}^{2}\right) \cdot x\right) + \frac{1}{6} \cdot \left({a}^{3} \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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