expax (section 3.5)

Percentage Accurate: 53.9% → 100.0%
Time: 8.0s
Alternatives: 7
Speedup: 10.5×

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 7 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: 53.9% 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 51.4%

    \[e^{a \cdot x} - 1 \]
  2. Step-by-step derivation
    1. expm1-defineN/A

      \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
    2. expm1-lowering-expm1.f64N/A

      \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
    3. *-lowering-*.f64100.0%

      \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
  3. Simplified100.0%

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

Alternative 2: 72.4% accurate, 4.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot x \leq -40000:\\ \;\;\;\;-2 + \frac{-4}{a \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(a \cdot x\right) \cdot \left(0.5 + a \cdot \left(x \cdot 0.16666666666666666\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (a x)
 :precision binary64
 (if (<= (* a x) -40000.0)
   (+ -2.0 (/ -4.0 (* a x)))
   (* (* a x) (+ 1.0 (* (* a x) (+ 0.5 (* a (* x 0.16666666666666666))))))))
double code(double a, double x) {
	double tmp;
	if ((a * x) <= -40000.0) {
		tmp = -2.0 + (-4.0 / (a * x));
	} else {
		tmp = (a * x) * (1.0 + ((a * x) * (0.5 + (a * (x * 0.16666666666666666)))));
	}
	return tmp;
}
real(8) function code(a, x)
    real(8), intent (in) :: a
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((a * x) <= (-40000.0d0)) then
        tmp = (-2.0d0) + ((-4.0d0) / (a * x))
    else
        tmp = (a * x) * (1.0d0 + ((a * x) * (0.5d0 + (a * (x * 0.16666666666666666d0)))))
    end if
    code = tmp
end function
public static double code(double a, double x) {
	double tmp;
	if ((a * x) <= -40000.0) {
		tmp = -2.0 + (-4.0 / (a * x));
	} else {
		tmp = (a * x) * (1.0 + ((a * x) * (0.5 + (a * (x * 0.16666666666666666)))));
	}
	return tmp;
}
def code(a, x):
	tmp = 0
	if (a * x) <= -40000.0:
		tmp = -2.0 + (-4.0 / (a * x))
	else:
		tmp = (a * x) * (1.0 + ((a * x) * (0.5 + (a * (x * 0.16666666666666666)))))
	return tmp
function code(a, x)
	tmp = 0.0
	if (Float64(a * x) <= -40000.0)
		tmp = Float64(-2.0 + Float64(-4.0 / Float64(a * x)));
	else
		tmp = Float64(Float64(a * x) * Float64(1.0 + Float64(Float64(a * x) * Float64(0.5 + Float64(a * Float64(x * 0.16666666666666666))))));
	end
	return tmp
end
function tmp_2 = code(a, x)
	tmp = 0.0;
	if ((a * x) <= -40000.0)
		tmp = -2.0 + (-4.0 / (a * x));
	else
		tmp = (a * x) * (1.0 + ((a * x) * (0.5 + (a * (x * 0.16666666666666666)))));
	end
	tmp_2 = tmp;
end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -40000.0], N[(-2.0 + N[(-4.0 / N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * x), $MachinePrecision] * N[(1.0 + N[(N[(a * x), $MachinePrecision] * N[(0.5 + N[(a * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -40000:\\
\;\;\;\;-2 + \frac{-4}{a \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(a \cdot x\right) \cdot \left(0.5 + a \cdot \left(x \cdot 0.16666666666666666\right)\right)\right)\\


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

    1. Initial program 100.0%

      \[e^{a \cdot x} - 1 \]
    2. Step-by-step derivation
      1. expm1-defineN/A

        \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
      2. expm1-lowering-expm1.f64N/A

        \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
      3. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    4. Add Preprocessing
    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 a \cdot x + \color{blue}{a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)} \]
      2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \left(\left(a \cdot \frac{1}{2}\right) \cdot x\right)\right)\right) \]
      15. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
      18. *-lowering-*.f640.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
    7. Simplified0.8%

      \[\leadsto \color{blue}{\left(a \cdot x\right) \cdot \left(1 + a \cdot \left(x \cdot 0.5\right)\right)} \]
    8. Step-by-step derivation
      1. flip3-+N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{{1}^{3} + {\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) - 1 \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)}}}\right)\right)\right) \]
      5. flip3-+N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f640.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right)\right)\right) \]
    9. Applied egg-rr0.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + \frac{-1}{2} \cdot \left(a \cdot x\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6412.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
    12. Simplified12.8%

      \[\leadsto \left(a \cdot x\right) \cdot \frac{1}{\color{blue}{1 + a \cdot \left(x \cdot -0.5\right)}} \]
    13. Taylor expanded in a around inf

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

        \[\leadsto \mathsf{neg}\left(\left(2 + 4 \cdot \frac{1}{a \cdot x}\right)\right) \]
      2. distribute-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(2\right)\right) + \color{blue}{\left(\mathsf{neg}\left(4 \cdot \frac{1}{a \cdot x}\right)\right)} \]
      3. metadata-evalN/A

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

        \[\leadsto \mathsf{+.f64}\left(-2, \color{blue}{\left(\mathsf{neg}\left(4 \cdot \frac{1}{a \cdot x}\right)\right)}\right) \]
      5. mul-1-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(-2, \left(-1 \cdot \frac{4 \cdot 1}{\color{blue}{a \cdot x}}\right)\right) \]
      7. metadata-evalN/A

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

        \[\leadsto \mathsf{+.f64}\left(-2, \left(\frac{-1 \cdot 4}{\color{blue}{a \cdot x}}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(-2, \left(\frac{-4}{\color{blue}{a} \cdot x}\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(-2, \left(\frac{\mathsf{neg}\left(4\right)}{\color{blue}{a} \cdot x}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(-2, \mathsf{/.f64}\left(\left(\mathsf{neg}\left(4\right)\right), \color{blue}{\left(a \cdot x\right)}\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(-2, \mathsf{/.f64}\left(-4, \left(\color{blue}{a} \cdot x\right)\right)\right) \]
      13. *-lowering-*.f6418.8%

        \[\leadsto \mathsf{+.f64}\left(-2, \mathsf{/.f64}\left(-4, \mathsf{*.f64}\left(a, \color{blue}{x}\right)\right)\right) \]
    15. Simplified18.8%

      \[\leadsto \color{blue}{-2 + \frac{-4}{a \cdot x}} \]

    if -4e4 < (*.f64 a x)

    1. Initial program 30.8%

      \[e^{a \cdot x} - 1 \]
    2. Step-by-step derivation
      1. expm1-defineN/A

        \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
      2. expm1-lowering-expm1.f64N/A

        \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
      3. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    4. Add Preprocessing
    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. Simplified99.0%

      \[\leadsto \color{blue}{\left(a \cdot x\right) \cdot \left(1 + \left(a \cdot x\right) \cdot \left(0.5 + a \cdot \left(x \cdot 0.16666666666666666\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 71.5% accurate, 7.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot x \leq -2.45:\\ \;\;\;\;-2 + \frac{-4}{a \cdot x}\\ \mathbf{else}:\\ \;\;\;\;a \cdot x\\ \end{array} \end{array} \]
(FPCore (a x)
 :precision binary64
 (if (<= (* a x) -2.45) (+ -2.0 (/ -4.0 (* a x))) (* a x)))
double code(double a, double x) {
	double tmp;
	if ((a * x) <= -2.45) {
		tmp = -2.0 + (-4.0 / (a * x));
	} 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 * x) <= (-2.45d0)) then
        tmp = (-2.0d0) + ((-4.0d0) / (a * x))
    else
        tmp = a * x
    end if
    code = tmp
end function
public static double code(double a, double x) {
	double tmp;
	if ((a * x) <= -2.45) {
		tmp = -2.0 + (-4.0 / (a * x));
	} else {
		tmp = a * x;
	}
	return tmp;
}
def code(a, x):
	tmp = 0
	if (a * x) <= -2.45:
		tmp = -2.0 + (-4.0 / (a * x))
	else:
		tmp = a * x
	return tmp
function code(a, x)
	tmp = 0.0
	if (Float64(a * x) <= -2.45)
		tmp = Float64(-2.0 + Float64(-4.0 / Float64(a * x)));
	else
		tmp = Float64(a * x);
	end
	return tmp
end
function tmp_2 = code(a, x)
	tmp = 0.0;
	if ((a * x) <= -2.45)
		tmp = -2.0 + (-4.0 / (a * x));
	else
		tmp = a * x;
	end
	tmp_2 = tmp;
end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -2.45], N[(-2.0 + N[(-4.0 / N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -2.45:\\
\;\;\;\;-2 + \frac{-4}{a \cdot x}\\

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


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

    1. Initial program 100.0%

      \[e^{a \cdot x} - 1 \]
    2. Step-by-step derivation
      1. expm1-defineN/A

        \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
      2. expm1-lowering-expm1.f64N/A

        \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
      3. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    4. Add Preprocessing
    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 a \cdot x + \color{blue}{a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)} \]
      2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \left(\left(a \cdot \frac{1}{2}\right) \cdot x\right)\right)\right) \]
      15. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
      18. *-lowering-*.f640.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
    7. Simplified0.8%

      \[\leadsto \color{blue}{\left(a \cdot x\right) \cdot \left(1 + a \cdot \left(x \cdot 0.5\right)\right)} \]
    8. Step-by-step derivation
      1. flip3-+N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{{1}^{3} + {\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) - 1 \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)}}}\right)\right)\right) \]
      5. flip3-+N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f640.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right)\right)\right) \]
    9. Applied egg-rr0.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + \frac{-1}{2} \cdot \left(a \cdot x\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6412.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
    12. Simplified12.8%

      \[\leadsto \left(a \cdot x\right) \cdot \frac{1}{\color{blue}{1 + a \cdot \left(x \cdot -0.5\right)}} \]
    13. Taylor expanded in a around inf

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

        \[\leadsto \mathsf{neg}\left(\left(2 + 4 \cdot \frac{1}{a \cdot x}\right)\right) \]
      2. distribute-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(2\right)\right) + \color{blue}{\left(\mathsf{neg}\left(4 \cdot \frac{1}{a \cdot x}\right)\right)} \]
      3. metadata-evalN/A

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

        \[\leadsto \mathsf{+.f64}\left(-2, \color{blue}{\left(\mathsf{neg}\left(4 \cdot \frac{1}{a \cdot x}\right)\right)}\right) \]
      5. mul-1-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(-2, \left(-1 \cdot \frac{4 \cdot 1}{\color{blue}{a \cdot x}}\right)\right) \]
      7. metadata-evalN/A

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

        \[\leadsto \mathsf{+.f64}\left(-2, \left(\frac{-1 \cdot 4}{\color{blue}{a \cdot x}}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(-2, \left(\frac{-4}{\color{blue}{a} \cdot x}\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(-2, \left(\frac{\mathsf{neg}\left(4\right)}{\color{blue}{a} \cdot x}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(-2, \mathsf{/.f64}\left(\left(\mathsf{neg}\left(4\right)\right), \color{blue}{\left(a \cdot x\right)}\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(-2, \mathsf{/.f64}\left(-4, \left(\color{blue}{a} \cdot x\right)\right)\right) \]
      13. *-lowering-*.f6418.8%

        \[\leadsto \mathsf{+.f64}\left(-2, \mathsf{/.f64}\left(-4, \mathsf{*.f64}\left(a, \color{blue}{x}\right)\right)\right) \]
    15. Simplified18.8%

      \[\leadsto \color{blue}{-2 + \frac{-4}{a \cdot x}} \]

    if -2.4500000000000002 < (*.f64 a x)

    1. Initial program 30.8%

      \[e^{a \cdot x} - 1 \]
    2. Step-by-step derivation
      1. expm1-defineN/A

        \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
      2. expm1-lowering-expm1.f64N/A

        \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
      3. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a \cdot x} \]
    6. Step-by-step derivation
      1. *-lowering-*.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{x}\right) \]
    7. Simplified98.0%

      \[\leadsto \color{blue}{a \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 70.9% accurate, 8.1× speedup?

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

\\
x \cdot \left(a \cdot \frac{1}{1 + \left(a \cdot x\right) \cdot -0.5}\right)
\end{array}
Derivation
  1. Initial program 51.4%

    \[e^{a \cdot x} - 1 \]
  2. Step-by-step derivation
    1. expm1-defineN/A

      \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
    2. expm1-lowering-expm1.f64N/A

      \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
    3. *-lowering-*.f64100.0%

      \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
  4. Add Preprocessing
  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 a \cdot x + \color{blue}{a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)} \]
    2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \left(\left(a \cdot \frac{1}{2}\right) \cdot x\right)\right)\right) \]
    15. associate-*l*N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
    18. *-lowering-*.f6469.7%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
  7. Simplified69.7%

    \[\leadsto \color{blue}{\left(a \cdot x\right) \cdot \left(1 + a \cdot \left(x \cdot 0.5\right)\right)} \]
  8. Step-by-step derivation
    1. flip3-+N/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{{1}^{3} + {\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) - 1 \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)}}}\right)\right)\right) \]
    5. flip3-+N/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
    9. *-lowering-*.f6469.7%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right)\right)\right) \]
  9. Applied egg-rr69.7%

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

    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + \frac{-1}{2} \cdot \left(a \cdot x\right)\right)}\right)\right) \]
  11. Step-by-step derivation
    1. +-lowering-+.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
    7. *-lowering-*.f6473.3%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
  12. Simplified73.3%

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(1 + a \cdot \left(x \cdot \frac{-1}{2}\right)\right)\right), a\right), x\right) \]
    6. +-lowering-+.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(\left(a \cdot x\right) \cdot \frac{-1}{2}\right)\right)\right), a\right), x\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(a \cdot x\right), \frac{-1}{2}\right)\right)\right), a\right), x\right) \]
    9. *-lowering-*.f6473.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \frac{-1}{2}\right)\right)\right), a\right), x\right) \]
  14. Applied egg-rr73.6%

    \[\leadsto \color{blue}{\left(\frac{1}{1 + \left(a \cdot x\right) \cdot -0.5} \cdot a\right) \cdot x} \]
  15. Final simplification73.6%

    \[\leadsto x \cdot \left(a \cdot \frac{1}{1 + \left(a \cdot x\right) \cdot -0.5}\right) \]
  16. Add Preprocessing

