expax (section 3.5)

Percentage Accurate: 54.2% → 100.0%
Time: 6.3s
Alternatives: 8
Speedup: 18.2×

Specification

?
\[710 > a \cdot x\]
\[\begin{array}{l} \\ e^{a \cdot x} - 1 \end{array} \]
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
double code(double a, double x) {
	return exp((a * x)) - 1.0;
}
real(8) function code(a, x)
    real(8), intent (in) :: a
    real(8), intent (in) :: x
    code = exp((a * x)) - 1.0d0
end function
public static double code(double a, double x) {
	return Math.exp((a * x)) - 1.0;
}
def code(a, x):
	return math.exp((a * x)) - 1.0
function code(a, x)
	return Float64(exp(Float64(a * x)) - 1.0)
end
function tmp = code(a, x)
	tmp = exp((a * x)) - 1.0;
end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

\\
e^{a \cdot x} - 1
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 54.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ e^{a \cdot x} - 1 \end{array} \]
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
double code(double a, double x) {
	return exp((a * x)) - 1.0;
}
real(8) function code(a, x)
    real(8), intent (in) :: a
    real(8), intent (in) :: x
    code = exp((a * x)) - 1.0d0
end function
public static double code(double a, double x) {
	return Math.exp((a * x)) - 1.0;
}
def code(a, x):
	return math.exp((a * x)) - 1.0
function code(a, x)
	return Float64(exp(Float64(a * x)) - 1.0)
end
function tmp = code(a, x)
	tmp = exp((a * x)) - 1.0;
end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

\\
e^{a \cdot x} - 1
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{expm1}\left(x \cdot a\right) \end{array} \]
(FPCore (a x) :precision binary64 (expm1 (* x a)))
double code(double a, double x) {
	return expm1((x * a));
}
public static double code(double a, double x) {
	return Math.expm1((x * a));
}
def code(a, x):
	return math.expm1((x * a))
function code(a, x)
	return expm1(Float64(x * a))
end
code[a_, x_] := N[(Exp[N[(x * a), $MachinePrecision]] - 1), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{expm1}\left(x \cdot a\right)
\end{array}
Derivation
  1. Initial program 54.2%

    \[e^{a \cdot x} - 1 \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{e^{a \cdot x} - 1} \]
    2. lift-exp.f64N/A

      \[\leadsto \color{blue}{e^{a \cdot x}} - 1 \]
    3. lower-expm1.f64100.0

      \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    4. lift-*.f64N/A

      \[\leadsto \mathsf{expm1}\left(\color{blue}{a \cdot x}\right) \]
    5. *-commutativeN/A

      \[\leadsto \mathsf{expm1}\left(\color{blue}{x \cdot a}\right) \]
    6. lower-*.f64100.0

      \[\leadsto \mathsf{expm1}\left(\color{blue}{x \cdot a}\right) \]
  4. Applied rewrites100.0%

    \[\leadsto \color{blue}{\mathsf{expm1}\left(x \cdot a\right)} \]
  5. Add Preprocessing

Alternative 2: 80.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{a \cdot x} \leq 0:\\ \;\;\;\;\left(\frac{{a}^{-1}}{a} \cdot a\right) \cdot a - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664 \cdot x, a, 0.16666666666666666\right), x \cdot a, 0.5\right) \cdot x, a, 1\right) \cdot \left(x \cdot a\right)\\ \end{array} \end{array} \]
(FPCore (a x)
 :precision binary64
 (if (<= (exp (* a x)) 0.0)
   (- (* (* (/ (pow a -1.0) a) a) a) 1.0)
   (*
    (fma
     (*
      (fma (fma (* 0.041666666666666664 x) a 0.16666666666666666) (* x a) 0.5)
      x)
     a
     1.0)
    (* x a))))
double code(double a, double x) {
	double tmp;
	if (exp((a * x)) <= 0.0) {
		tmp = (((pow(a, -1.0) / a) * a) * a) - 1.0;
	} else {
		tmp = fma((fma(fma((0.041666666666666664 * x), a, 0.16666666666666666), (x * a), 0.5) * x), a, 1.0) * (x * a);
	}
	return tmp;
}
function code(a, x)
	tmp = 0.0
	if (exp(Float64(a * x)) <= 0.0)
		tmp = Float64(Float64(Float64(Float64((a ^ -1.0) / a) * a) * a) - 1.0);
	else
		tmp = Float64(fma(Float64(fma(fma(Float64(0.041666666666666664 * x), a, 0.16666666666666666), Float64(x * a), 0.5) * x), a, 1.0) * Float64(x * a));
	end
	return tmp
