expax (section 3.5)

Percentage Accurate: 54.3% → 100.0%
Time: 8.3s
Alternatives: 6
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 6 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.3% 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(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}
Derivation
  1. Initial program 55.4%

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

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

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

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

Alternative 2: 67.5% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{+251}:\\
\;\;\;\;a \cdot \left(0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right) + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.1e251

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(a, \frac{1}{2} \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) - 1 \]
      10. lower-*.f642.9

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5 \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) - 1 \]
    5. Simplified2.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(\color{blue}{\left(a \cdot \frac{1}{2}\right) \cdot x}, x, x\right), 1\right) - 1 \]
      9. lower-*.f640.8

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(\color{blue}{\left(a \cdot 0.5\right)} \cdot x, x, x\right), 1\right) - 1 \]
    7. Applied egg-rr0.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \left(\frac{1}{2} \cdot \left(a \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - 1 \]
      10. lower-*.f6435.7

        \[\leadsto a \cdot \left(0.5 \cdot \left(a \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - 1 \]
    10. Simplified35.7%

      \[\leadsto \color{blue}{a \cdot \left(0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right)} - 1 \]

    if -1.1e251 < a

    1. Initial program 52.2%

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

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

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    5. 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)} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\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)} \]
      2. +-commutativeN/A

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

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

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

        \[\leadsto a \cdot \left(a \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(a \cdot \frac{1}{6}\right)} + \frac{1}{2}\right)\right)\right) + x\right) \]
      2. lift-fma.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, a, \color{blue}{\left(a \cdot \left(x \cdot \left(x \cdot \mathsf{fma}\left(x, a \cdot \frac{1}{6}, \frac{1}{2}\right)\right)\right)\right) \cdot a}\right) \]
      10. lift-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(x, a, \color{blue}{\left(\left(a \cdot x\right) \cdot \left(x \cdot \mathsf{fma}\left(x, a \cdot \frac{1}{6}, \frac{1}{2}\right)\right)\right)} \cdot a\right) \]
      12. lift-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(x, a, \color{blue}{\left(a \cdot x\right) \cdot \left(\left(x \cdot \mathsf{fma}\left(x, a \cdot \frac{1}{6}, \frac{1}{2}\right)\right) \cdot a\right)}\right) \]
    9. Applied egg-rr69.2%

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

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

Alternative 3: 67.5% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{+251}:\\
\;\;\;\;a \cdot \left(0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right) + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.1e251

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(a, \frac{1}{2} \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) - 1 \]
      10. lower-*.f642.9

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5 \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) - 1 \]
    5. Simplified2.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(\color{blue}{\left(a \cdot \frac{1}{2}\right) \cdot x}, x, x\right), 1\right) - 1 \]
      9. lower-*.f640.8

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(\color{blue}{\left(a \cdot 0.5\right)} \cdot x, x, x\right), 1\right) - 1 \]
    7. Applied egg-rr0.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \left(\frac{1}{2} \cdot \left(a \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - 1 \]
      10. lower-*.f6435.7

        \[\leadsto a \cdot \left(0.5 \cdot \left(a \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - 1 \]
    10. Simplified35.7%

      \[\leadsto \color{blue}{a \cdot \left(0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right)} - 1 \]

    if -1.1e251 < a

    1. Initial program 52.2%

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

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

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    5. 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)} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\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)} \]
      2. +-commutativeN/A

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

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

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

        \[\leadsto a \cdot \left(a \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(a \cdot \frac{1}{6}\right)} + \frac{1}{2}\right)\right)\right) + x\right) \]
      2. lift-fma.f64N/A

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

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

        \[\leadsto a \cdot \left(a \cdot \color{blue}{\left(x \cdot \left(x \cdot \mathsf{fma}\left(x, a \cdot \frac{1}{6}, \frac{1}{2}\right)\right)\right)} + x\right) \]
      5. lift-*.f64N/A

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

        \[\leadsto a \cdot \left(\color{blue}{\left(a \cdot x\right) \cdot \left(x \cdot \mathsf{fma}\left(x, a \cdot \frac{1}{6}, \frac{1}{2}\right)\right)} + x\right) \]
      7. lift-*.f64N/A

        \[\leadsto a \cdot \left(\color{blue}{\left(a \cdot x\right)} \cdot \left(x \cdot \mathsf{fma}\left(x, a \cdot \frac{1}{6}, \frac{1}{2}\right)\right) + x\right) \]
      8. lift-*.f64N/A

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

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

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

        \[\leadsto a \cdot \color{blue}{\mathsf{fma}\left(\left(a \cdot x\right) \cdot \mathsf{fma}\left(x, a \cdot \frac{1}{6}, \frac{1}{2}\right), x, x\right)} \]
      12. lower-*.f6469.2

        \[\leadsto a \cdot \mathsf{fma}\left(\color{blue}{\left(a \cdot x\right) \cdot \mathsf{fma}\left(x, a \cdot 0.16666666666666666, 0.5\right)}, x, x\right) \]
      13. lift-*.f64N/A

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

        \[\leadsto a \cdot \mathsf{fma}\left(\color{blue}{\left(x \cdot a\right)} \cdot \mathsf{fma}\left(x, a \cdot \frac{1}{6}, \frac{1}{2}\right), x, x\right) \]
      15. lower-*.f6469.2

        \[\leadsto a \cdot \mathsf{fma}\left(\color{blue}{\left(x \cdot a\right)} \cdot \mathsf{fma}\left(x, a \cdot 0.16666666666666666, 0.5\right), x, x\right) \]
    9. Applied egg-rr69.2%

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

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