Alternative 5: 70.9% accurate, 9.5× speedup?

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

\\
x \cdot \frac{a}{1 + \left(a \cdot x\right) \cdot -0.5}
\end{array}
Derivation
  1. Initial program 51.4%

    \[e^{a \cdot x} - 1 \]
  2. Step-by-step derivation
    1. expm1-defineN/A

      \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
    2. expm1-lowering-expm1.f64N/A

      \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
    3. *-lowering-*.f64100.0%

      \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
  4. Add Preprocessing
  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 a \cdot x + \color{blue}{a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)} \]
    2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \left(\left(a \cdot \frac{1}{2}\right) \cdot x\right)\right)\right) \]
    15. associate-*l*N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
    18. *-lowering-*.f6469.7%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
  7. Simplified69.7%

    \[\leadsto \color{blue}{\left(a \cdot x\right) \cdot \left(1 + a \cdot \left(x \cdot 0.5\right)\right)} \]
  8. Step-by-step derivation
    1. flip3-+N/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{{1}^{3} + {\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) - 1 \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)}}}\right)\right)\right) \]
    5. flip3-+N/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
    9. *-lowering-*.f6469.7%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right)\right)\right) \]
  9. Applied egg-rr69.7%

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

    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + \frac{-1}{2} \cdot \left(a \cdot x\right)\right)}\right)\right) \]
  11. Step-by-step derivation
    1. +-lowering-+.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
    7. *-lowering-*.f6473.3%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
  12. Simplified73.3%

    \[\leadsto \left(a \cdot x\right) \cdot \frac{1}{\color{blue}{1 + a \cdot \left(x \cdot -0.5\right)}} \]
  13. Step-by-step derivation
    1. div-invN/A

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(a \cdot x\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right) \]
    9. *-lowering-*.f6473.6%

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \frac{-1}{2}\right)\right)\right)\right) \]
  14. Applied egg-rr73.6%

    \[\leadsto \color{blue}{x \cdot \frac{a}{1 + \left(a \cdot x\right) \cdot -0.5}} \]
  15. Add Preprocessing