end
code[a_, x_] := If[LessEqual[N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision], 0.0], N[(N[(N[(N[(N[Power[a, -1.0], $MachinePrecision] / a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.041666666666666664 * x), $MachinePrecision] * a + 0.16666666666666666), $MachinePrecision] * N[(x * a), $MachinePrecision] + 0.5), $MachinePrecision] * x), $MachinePrecision] * a + 1.0), $MachinePrecision] * N[(x * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{a \cdot x} \leq 0:\\
\;\;\;\;\left(\frac{{a}^{-1}}{a} \cdot a\right) \cdot a - 1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664 \cdot x, a, 0.16666666666666666\right), x \cdot a, 0.5\right) \cdot x, a, 1\right) \cdot \left(x \cdot a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 (*.f64 a x)) < 0.0

    1. Initial program 100.0%

      \[e^{a \cdot x} - 1 \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0

      \[\leadsto \color{blue}{\left(1 + a \cdot \left(x + \frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)} - 1 \]
    4. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)}\right) - 1 \]
      2. associate-*r*N/A

        \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot {x}^{2}\right)}\right)\right) - 1 \]
      3. unpow2N/A

        \[\leadsto \left(1 + \left(a \cdot x + a \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) - 1 \]
      4. associate-*r*N/A

        \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot x\right)}\right)\right) - 1 \]
      5. *-commutativeN/A

        \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(x \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)\right)}\right)\right) - 1 \]
      6. associate-*r*N/A

        \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(a \cdot x\right) \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
      7. *-commutativeN/A

        \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot \left(a \cdot x\right)}\right)\right) - 1 \]
      8. distribute-rgt1-inN/A

        \[\leadsto \left(1 + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x + 1\right) \cdot \left(a \cdot x\right)}\right) - 1 \]
      9. *-commutativeN/A

        \[\leadsto \left(1 + \left(\color{blue}{x \cdot \left(\frac{1}{2} \cdot a\right)} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
      10. associate-*r*N/A

        \[\leadsto \left(1 + \left(\color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot a} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
      11. distribute-rgt1-inN/A

        \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + \left(\left(x \cdot \frac{1}{2}\right) \cdot a\right) \cdot \left(a \cdot x\right)\right)}\right) - 1 \]
      12. associate-*r*N/A

        \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot \left(a \cdot \left(a \cdot x\right)\right)}\right)\right) - 1 \]
      13. associate-*l*N/A

        \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
      14. unpow2N/A

        \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{{a}^{2}} \cdot x\right)\right)\right) - 1 \]
      15. associate-*r*N/A

        \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right)\right) - 1 \]
      16. *-commutativeN/A

        \[\leadsto \left(1 + \left(\color{blue}{x \cdot a} + x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right)\right) - 1 \]
      17. distribute-lft-inN/A

        \[\leadsto \left(1 + \color{blue}{x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right) - 1 \]
      18. *-rgt-identityN/A

        \[\leadsto \left(1 + \color{blue}{\left(x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right) \cdot 1}\right) - 1 \]
    5. Applied rewrites1.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, 0.5, a\right), x, 1\right)} - 1 \]
    6. Step-by-step derivation
      1. Applied rewrites0.6%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{a}, \mathsf{fma}\left(x \cdot x, \left(0.5 \cdot a\right) \cdot a, 1\right)\right) - 1 \]
      2. Taylor expanded in a around -inf

        \[\leadsto {a}^{2} \cdot \color{blue}{\left(-1 \cdot \frac{-1 \cdot x - \frac{1}{a}}{a} + \frac{1}{2} \cdot {x}^{2}\right)} - 1 \]
      3. Step-by-step derivation
        1. Applied rewrites8.7%

          \[\leadsto \left(\mathsf{fma}\left(0.5 \cdot x, x, \frac{x + \frac{1}{a}}{a}\right) \cdot a\right) \cdot \color{blue}{a} - 1 \]
        2. Taylor expanded in a around 0

          \[\leadsto \left(\frac{1}{{a}^{2}} \cdot a\right) \cdot a - 1 \]
        3. Step-by-step derivation
          1. Applied rewrites50.5%

            \[\leadsto \left(\frac{\frac{1}{a}}{a} \cdot a\right) \cdot a - 1 \]

          if 0.0 < (exp.f64 (*.f64 a x))

          1. Initial program 34.1%

            \[e^{a \cdot x} - 1 \]
          2. Add Preprocessing
          3. Taylor expanded in a around 0

            \[\leadsto \color{blue}{a \cdot \left(x + a \cdot \left(\frac{1}{2} \cdot {x}^{2} + a \cdot \left(\frac{1}{24} \cdot \left(a \cdot {x}^{4}\right) + \frac{1}{6} \cdot {x}^{3}\right)\right)\right)} \]
          4. Applied rewrites99.6%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664 \cdot x, a, 0.16666666666666666\right), x \cdot a, 0.5\right) \cdot x, a, 1\right) \cdot \left(x \cdot a\right)} \]
        4. Recombined 2 regimes into one program.
        5. Final simplification84.6%

          \[\leadsto \begin{array}{l} \mathbf{if}\;e^{a \cdot x} \leq 0:\\ \;\;\;\;\left(\frac{{a}^{-1}}{a} \cdot a\right) \cdot a - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664 \cdot x, a, 0.16666666666666666\right), x \cdot a, 0.5\right) \cdot x, a, 1\right) \cdot \left(x \cdot a\right)\\ \end{array} \]
        6. Add Preprocessing

        Alternative 3: 80.6% accurate, 0.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{a \cdot x} \leq 0:\\ \;\;\;\;\left(\frac{{a}^{-1}}{a} \cdot a\right) \cdot a - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot x, a, 0.5\right) \cdot a, x, 1\right) \cdot \left(x \cdot a\right)\\ \end{array} \end{array} \]
        (FPCore (a x)
         :precision binary64
         (if (<= (exp (* a x)) 0.0)
           (- (* (* (/ (pow a -1.0) a) a) a) 1.0)
           (* (fma (* (fma (* 0.16666666666666666 x) a 0.5) a) x 1.0) (* x a))))
        double code(double a, double x) {
        	double tmp;
        	if (exp((a * x)) <= 0.0) {
        		tmp = (((pow(a, -1.0) / a) * a) * a) - 1.0;
        	} else {
        		tmp = fma((fma((0.16666666666666666 * x), a, 0.5) * a), x, 1.0) * (x * a);
        	}
        	return tmp;
        }
        
        function code(a, x)
        	tmp = 0.0
        	if (exp(Float64(a * x)) <= 0.0)
        		tmp = Float64(Float64(Float64(Float64((a ^ -1.0) / a) * a) * a) - 1.0);
        	else
        		tmp = Float64(fma(Float64(fma(Float64(0.16666666666666666 * x), a, 0.5) * a), x, 1.0) * Float64(x * a));
        	end
        	return tmp
        end
        
        code[a_, x_] := If[LessEqual[N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision], 0.0], N[(N[(N[(N[(N[Power[a, -1.0], $MachinePrecision] / a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(0.16666666666666666 * x), $MachinePrecision] * a + 0.5), $MachinePrecision] * a), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * a), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;e^{a \cdot x} \leq 0:\\
        \;\;\;\;\left(\frac{{a}^{-1}}{a} \cdot a\right) \cdot a - 1\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot x, a, 0.5\right) \cdot a, x, 1\right) \cdot \left(x \cdot a\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (exp.f64 (*.f64 a x)) < 0.0

          1. Initial program 100.0%

            \[e^{a \cdot x} - 1 \]
          2. Add Preprocessing
          3. Taylor expanded in a around 0

            \[\leadsto \color{blue}{\left(1 + a \cdot \left(x + \frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)} - 1 \]
          4. Step-by-step derivation
            1. distribute-lft-inN/A

              \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)}\right) - 1 \]
            2. associate-*r*N/A

              \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot {x}^{2}\right)}\right)\right) - 1 \]
            3. unpow2N/A

              \[\leadsto \left(1 + \left(a \cdot x + a \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) - 1 \]
            4. associate-*r*N/A

              \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot x\right)}\right)\right) - 1 \]
            5. *-commutativeN/A

              \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(x \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)\right)}\right)\right) - 1 \]
            6. associate-*r*N/A

              \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(a \cdot x\right) \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
            7. *-commutativeN/A

              \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot \left(a \cdot x\right)}\right)\right) - 1 \]
            8. distribute-rgt1-inN/A

              \[\leadsto \left(1 + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x + 1\right) \cdot \left(a \cdot x\right)}\right) - 1 \]
            9. *-commutativeN/A

              \[\leadsto \left(1 + \left(\color{blue}{x \cdot \left(\frac{1}{2} \cdot a\right)} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
            10. associate-*r*N/A

              \[\leadsto \left(1 + \left(\color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot a} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
            11. distribute-rgt1-inN/A

              \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + \left(\left(x \cdot \frac{1}{2}\right) \cdot a\right) \cdot \left(a \cdot x\right)\right)}\right) - 1 \]
            12. associate-*r*N/A

              \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot \left(a \cdot \left(a \cdot x\right)\right)}\right)\right) - 1 \]
            13. associate-*l*N/A

              \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
            14. unpow2N/A

              \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{{a}^{2}} \cdot x\right)\right)\right) - 1 \]
            15. associate-*r*N/A

              \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right)\right) - 1 \]
            16. *-commutativeN/A

              \[\leadsto \left(1 + \left(\color{blue}{x \cdot a} + x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right)\right) - 1 \]
            17. distribute-lft-inN/A

              \[\leadsto \left(1 + \color{blue}{x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right) - 1 \]
            18. *-rgt-identityN/A

              \[\leadsto \left(1 + \color{blue}{\left(x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right) \cdot 1}\right) - 1 \]
          5. Applied rewrites1.2%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, 0.5, a\right), x, 1\right)} - 1 \]
          6. Step-by-step derivation
            1. Applied rewrites0.6%

              \[\leadsto \mathsf{fma}\left(x, \color{blue}{a}, \mathsf{fma}\left(x \cdot x, \left(0.5 \cdot a\right) \cdot a, 1\right)\right) - 1 \]
            2. Taylor expanded in a around -inf

              \[\leadsto {a}^{2} \cdot \color{blue}{\left(-1 \cdot \frac{-1 \cdot x - \frac{1}{a}}{a} + \frac{1}{2} \cdot {x}^{2}\right)} - 1 \]
            3. Step-by-step derivation
              1. Applied rewrites8.7%

                \[\leadsto \left(\mathsf{fma}\left(0.5 \cdot x, x, \frac{x + \frac{1}{a}}{a}\right) \cdot a\right) \cdot \color{blue}{a} - 1 \]
              2. Taylor expanded in a around 0

                \[\leadsto \left(\frac{1}{{a}^{2}} \cdot a\right) \cdot a - 1 \]
              3. Step-by-step derivation
                1. Applied rewrites50.5%

                  \[\leadsto \left(\frac{\frac{1}{a}}{a} \cdot a\right) \cdot a - 1 \]

                if 0.0 < (exp.f64 (*.f64 a x))

                1. Initial program 34.1%

                  \[e^{a \cdot x} - 1 \]
                2. Add Preprocessing
                3. Taylor expanded in a around 0

                  \[\leadsto \color{blue}{a \cdot \left(x + a \cdot \left(\frac{1}{6} \cdot \left(a \cdot {x}^{3}\right) + \frac{1}{2} \cdot {x}^{2}\right)\right)} \]
                4. Applied rewrites99.5%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot x, a, 0.5\right) \cdot a, x, 1\right) \cdot \left(x \cdot a\right)} \]
              4. Recombined 2 regimes into one program.
              5. Final simplification84.6%

                \[\leadsto \begin{array}{l} \mathbf{if}\;e^{a \cdot x} \leq 0:\\ \;\;\;\;\left(\frac{{a}^{-1}}{a} \cdot a\right) \cdot a - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot x, a, 0.5\right) \cdot a, x, 1\right) \cdot \left(x \cdot a\right)\\ \end{array} \]
              6. Add Preprocessing

              Alternative 4: 71.2% accurate, 0.5× speedup?

              \[\begin{array}{l} \\ {\left({\left(x \cdot a\right)}^{-1} - 0.5\right)}^{-1} \end{array} \]
              (FPCore (a x) :precision binary64 (pow (- (pow (* x a) -1.0) 0.5) -1.0))
              double code(double a, double x) {
              	return pow((pow((x * a), -1.0) - 0.5), -1.0);
              }
              
              real(8) function code(a, x)
                  real(8), intent (in) :: a
                  real(8), intent (in) :: x
                  code = (((x * a) ** (-1.0d0)) - 0.5d0) ** (-1.0d0)
              end function
              
              public static double code(double a, double x) {
              	return Math.pow((Math.pow((x * a), -1.0) - 0.5), -1.0);
              }
              
              def code(a, x):
              	return math.pow((math.pow((x * a), -1.0) - 0.5), -1.0)
              
              function code(a, x)
              	return Float64((Float64(x * a) ^ -1.0) - 0.5) ^ -1.0
              end
              
              function tmp = code(a, x)
              	tmp = (((x * a) ^ -1.0) - 0.5) ^ -1.0;
              end
              
              code[a_, x_] := N[Power[N[(N[Power[N[(x * a), $MachinePrecision], -1.0], $MachinePrecision] - 0.5), $MachinePrecision], -1.0], $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              {\left({\left(x \cdot a\right)}^{-1} - 0.5\right)}^{-1}
              \end{array}
              
              Derivation
              1. Initial program 54.2%

                \[e^{a \cdot x} - 1 \]
              2. Add Preprocessing
              3. Taylor expanded in a around 0

                \[\leadsto \color{blue}{\left(1 + a \cdot \left(x + \frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)} - 1 \]
              4. Step-by-step derivation
                1. distribute-lft-inN/A

                  \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)}\right) - 1 \]
                2. associate-*r*N/A

                  \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot {x}^{2}\right)}\right)\right) - 1 \]
                3. unpow2N/A

                  \[\leadsto \left(1 + \left(a \cdot x + a \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) - 1 \]
                4. associate-*r*N/A

                  \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot x\right)}\right)\right) - 1 \]
                5. *-commutativeN/A

                  \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(x \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)\right)}\right)\right) - 1 \]
                6. associate-*r*N/A

                  \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(a \cdot x\right) \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
                7. *-commutativeN/A

                  \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot \left(a \cdot x\right)}\right)\right) - 1 \]
                8. distribute-rgt1-inN/A

                  \[\leadsto \left(1 + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x + 1\right) \cdot \left(a \cdot x\right)}\right) - 1 \]
                9. *-commutativeN/A

                  \[\leadsto \left(1 + \left(\color{blue}{x \cdot \left(\frac{1}{2} \cdot a\right)} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
                10. associate-*r*N/A

                  \[\leadsto \left(1 + \left(\color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot a} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
                11. distribute-rgt1-inN/A

                  \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + \left(\left(x \cdot \frac{1}{2}\right) \cdot a\right) \cdot \left(a \cdot x\right)\right)}\right) - 1 \]
                12. associate-*r*N/A

                  \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot \left(a \cdot \left(a \cdot x\right)\right)}\right)\right) - 1 \]
                13. associate-*l*N/A

                  \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
                14. unpow2N/A

                  \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{{a}^{2}} \cdot x\right)\right)\right) - 1 \]
                15. associate-*r*N/A

                  \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right)\right) - 1 \]
                16. *-commutativeN/A

                  \[\leadsto \left(1 + \left(\color{blue}{x \cdot a} + x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right)\right) - 1 \]
                17. distribute-lft-inN/A

                  \[\leadsto \left(1 + \color{blue}{x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right) - 1 \]
                18. *-rgt-identityN/A

                  \[\leadsto \left(1 + \color{blue}{\left(x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right) \cdot 1}\right) - 1 \]
              5. Applied rewrites23.4%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, 0.5, a\right), x, 1\right)} - 1 \]
              6. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) - 1} \]
                2. flip3--N/A

                  \[\leadsto \color{blue}{\frac{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}} \]
                3. clear-numN/A

                  \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}}} \]
                4. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}}} \]
              7. Applied rewrites23.4%

                \[\leadsto \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, \left(a \cdot a\right) \cdot x, a\right), x, 1\right) - 1}}} \]
              8. Taylor expanded in x around 0

                \[\leadsto \frac{1}{\color{blue}{\frac{\frac{-1}{2} \cdot x + \frac{1}{a}}{x}}} \]
              9. Step-by-step derivation
                1. lower-/.f64N/A

                  \[\leadsto \frac{1}{\color{blue}{\frac{\frac{-1}{2} \cdot x + \frac{1}{a}}{x}}} \]
                2. lower-fma.f64N/A

                  \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{a}\right)}}{x}} \]
                3. lower-/.f6473.3

                  \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-0.5, x, \color{blue}{\frac{1}{a}}\right)}{x}} \]
              10. Applied rewrites73.3%

                \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(-0.5, x, \frac{1}{a}\right)}{x}}} \]
              11. Taylor expanded in a around inf

                \[\leadsto \frac{1}{\frac{1}{a \cdot x} - \color{blue}{\frac{1}{2}}} \]
              12. Step-by-step derivation
                1. Applied rewrites73.5%

                  \[\leadsto \frac{1}{\frac{1}{x \cdot a} - \color{blue}{0.5}} \]
                2. Final simplification73.5%

                  \[\leadsto {\left({\left(x \cdot a\right)}^{-1} - 0.5\right)}^{-1} \]
                3. Add Preprocessing

                Alternative 5: 71.7% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot x \leq -50000000:\\ \;\;\;\;{-0.5}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(0.5, a \cdot x, 1\right) \cdot a\right) \cdot x\\ \end{array} \end{array} \]
                (FPCore (a x)
                 :precision binary64
                 (if (<= (* a x) -50000000.0)
                   (pow -0.5 -1.0)
                   (* (* (fma 0.5 (* a x) 1.0) a) x)))
                double code(double a, double x) {
                	double tmp;
                	if ((a * x) <= -50000000.0) {
                		tmp = pow(-0.5, -1.0);
                	} else {
                		tmp = (fma(0.5, (a * x), 1.0) * a) * x;
                	}
                	return tmp;
                }
                
                function code(a, x)
                	tmp = 0.0
                	if (Float64(a * x) <= -50000000.0)
                		tmp = -0.5 ^ -1.0;
                	else
                		tmp = Float64(Float64(fma(0.5, Float64(a * x), 1.0) * a) * x);
                	end
                	return tmp
                end
                
                code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -50000000.0], N[Power[-0.5, -1.0], $MachinePrecision], N[(N[(N[(0.5 * N[(a * x), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] * x), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;a \cdot x \leq -50000000:\\
                \;\;\;\;{-0.5}^{-1}\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(\mathsf{fma}\left(0.5, a \cdot x, 1\right) \cdot a\right) \cdot x\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (*.f64 a x) < -5e7

                  1. Initial program 100.0%

                    \[e^{a \cdot x} - 1 \]
                  2. Add Preprocessing
                  3. Taylor expanded in a around 0

                    \[\leadsto \color{blue}{\left(1 + a \cdot \left(x + \frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)} - 1 \]
                  4. Step-by-step derivation
                    1. distribute-lft-inN/A

                      \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)}\right) - 1 \]
                    2. associate-*r*N/A

                      \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot {x}^{2}\right)}\right)\right) - 1 \]
                    3. unpow2N/A

                      \[\leadsto \left(1 + \left(a \cdot x + a \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) - 1 \]
                    4. associate-*r*N/A

                      \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot x\right)}\right)\right) - 1 \]
                    5. *-commutativeN/A

                      \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(x \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)\right)}\right)\right) - 1 \]
                    6. associate-*r*N/A

                      \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(a \cdot x\right) \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
                    7. *-commutativeN/A

                      \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot \left(a \cdot x\right)}\right)\right) - 1 \]
                    8. distribute-rgt1-inN/A

                      \[\leadsto \left(1 + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x + 1\right) \cdot \left(a \cdot x\right)}\right) - 1 \]
                    9. *-commutativeN/A

                      \[\leadsto \left(1 + \left(\color{blue}{x \cdot \left(\frac{1}{2} \cdot a\right)} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
                    10. associate-*r*N/A

                      \[\leadsto \left(1 + \left(\color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot a} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
                    11. distribute-rgt1-inN/A

                      \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + \left(\left(x \cdot \frac{1}{2}\right) \cdot a\right) \cdot \left(a \cdot x\right)\right)}\right) - 1 \]
                    12. associate-*r*N/A

                      \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot \left(a \cdot \left(a \cdot x\right)\right)}\right)\right) - 1 \]
                    13. associate-*l*N/A

                      \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
                    14. unpow2N/A

                      \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{{a}^{2}} \cdot x\right)\right)\right) - 1 \]
                    15. associate-*r*N/A

                      \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right)\right) - 1 \]
                    16. *-commutativeN/A

                      \[\leadsto \left(1 + \left(\color{blue}{x \cdot a} + x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right)\right) - 1 \]
                    17. distribute-lft-inN/A

                      \[\leadsto \left(1 + \color{blue}{x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right) - 1 \]
                    18. *-rgt-identityN/A

                      \[\leadsto \left(1 + \color{blue}{\left(x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right) \cdot 1}\right) - 1 \]
                  5. Applied rewrites1.2%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, 0.5, a\right), x, 1\right)} - 1 \]
                  6. Step-by-step derivation
                    1. lift--.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) - 1} \]
                    2. flip3--N/A

                      \[\leadsto \color{blue}{\frac{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}} \]
                    3. clear-numN/A

                      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}}} \]
                    4. lower-/.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}}} \]
                  7. Applied rewrites1.2%

                    \[\leadsto \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, \left(a \cdot a\right) \cdot x, a\right), x, 1\right) - 1}}} \]
                  8. Taylor expanded in x around 0

                    \[\leadsto \frac{1}{\color{blue}{\frac{\frac{-1}{2} \cdot x + \frac{1}{a}}{x}}} \]
                  9. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{-1}{2} \cdot x + \frac{1}{a}}{x}}} \]
                    2. lower-fma.f64N/A

                      \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{a}\right)}}{x}} \]
                    3. lower-/.f6418.8

                      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-0.5, x, \color{blue}{\frac{1}{a}}\right)}{x}} \]
                  10. Applied rewrites18.8%

                    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(-0.5, x, \frac{1}{a}\right)}{x}}} \]
                  11. Taylor expanded in a around inf

                    \[\leadsto \frac{1}{\frac{-1}{2}} \]
                  12. Step-by-step derivation
                    1. Applied rewrites18.8%

                      \[\leadsto \frac{1}{-0.5} \]

                    if -5e7 < (*.f64 a x)

                    1. Initial program 34.1%

                      \[e^{a \cdot x} - 1 \]
                    2. Add Preprocessing
                    3. Step-by-step derivation
                      1. lift--.f64N/A

                        \[\leadsto \color{blue}{e^{a \cdot x} - 1} \]
                      2. lift-exp.f64N/A

                        \[\leadsto \color{blue}{e^{a \cdot x}} - 1 \]
                      3. lower-expm1.f64100.0

                        \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
                      4. lift-*.f64N/A

                        \[\leadsto \mathsf{expm1}\left(\color{blue}{a \cdot x}\right) \]
                      5. *-commutativeN/A

                        \[\leadsto \mathsf{expm1}\left(\color{blue}{x \cdot a}\right) \]
                      6. lower-*.f64100.0

                        \[\leadsto \mathsf{expm1}\left(\color{blue}{x \cdot a}\right) \]
                    4. Applied rewrites100.0%

                      \[\leadsto \color{blue}{\mathsf{expm1}\left(x \cdot a\right)} \]
                    5. Taylor expanded in a around 0

                      \[\leadsto \color{blue}{a \cdot \left(x + \frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)} \]
                    6. Step-by-step derivation
                      1. distribute-lft-inN/A

                        \[\leadsto \color{blue}{a \cdot x + a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)} \]
                      2. associate-*r*N/A

                        \[\leadsto a \cdot x + \color{blue}{\left(a \cdot \frac{1}{2}\right) \cdot \left(a \cdot {x}^{2}\right)} \]
                      3. *-commutativeN/A

                        \[\leadsto a \cdot x + \color{blue}{\left(\frac{1}{2} \cdot a\right)} \cdot \left(a \cdot {x}^{2}\right) \]
                      4. associate-*r*N/A

                        \[\leadsto a \cdot x + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot a\right) \cdot {x}^{2}} \]
                      5. associate-*r*N/A

                        \[\leadsto a \cdot x + \color{blue}{\left(\frac{1}{2} \cdot \left(a \cdot a\right)\right)} \cdot {x}^{2} \]
                      6. unpow2N/A

                        \[\leadsto a \cdot x + \left(\frac{1}{2} \cdot \color{blue}{{a}^{2}}\right) \cdot {x}^{2} \]
                      7. unpow2N/A

                        \[\leadsto a \cdot x + \left(\frac{1}{2} \cdot {a}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
                      8. associate-*r*N/A

                        \[\leadsto a \cdot x + \color{blue}{\left(\left(\frac{1}{2} \cdot {a}^{2}\right) \cdot x\right) \cdot x} \]
                      9. associate-*r*N/A

                        \[\leadsto a \cdot x + \color{blue}{\left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)} \cdot x \]
                      10. distribute-rgt-inN/A

                        \[\leadsto \color{blue}{x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)} \]
                      11. *-commutativeN/A

                        \[\leadsto \color{blue}{\left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right) \cdot x} \]
                      12. lower-*.f64N/A

                        \[\leadsto \color{blue}{\left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right) \cdot x} \]
                    7. Applied rewrites99.2%

                      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0.5, a \cdot x, 1\right) \cdot a\right) \cdot x} \]
                  13. Recombined 2 regimes into one program.
                  14. Final simplification74.7%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot x \leq -50000000:\\ \;\;\;\;{-0.5}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(0.5, a \cdot x, 1\right) \cdot a\right) \cdot x\\ \end{array} \]
                  15. Add Preprocessing

                  Alternative 6: 71.0% accurate, 1.0× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot x \leq -50000000:\\ \;\;\;\;{-0.5}^{-1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot a\\ \end{array} \end{array} \]
                  (FPCore (a x)
                   :precision binary64
                   (if (<= (* a x) -50000000.0) (pow -0.5 -1.0) (* x a)))
                  double code(double a, double x) {
                  	double tmp;
                  	if ((a * x) <= -50000000.0) {
                  		tmp = pow(-0.5, -1.0);
                  	} else {
                  		tmp = x * a;
                  	}
                  	return tmp;
                  }
                  
                  real(8) function code(a, x)
                      real(8), intent (in) :: a
                      real(8), intent (in) :: x
                      real(8) :: tmp
                      if ((a * x) <= (-50000000.0d0)) then
                          tmp = (-0.5d0) ** (-1.0d0)
                      else
                          tmp = x * a
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double a, double x) {
                  	double tmp;
                  	if ((a * x) <= -50000000.0) {
                  		tmp = Math.pow(-0.5, -1.0);
                  	} else {
                  		tmp = x * a;
                  	}
                  	return tmp;
                  }
                  
                  def code(a, x):
                  	tmp = 0
                  	if (a * x) <= -50000000.0:
                  		tmp = math.pow(-0.5, -1.0)
                  	else:
                  		tmp = x * a
                  	return tmp
                  
                  function code(a, x)
                  	tmp = 0.0
                  	if (Float64(a * x) <= -50000000.0)
                  		tmp = -0.5 ^ -1.0;
                  	else
                  		tmp = Float64(x * a);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(a, x)
                  	tmp = 0.0;
                  	if ((a * x) <= -50000000.0)
                  		tmp = -0.5 ^ -1.0;
                  	else
                  		tmp = x * a;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -50000000.0], N[Power[-0.5, -1.0], $MachinePrecision], N[(x * a), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;a \cdot x \leq -50000000:\\
                  \;\;\;\;{-0.5}^{-1}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;x \cdot a\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f64 a x) < -5e7

                    1. Initial program 100.0%

                      \[e^{a \cdot x} - 1 \]
                    2. Add Preprocessing
                    3. Taylor expanded in a around 0

                      \[\leadsto \color{blue}{\left(1 + a \cdot \left(x + \frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)} - 1 \]
                    4. Step-by-step derivation
                      1. distribute-lft-inN/A

                        \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)\right)}\right) - 1 \]
                      2. associate-*r*N/A

                        \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot {x}^{2}\right)}\right)\right) - 1 \]
                      3. unpow2N/A

                        \[\leadsto \left(1 + \left(a \cdot x + a \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) - 1 \]
                      4. associate-*r*N/A

                        \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot x\right)}\right)\right) - 1 \]
                      5. *-commutativeN/A

                        \[\leadsto \left(1 + \left(a \cdot x + a \cdot \color{blue}{\left(x \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)\right)}\right)\right) - 1 \]
                      6. associate-*r*N/A

                        \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(a \cdot x\right) \cdot \left(\left(\frac{1}{2} \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
                      7. *-commutativeN/A

                        \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x\right) \cdot \left(a \cdot x\right)}\right)\right) - 1 \]
                      8. distribute-rgt1-inN/A

                        \[\leadsto \left(1 + \color{blue}{\left(\left(\frac{1}{2} \cdot a\right) \cdot x + 1\right) \cdot \left(a \cdot x\right)}\right) - 1 \]
                      9. *-commutativeN/A

                        \[\leadsto \left(1 + \left(\color{blue}{x \cdot \left(\frac{1}{2} \cdot a\right)} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
                      10. associate-*r*N/A

                        \[\leadsto \left(1 + \left(\color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot a} + 1\right) \cdot \left(a \cdot x\right)\right) - 1 \]
                      11. distribute-rgt1-inN/A

                        \[\leadsto \left(1 + \color{blue}{\left(a \cdot x + \left(\left(x \cdot \frac{1}{2}\right) \cdot a\right) \cdot \left(a \cdot x\right)\right)}\right) - 1 \]
                      12. associate-*r*N/A

                        \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{\left(x \cdot \frac{1}{2}\right) \cdot \left(a \cdot \left(a \cdot x\right)\right)}\right)\right) - 1 \]
                      13. associate-*l*N/A

                        \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot x\right)}\right)\right) - 1 \]
                      14. unpow2N/A

                        \[\leadsto \left(1 + \left(a \cdot x + \left(x \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{{a}^{2}} \cdot x\right)\right)\right) - 1 \]
                      15. associate-*r*N/A

                        \[\leadsto \left(1 + \left(a \cdot x + \color{blue}{x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right)\right) - 1 \]
                      16. *-commutativeN/A

                        \[\leadsto \left(1 + \left(\color{blue}{x \cdot a} + x \cdot \left(\frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right)\right) - 1 \]
                      17. distribute-lft-inN/A

                        \[\leadsto \left(1 + \color{blue}{x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)}\right) - 1 \]
                      18. *-rgt-identityN/A

                        \[\leadsto \left(1 + \color{blue}{\left(x \cdot \left(a + \frac{1}{2} \cdot \left({a}^{2} \cdot x\right)\right)\right) \cdot 1}\right) - 1 \]
                    5. Applied rewrites1.2%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, 0.5, a\right), x, 1\right)} - 1 \]
                    6. Step-by-step derivation
                      1. lift--.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) - 1} \]
                      2. flip3--N/A

                        \[\leadsto \color{blue}{\frac{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}} \]
                      3. clear-numN/A

                        \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}}} \]
                      4. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) + \left(1 \cdot 1 + \mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right) \cdot 1\right)}{{\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(a \cdot a\right) \cdot x, \frac{1}{2}, a\right), x, 1\right)\right)}^{3} - {1}^{3}}}} \]
                    7. Applied rewrites1.2%

                      \[\leadsto \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, \left(a \cdot a\right) \cdot x, a\right), x, 1\right) - 1}}} \]
                    8. Taylor expanded in x around 0

                      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{-1}{2} \cdot x + \frac{1}{a}}{x}}} \]
                    9. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{-1}{2} \cdot x + \frac{1}{a}}{x}}} \]
                      2. lower-fma.f64N/A

                        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{a}\right)}}{x}} \]
                      3. lower-/.f6418.8

                        \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-0.5, x, \color{blue}{\frac{1}{a}}\right)}{x}} \]
                    10. Applied rewrites18.8%

                      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(-0.5, x, \frac{1}{a}\right)}{x}}} \]
                    11. Taylor expanded in a around inf

                      \[\leadsto \frac{1}{\frac{-1}{2}} \]
                    12. Step-by-step derivation
                      1. Applied rewrites18.8%

                        \[\leadsto \frac{1}{-0.5} \]

                      if -5e7 < (*.f64 a x)

                      1. Initial program 34.1%

                        \[e^{a \cdot x} - 1 \]
                      2. Add Preprocessing
                      3. Taylor expanded in a around 0

                        \[\leadsto \color{blue}{a \cdot x} \]
                      4. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \color{blue}{x \cdot a} \]
                        2. lower-*.f6498.4

                          \[\leadsto \color{blue}{x \cdot a} \]
                      5. Applied rewrites98.4%

                        \[\leadsto \color{blue}{x \cdot a} \]
                    13. Recombined 2 regimes into one program.
                    14. Final simplification74.1%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot x \leq -50000000:\\ \;\;\;\;{-0.5}^{-1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot a\\ \end{array} \]
                    15. Add Preprocessing

                    Alternative 7: 66.5% accurate, 18.2× speedup?

                    \[\begin{array}{l} \\ x \cdot a \end{array} \]
                    (FPCore (a x) :precision binary64 (* x a))
                    double code(double a, double x) {
                    	return x * a;
                    }
                    
                    real(8) function code(a, x)
                        real(8), intent (in) :: a
                        real(8), intent (in) :: x
                        code = x * a
                    end function
                    
                    public static double code(double a, double x) {
                    	return x * a;
                    }
                    
                    def code(a, x):
                    	return x * a
                    
                    function code(a, x)
                    	return Float64(x * a)
                    end
                    
                    function tmp = code(a, x)
                    	tmp = x * a;
                    end
                    
                    code[a_, x_] := N[(x * a), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    x \cdot a
                    \end{array}
                    
                    Derivation
                    1. Initial program 54.2%

                      \[e^{a \cdot x} - 1 \]
                    2. Add Preprocessing
                    3. Taylor expanded in a around 0

                      \[\leadsto \color{blue}{a \cdot x} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \color{blue}{x \cdot a} \]
                      2. lower-*.f6470.0

                        \[\leadsto \color{blue}{x \cdot a} \]
                    5. Applied rewrites70.0%

                      \[\leadsto \color{blue}{x \cdot a} \]
                    6. Final simplification70.0%

                      \[\leadsto x \cdot a \]
                    7. Add Preprocessing

                    Alternative 8: 19.3% accurate, 27.3× speedup?

                    \[\begin{array}{l} \\ 1 - 1 \end{array} \]
                    (FPCore (a x) :precision binary64 (- 1.0 1.0))
                    double code(double a, double x) {
                    	return 1.0 - 1.0;
                    }
                    
                    real(8) function code(a, x)
                        real(8), intent (in) :: a
                        real(8), intent (in) :: x
                        code = 1.0d0 - 1.0d0
                    end function
                    
                    public static double code(double a, double x) {
                    	return 1.0 - 1.0;
                    }
                    
                    def code(a, x):
                    	return 1.0 - 1.0
                    
                    function code(a, x)
                    	return Float64(1.0 - 1.0)
                    end
                    
                    function tmp = code(a, x)
                    	tmp = 1.0 - 1.0;
                    end
                    
                    code[a_, x_] := N[(1.0 - 1.0), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    1 - 1
                    \end{array}
                    
                    Derivation
                    1. Initial program 54.2%

                      \[e^{a \cdot x} - 1 \]
                    2. Add Preprocessing
                    3. Taylor expanded in a around 0

                      \[\leadsto \color{blue}{1} - 1 \]
                    4. Step-by-step derivation
                      1. Applied rewrites22.9%

                        \[\leadsto \color{blue}{1} - 1 \]
                      2. Add Preprocessing

                      Developer Target 1: 100.0% accurate, 1.0× speedup?

                      \[\begin{array}{l} \\ \mathsf{expm1}\left(a \cdot x\right) \end{array} \]
                      (FPCore (a x) :precision binary64 (expm1 (* a x)))
                      double code(double a, double x) {
                      	return expm1((a * x));
                      }
                      
                      public static double code(double a, double x) {
                      	return Math.expm1((a * x));
                      }
                      
                      def code(a, x):
                      	return math.expm1((a * x))
                      
                      function code(a, x)
                      	return expm1(Float64(a * x))
                      end
                      
                      code[a_, x_] := N[(Exp[N[(a * x), $MachinePrecision]] - 1), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      \mathsf{expm1}\left(a \cdot x\right)
                      \end{array}
                      

                      Reproduce

                      ?
                      herbie shell --seed 2024318 
                      (FPCore (a x)
                        :name "expax (section 3.5)"
                        :precision binary64
                        :pre (> 710.0 (* a x))
                      
                        :alt
                        (! :herbie-platform default (expm1 (* a x)))
                      
                        (- (exp (* a x)) 1.0))