Alternative 4: 66.9% accurate, 3.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -5.8 \cdot 10^{+250}:\\ \;\;\;\;a \cdot \left(0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;a \cdot x\\ \end{array} \end{array} \]
(FPCore (a x)
 :precision binary64
 (if (<= a -5.8e+250) (+ (* a (* 0.5 (* a (* x x)))) -1.0) (* a x)))
double code(double a, double x) {
	double tmp;
	if (a <= -5.8e+250) {
		tmp = (a * (0.5 * (a * (x * x)))) + -1.0;
	} else {
		tmp = a * x;
	}
	return tmp;
}
real(8) function code(a, x)
    real(8), intent (in) :: a
    real(8), intent (in) :: x
    real(8) :: tmp
    if (a <= (-5.8d+250)) then
        tmp = (a * (0.5d0 * (a * (x * x)))) + (-1.0d0)
    else
        tmp = a * x
    end if
    code = tmp
end function
public static double code(double a, double x) {
	double tmp;
	if (a <= -5.8e+250) {
		tmp = (a * (0.5 * (a * (x * x)))) + -1.0;
	} else {
		tmp = a * x;
	}
	return tmp;
}
def code(a, x):
	tmp = 0
	if a <= -5.8e+250:
		tmp = (a * (0.5 * (a * (x * x)))) + -1.0
	else:
		tmp = a * x
	return tmp
function code(a, x)
	tmp = 0.0
	if (a <= -5.8e+250)
		tmp = Float64(Float64(a * Float64(0.5 * Float64(a * Float64(x * x)))) + -1.0);
	else
		tmp = Float64(a * x);
	end
	return tmp
end
function tmp_2 = code(a, x)
	tmp = 0.0;
	if (a <= -5.8e+250)
		tmp = (a * (0.5 * (a * (x * x)))) + -1.0;
	else
		tmp = a * x;
	end
	tmp_2 = tmp;
end
code[a_, x_] := If[LessEqual[a, -5.8e+250], N[(N[(a * N[(0.5 * N[(a * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(a * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.8 \cdot 10^{+250}:\\
\;\;\;\;a \cdot \left(0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right) + -1\\

\mathbf{else}:\\
\;\;\;\;a \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -5.80000000000000018e250

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(a, \frac{1}{2} \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) - 1 \]
      10. lower-*.f642.9

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5 \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) - 1 \]
    5. Simplified2.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(\color{blue}{\left(a \cdot \frac{1}{2}\right) \cdot x}, x, x\right), 1\right) - 1 \]
      9. lower-*.f640.8

        \[\leadsto \mathsf{fma}\left(a, \mathsf{fma}\left(\color{blue}{\left(a \cdot 0.5\right)} \cdot x, x, x\right), 1\right) - 1 \]
    7. Applied egg-rr0.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \left(\frac{1}{2} \cdot \left(a \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - 1 \]
      10. lower-*.f6435.7

        \[\leadsto a \cdot \left(0.5 \cdot \left(a \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - 1 \]
    10. Simplified35.7%

      \[\leadsto \color{blue}{a \cdot \left(0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right)} - 1 \]

    if -5.80000000000000018e250 < a

    1. Initial program 52.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. lower-*.f6468.7

        \[\leadsto \color{blue}{a \cdot x} \]
    5. Simplified68.7%

      \[\leadsto \color{blue}{a \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -5.8 \cdot 10^{+250}:\\ \;\;\;\;a \cdot \left(0.5 \cdot \left(a \cdot \left(x \cdot x\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;a \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 66.7% accurate, 18.2× speedup?

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

\\
a \cdot x
\end{array}
Derivation
  1. Initial program 55.4%

    \[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. lower-*.f6464.5

      \[\leadsto \color{blue}{a \cdot x} \]
  5. Simplified64.5%

    \[\leadsto \color{blue}{a \cdot x} \]
  6. Add Preprocessing

Alternative 6: 19.6% accurate, 109.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a x) :precision binary64 0.0)
double code(double a, double x) {
	return 0.0;
}
real(8) function code(a, x)
    real(8), intent (in) :: a
    real(8), intent (in) :: x
    code = 0.0d0
end function
public static double code(double a, double x) {
	return 0.0;
}
def code(a, x):
	return 0.0
function code(a, x)
	return 0.0
end
function tmp = code(a, x)
	tmp = 0.0;
end
code[a_, x_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 55.4%

    \[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. Simplified18.8%

      \[\leadsto \color{blue}{1} - 1 \]
    2. Step-by-step derivation
      1. metadata-eval18.8

        \[\leadsto \color{blue}{0} \]
    3. Applied egg-rr18.8%

      \[\leadsto \color{blue}{0} \]
    4. 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 2024215 
    (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))