Alternative 6: 71.5% accurate, 10.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot x \leq -2:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;a \cdot x\\ \end{array} \end{array} \]
(FPCore (a x) :precision binary64 (if (<= (* a x) -2.0) -2.0 (* a x)))
double code(double a, double x) {
	double tmp;
	if ((a * x) <= -2.0) {
		tmp = -2.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 * x) <= (-2.0d0)) then
        tmp = -2.0d0
    else
        tmp = a * x
    end if
    code = tmp
end function
public static double code(double a, double x) {
	double tmp;
	if ((a * x) <= -2.0) {
		tmp = -2.0;
	} else {
		tmp = a * x;
	}
	return tmp;
}
def code(a, x):
	tmp = 0
	if (a * x) <= -2.0:
		tmp = -2.0
	else:
		tmp = a * x
	return tmp
function code(a, x)
	tmp = 0.0
	if (Float64(a * x) <= -2.0)
		tmp = -2.0;
	else
		tmp = Float64(a * x);
	end
	return tmp
end
function tmp_2 = code(a, x)
	tmp = 0.0;
	if ((a * x) <= -2.0)
		tmp = -2.0;
	else
		tmp = a * x;
	end
	tmp_2 = tmp;
end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -2.0], -2.0, N[(a * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -2:\\
\;\;\;\;-2\\

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


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

    1. Initial program 100.0%

      \[e^{a \cdot x} - 1 \]
    2. Step-by-step derivation
      1. expm1-defineN/A

        \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
      2. expm1-lowering-expm1.f64N/A

        \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
      3. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    4. Add Preprocessing
    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 a \cdot x + \color{blue}{a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)} \]
      2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \left(\left(a \cdot \frac{1}{2}\right) \cdot x\right)\right)\right) \]
      15. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
      18. *-lowering-*.f640.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
    7. Simplified0.8%

      \[\leadsto \color{blue}{\left(a \cdot x\right) \cdot \left(1 + a \cdot \left(x \cdot 0.5\right)\right)} \]
    8. Step-by-step derivation
      1. flip3-+N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{{1}^{3} + {\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) - 1 \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)}}}\right)\right)\right) \]
      5. flip3-+N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f640.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right)\right)\right) \]
    9. Applied egg-rr0.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + \frac{-1}{2} \cdot \left(a \cdot x\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6412.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
    12. Simplified12.8%

      \[\leadsto \left(a \cdot x\right) \cdot \frac{1}{\color{blue}{1 + a \cdot \left(x \cdot -0.5\right)}} \]
    13. Taylor expanded in a around inf

      \[\leadsto \color{blue}{-2} \]
    14. Step-by-step derivation
      1. Simplified18.8%

        \[\leadsto \color{blue}{-2} \]

      if -2 < (*.f64 a x)

      1. Initial program 30.8%

        \[e^{a \cdot x} - 1 \]
      2. Step-by-step derivation
        1. expm1-defineN/A

          \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
        2. expm1-lowering-expm1.f64N/A

          \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
        3. *-lowering-*.f64100.0%

          \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
      3. Simplified100.0%

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

        \[\leadsto \color{blue}{a \cdot x} \]
      6. Step-by-step derivation
        1. *-lowering-*.f6498.0%

          \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{x}\right) \]
      7. Simplified98.0%

        \[\leadsto \color{blue}{a \cdot x} \]
    15. Recombined 2 regimes into one program.
    16. Add Preprocessing

    Alternative 7: 8.8% accurate, 105.0× speedup?

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

      \[e^{a \cdot x} - 1 \]
    2. Step-by-step derivation
      1. expm1-defineN/A

        \[\leadsto \mathsf{expm1}\left(a \cdot x\right) \]
      2. expm1-lowering-expm1.f64N/A

        \[\leadsto \mathsf{expm1.f64}\left(\left(a \cdot x\right)\right) \]
      3. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{expm1.f64}\left(\mathsf{*.f64}\left(a, x\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)} \]
    4. Add Preprocessing
    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 a \cdot x + \color{blue}{a \cdot \left(\frac{1}{2} \cdot \left(a \cdot {x}^{2}\right)\right)} \]
      2. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \left(\left(a \cdot \frac{1}{2}\right) \cdot x\right)\right)\right) \]
      15. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
      18. *-lowering-*.f6469.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
    7. Simplified69.7%

      \[\leadsto \color{blue}{\left(a \cdot x\right) \cdot \left(1 + a \cdot \left(x \cdot 0.5\right)\right)} \]
    8. Step-by-step derivation
      1. flip3-+N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{{1}^{3} + {\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right) - 1 \cdot \left(a \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)}}}\right)\right)\right) \]
      5. flip3-+N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f6469.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right)\right)\right)\right)\right) \]
    9. Applied egg-rr69.7%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + \frac{-1}{2} \cdot \left(a \cdot x\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \left(x \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6473.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, x\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right) \]
    12. Simplified73.3%

      \[\leadsto \left(a \cdot x\right) \cdot \frac{1}{\color{blue}{1 + a \cdot \left(x \cdot -0.5\right)}} \]
    13. Taylor expanded in a around inf

      \[\leadsto \color{blue}{-2} \]
    14. Step-by-step derivation
      1. Simplified8.2%

        \[\leadsto \color{blue}{-2} \]
      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 2024150 
      (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))