Logistic function from Lakshay Garg

Percentage Accurate: 54.6% → 99.0%
Time: 11.1s
Alternatives: 17
Speedup: 3.8×

Specification

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

\\
\frac{2}{1 + e^{-2 \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 17 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.6% accurate, 1.0× speedup?

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

\\
\frac{2}{1 + e^{-2 \cdot x}} - 1
\end{array}

Alternative 1: 99.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-2 \cdot x}\\ t_1 := 1 + t\_0\\ \mathbf{if}\;-2 \cdot x \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(4, \frac{{t\_1}^{-2}}{1 + \frac{-2}{-1 - t\_0}}, \frac{1}{\frac{-2}{t\_1} + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (exp (* -2.0 x))) (t_1 (+ 1.0 t_0)))
   (if (<= (* -2.0 x) -0.01)
     (fma
      4.0
      (/ (pow t_1 -2.0) (+ 1.0 (/ -2.0 (- -1.0 t_0))))
      (/ 1.0 (+ (/ -2.0 t_1) -1.0)))
     (expm1 (- (- x))))))
double code(double x, double y) {
	double t_0 = exp((-2.0 * x));
	double t_1 = 1.0 + t_0;
	double tmp;
	if ((-2.0 * x) <= -0.01) {
		tmp = fma(4.0, (pow(t_1, -2.0) / (1.0 + (-2.0 / (-1.0 - t_0)))), (1.0 / ((-2.0 / t_1) + -1.0)));
	} else {
		tmp = expm1(-(-x));
	}
	return tmp;
}
function code(x, y)
	t_0 = exp(Float64(-2.0 * x))
	t_1 = Float64(1.0 + t_0)
	tmp = 0.0
	if (Float64(-2.0 * x) <= -0.01)
		tmp = fma(4.0, Float64((t_1 ^ -2.0) / Float64(1.0 + Float64(-2.0 / Float64(-1.0 - t_0)))), Float64(1.0 / Float64(Float64(-2.0 / t_1) + -1.0)));
	else
		tmp = expm1(Float64(-Float64(-x)));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + t$95$0), $MachinePrecision]}, If[LessEqual[N[(-2.0 * x), $MachinePrecision], -0.01], N[(4.0 * N[(N[Power[t$95$1, -2.0], $MachinePrecision] / N[(1.0 + N[(-2.0 / N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[(-2.0 / t$95$1), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Exp[(-(-x))] - 1), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-2 \cdot x}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;-2 \cdot x \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(4, \frac{{t\_1}^{-2}}{1 + \frac{-2}{-1 - t\_0}}, \frac{1}{\frac{-2}{t\_1} + -1}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal -2 binary64) x) < -0.0100000000000000002

    1. Initial program 99.7%

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}} - 1} \]
      2. flip--N/A

        \[\leadsto \color{blue}{\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - \color{blue}{1}}{\frac{2}{1 + e^{-2 \cdot x}} + 1} \]
      4. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}}}{\frac{2}{1 + e^{-2 \cdot x}} + 1} - \frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}} \]
      5. sub-negN/A

        \[\leadsto \color{blue}{\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}}}{\frac{2}{1 + e^{-2 \cdot x}} + 1} + \left(\mathsf{neg}\left(\frac{1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\right)\right)} \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \frac{{\left(1 + e^{-2 \cdot x}\right)}^{-2}}{1 - \frac{-2}{1 + e^{-2 \cdot x}}}, -\frac{1}{1 - \frac{-2}{1 + e^{-2 \cdot x}}}\right)} \]

    if -0.0100000000000000002 < (*.f64 #s(literal -2 binary64) x)

    1. Initial program 34.3%

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

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}}} - 1 \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}} - 1 \]
      4. inv-powN/A

        \[\leadsto \color{blue}{{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{-1}} - 1 \]
      5. metadata-evalN/A

        \[\leadsto {\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      6. pow-to-expN/A

        \[\leadsto \color{blue}{e^{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      7. lower-expm1.f64N/A

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}\right) \]
      9. lower-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      10. div-invN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      13. metadata-eval34.3

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot \color{blue}{-1}\right) \]
    4. Applied rewrites34.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot -1\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-1 \cdot x\right)} \cdot -1\right) \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot -1\right) \]
      2. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-x\right)} \cdot -1\right) \]
    7. Applied rewrites99.7%

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

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

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-1 \cdot \left(-x\right)}\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{neg}\left(\left(-x\right)\right)}\right) \]
      4. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
    9. Applied rewrites99.7%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(4, \frac{{\left(1 + e^{-2 \cdot x}\right)}^{-2}}{1 + \frac{-2}{-1 - e^{-2 \cdot x}}}, \frac{1}{\frac{-2}{1 + e^{-2 \cdot x}} + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq -0.01:\\ \;\;\;\;\mathsf{expm1}\left(\log 2 - \mathsf{log1p}\left(e^{-2 \cdot x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (* -2.0 x) -0.01)
   (expm1 (- (log 2.0) (log1p (exp (* -2.0 x)))))
   (expm1 (- (- x)))))
double code(double x, double y) {
	double tmp;
	if ((-2.0 * x) <= -0.01) {
		tmp = expm1((log(2.0) - log1p(exp((-2.0 * x)))));
	} else {
		tmp = expm1(-(-x));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if ((-2.0 * x) <= -0.01) {
		tmp = Math.expm1((Math.log(2.0) - Math.log1p(Math.exp((-2.0 * x)))));
	} else {
		tmp = Math.expm1(-(-x));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (-2.0 * x) <= -0.01:
		tmp = math.expm1((math.log(2.0) - math.log1p(math.exp((-2.0 * x)))))
	else:
		tmp = math.expm1(-(-x))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(-2.0 * x) <= -0.01)
		tmp = expm1(Float64(log(2.0) - log1p(exp(Float64(-2.0 * x)))));
	else
		tmp = expm1(Float64(-Float64(-x)));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], -0.01], N[(Exp[N[(N[Log[2.0], $MachinePrecision] - N[Log[1 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision], N[(Exp[(-(-x))] - 1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -0.01:\\
\;\;\;\;\mathsf{expm1}\left(\log 2 - \mathsf{log1p}\left(e^{-2 \cdot x}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal -2 binary64) x) < -0.0100000000000000002

    1. Initial program 99.7%

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

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}}} - 1 \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}} - 1 \]
      4. inv-powN/A

        \[\leadsto \color{blue}{{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{-1}} - 1 \]
      5. metadata-evalN/A

        \[\leadsto {\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      6. pow-to-expN/A

        \[\leadsto \color{blue}{e^{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      7. lower-expm1.f64N/A

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}\right) \]
      9. lower-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      10. div-invN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      13. metadata-eval99.9

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot \color{blue}{-1}\right) \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot -1\right)} \]
    5. Step-by-step derivation
      1. rem-log-expN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right) \cdot -1}\right)}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \left(e^{\color{blue}{\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right) \cdot -1}}\right)\right) \]
      3. lift-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \left(e^{\color{blue}{\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot -1}\right)\right) \]
      4. exp-to-powN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left({\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)}^{-1}\right)}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \left({\color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)}}^{-1}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(\log \left({\left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right)}^{-1}\right)\right) \]
      7. div-invN/A

        \[\leadsto \mathsf{expm1}\left(\log \left({\color{blue}{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}}^{-1}\right)\right) \]
      8. inv-powN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}\right)}\right) \]
      9. clear-numN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}\right) \]
      10. log-divN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log 2 - \log \left(1 + e^{-2 \cdot x}\right)}\right) \]
      11. lower--.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log 2 - \log \left(1 + e^{-2 \cdot x}\right)}\right) \]
      12. lower-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log 2} - \log \left(1 + e^{-2 \cdot x}\right)\right) \]
      13. lift-+.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log 2 - \log \color{blue}{\left(1 + e^{-2 \cdot x}\right)}\right) \]
      14. lower-log1p.f6499.9

        \[\leadsto \mathsf{expm1}\left(\log 2 - \color{blue}{\mathsf{log1p}\left(e^{-2 \cdot x}\right)}\right) \]
    6. Applied rewrites99.9%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log 2 - \mathsf{log1p}\left(e^{-2 \cdot x}\right)}\right) \]

    if -0.0100000000000000002 < (*.f64 #s(literal -2 binary64) x)

    1. Initial program 34.3%

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

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}}} - 1 \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}} - 1 \]
      4. inv-powN/A

        \[\leadsto \color{blue}{{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{-1}} - 1 \]
      5. metadata-evalN/A

        \[\leadsto {\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      6. pow-to-expN/A

        \[\leadsto \color{blue}{e^{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      7. lower-expm1.f64N/A

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}\right) \]
      9. lower-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      10. div-invN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      13. metadata-eval34.3

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot \color{blue}{-1}\right) \]
    4. Applied rewrites34.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot -1\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-1 \cdot x\right)} \cdot -1\right) \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot -1\right) \]
      2. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-x\right)} \cdot -1\right) \]
    7. Applied rewrites99.7%

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

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

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-1 \cdot \left(-x\right)}\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{neg}\left(\left(-x\right)\right)}\right) \]
      4. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
    9. Applied rewrites99.7%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 99.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq -0.01:\\ \;\;\;\;\mathsf{expm1}\left(-\log \left(\mathsf{fma}\left(e^{-2 \cdot x}, 0.5, 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (* -2.0 x) -0.01)
   (expm1 (- (log (fma (exp (* -2.0 x)) 0.5 0.5))))
   (expm1 (- (- x)))))
double code(double x, double y) {
	double tmp;
	if ((-2.0 * x) <= -0.01) {
		tmp = expm1(-log(fma(exp((-2.0 * x)), 0.5, 0.5)));
	} else {
		tmp = expm1(-(-x));
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (Float64(-2.0 * x) <= -0.01)
		tmp = expm1(Float64(-log(fma(exp(Float64(-2.0 * x)), 0.5, 0.5))));
	else
		tmp = expm1(Float64(-Float64(-x)));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], -0.01], N[(Exp[(-N[Log[N[(N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]], $MachinePrecision])] - 1), $MachinePrecision], N[(Exp[(-(-x))] - 1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -0.01:\\
\;\;\;\;\mathsf{expm1}\left(-\log \left(\mathsf{fma}\left(e^{-2 \cdot x}, 0.5, 0.5\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal -2 binary64) x) < -0.0100000000000000002

    1. Initial program 99.7%

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

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}}} - 1 \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}} - 1 \]
      4. inv-powN/A

        \[\leadsto \color{blue}{{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{-1}} - 1 \]
      5. metadata-evalN/A

        \[\leadsto {\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      6. pow-to-expN/A

        \[\leadsto \color{blue}{e^{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      7. lower-expm1.f64N/A

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}\right) \]
      9. lower-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      10. div-invN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      13. metadata-eval99.9

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot \color{blue}{-1}\right) \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot -1\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-1 \cdot \log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)}\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{neg}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)\right)}\right) \]
      4. lower-neg.f6499.9

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right)}\right) \]
      5. lift-*.f64N/A

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

        \[\leadsto \mathsf{expm1}\left(-\log \color{blue}{\left(\frac{1}{2} \cdot \left(1 + e^{-2 \cdot x}\right)\right)}\right) \]
      7. lift-+.f64N/A

        \[\leadsto \mathsf{expm1}\left(-\log \left(\frac{1}{2} \cdot \color{blue}{\left(1 + e^{-2 \cdot x}\right)}\right)\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{expm1}\left(-\log \left(\frac{1}{2} \cdot \color{blue}{\left(e^{-2 \cdot x} + 1\right)}\right)\right) \]
      9. distribute-rgt-inN/A

        \[\leadsto \mathsf{expm1}\left(-\log \color{blue}{\left(e^{-2 \cdot x} \cdot \frac{1}{2} + 1 \cdot \frac{1}{2}\right)}\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(-\log \left(e^{-2 \cdot x} \cdot \frac{1}{2} + \color{blue}{\frac{1}{2}}\right)\right) \]
      11. lower-fma.f6499.9

        \[\leadsto \mathsf{expm1}\left(-\log \color{blue}{\left(\mathsf{fma}\left(e^{-2 \cdot x}, 0.5, 0.5\right)\right)}\right) \]
    6. Applied rewrites99.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(-\log \left(\mathsf{fma}\left(e^{-2 \cdot x}, 0.5, 0.5\right)\right)\right)} \]

    if -0.0100000000000000002 < (*.f64 #s(literal -2 binary64) x)

    1. Initial program 34.3%

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

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}}} - 1 \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}} - 1 \]
      4. inv-powN/A

        \[\leadsto \color{blue}{{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{-1}} - 1 \]
      5. metadata-evalN/A

        \[\leadsto {\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      6. pow-to-expN/A

        \[\leadsto \color{blue}{e^{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      7. lower-expm1.f64N/A

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}\right) \]
      9. lower-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      10. div-invN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      13. metadata-eval34.3

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot \color{blue}{-1}\right) \]
    4. Applied rewrites34.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot -1\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-1 \cdot x\right)} \cdot -1\right) \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot -1\right) \]
      2. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-x\right)} \cdot -1\right) \]
    7. Applied rewrites99.7%

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

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

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-1 \cdot \left(-x\right)}\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{neg}\left(\left(-x\right)\right)}\right) \]
      4. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
    9. Applied rewrites99.7%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 99.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(\frac{2}{\mathsf{expm1}\left(x \cdot -4\right)}, \mathsf{expm1}\left(-2 \cdot x\right), -1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (* -2.0 x) -0.01)
   (fma (/ 2.0 (expm1 (* x -4.0))) (expm1 (* -2.0 x)) -1.0)
   (expm1 (- (- x)))))
double code(double x, double y) {
	double tmp;
	if ((-2.0 * x) <= -0.01) {
		tmp = fma((2.0 / expm1((x * -4.0))), expm1((-2.0 * x)), -1.0);
	} else {
		tmp = expm1(-(-x));
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (Float64(-2.0 * x) <= -0.01)
		tmp = fma(Float64(2.0 / expm1(Float64(x * -4.0))), expm1(Float64(-2.0 * x)), -1.0);
	else
		tmp = expm1(Float64(-Float64(-x)));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], -0.01], N[(N[(2.0 / N[(Exp[N[(x * -4.0), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] * N[(Exp[N[(-2.0 * x), $MachinePrecision]] - 1), $MachinePrecision] + -1.0), $MachinePrecision], N[(Exp[(-(-x))] - 1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\frac{2}{\mathsf{expm1}\left(x \cdot -4\right)}, \mathsf{expm1}\left(-2 \cdot x\right), -1\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal -2 binary64) x) < -0.0100000000000000002

    1. Initial program 99.7%

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}} - 1} \]
      2. sub-negN/A

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}} + \left(\mathsf{neg}\left(1\right)\right)} \]
      3. lift-/.f64N/A

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

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

        \[\leadsto \frac{2}{\color{blue}{e^{-2 \cdot x} + 1}} + \left(\mathsf{neg}\left(1\right)\right) \]
      6. flip-+N/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{e^{-2 \cdot x} \cdot e^{-2 \cdot x} - 1 \cdot 1}, e^{-2 \cdot x} - 1, \mathsf{neg}\left(1\right)\right)} \]
    4. Applied rewrites99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{\mathsf{expm1}\left(x \cdot -4\right)}, \mathsf{expm1}\left(-2 \cdot x\right), -1\right)} \]

    if -0.0100000000000000002 < (*.f64 #s(literal -2 binary64) x)

    1. Initial program 34.3%

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

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}}} - 1 \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}} - 1 \]
      4. inv-powN/A

        \[\leadsto \color{blue}{{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{-1}} - 1 \]
      5. metadata-evalN/A

        \[\leadsto {\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      6. pow-to-expN/A

        \[\leadsto \color{blue}{e^{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      7. lower-expm1.f64N/A

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}\right) \]
      9. lower-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      10. div-invN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      13. metadata-eval34.3

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot \color{blue}{-1}\right) \]
    4. Applied rewrites34.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot -1\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-1 \cdot x\right)} \cdot -1\right) \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot -1\right) \]
      2. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-x\right)} \cdot -1\right) \]
    7. Applied rewrites99.7%

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

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

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-1 \cdot \left(-x\right)}\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{neg}\left(\left(-x\right)\right)}\right) \]
      4. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
    9. Applied rewrites99.7%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 75.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} \leq 2 \cdot 10^{-42}:\\ \;\;\;\;\frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -1.3333333333333333, 2\right), -2\right), 2\right)} + -1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 2e-42)
   (+ (/ 2.0 (fma x (fma x (fma x -1.3333333333333333 2.0) -2.0) 2.0)) -1.0)
   (fma
    (fma (* x x) 0.13333333333333333 -0.3333333333333333)
    (* x (* x x))
    x)))
double code(double x, double y) {
	double tmp;
	if ((2.0 / (1.0 + exp((-2.0 * x)))) <= 2e-42) {
		tmp = (2.0 / fma(x, fma(x, fma(x, -1.3333333333333333, 2.0), -2.0), 2.0)) + -1.0;
	} else {
		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), (x * (x * x)), x);
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) <= 2e-42)
		tmp = Float64(Float64(2.0 / fma(x, fma(x, fma(x, -1.3333333333333333, 2.0), -2.0), 2.0)) + -1.0);
	else
		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(x * Float64(x * x)), x);
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-42], N[(N[(2.0 / N[(x * N[(x * N[(x * -1.3333333333333333 + 2.0), $MachinePrecision] + -2.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} \leq 2 \cdot 10^{-42}:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -1.3333333333333333, 2\right), -2\right), 2\right)} + -1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) < 2.00000000000000008e-42

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-4}{3}} + 2, -2\right), 2\right)} - 1 \]
      8. lower-fma.f6499.0

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -1.3333333333333333, 2\right)}, -2\right), 2\right)} - 1 \]
    5. Applied rewrites99.0%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -1.3333333333333333, 2\right), -2\right), 2\right)}} - 1 \]

    if 2.00000000000000008e-42 < (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))))

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}, x \cdot {x}^{2}, x\right)} \]
      8. sub-negN/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2} \cdot \frac{2}{15}} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), x \cdot {x}^{2}, x\right) \]
      10. metadata-evalN/A

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
    5. Applied rewrites70.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} \leq 2 \cdot 10^{-42}:\\ \;\;\;\;\frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -1.3333333333333333, 2\right), -2\right), 2\right)} + -1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 99.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq -0.01:\\ \;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} + -1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (* -2.0 x) -0.01)
   (+ (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) -1.0)
   (expm1 (- (- x)))))
double code(double x, double y) {
	double tmp;
	if ((-2.0 * x) <= -0.01) {
		tmp = (2.0 / (1.0 + exp((-2.0 * x)))) + -1.0;
	} else {
		tmp = expm1(-(-x));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if ((-2.0 * x) <= -0.01) {
		tmp = (2.0 / (1.0 + Math.exp((-2.0 * x)))) + -1.0;
	} else {
		tmp = Math.expm1(-(-x));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (-2.0 * x) <= -0.01:
		tmp = (2.0 / (1.0 + math.exp((-2.0 * x)))) + -1.0
	else:
		tmp = math.expm1(-(-x))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(-2.0 * x) <= -0.01)
		tmp = Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) + -1.0);
	else
		tmp = expm1(Float64(-Float64(-x)));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], -0.01], N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(Exp[(-(-x))] - 1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -0.01:\\
\;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} + -1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal -2 binary64) x) < -0.0100000000000000002

    1. Initial program 99.7%

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1 \]
    2. Add Preprocessing

    if -0.0100000000000000002 < (*.f64 #s(literal -2 binary64) x)

    1. Initial program 34.3%

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

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

        \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}}} - 1 \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}} - 1 \]
      4. inv-powN/A

        \[\leadsto \color{blue}{{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{-1}} - 1 \]
      5. metadata-evalN/A

        \[\leadsto {\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      6. pow-to-expN/A

        \[\leadsto \color{blue}{e^{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
      7. lower-expm1.f64N/A

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}\right) \]
      9. lower-log.f64N/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      10. div-invN/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
      13. metadata-eval34.3

        \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot \color{blue}{-1}\right) \]
    4. Applied rewrites34.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot -1\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-1 \cdot x\right)} \cdot -1\right) \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot -1\right) \]
      2. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-x\right)} \cdot -1\right) \]
    7. Applied rewrites99.7%

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

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

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-1 \cdot \left(-x\right)}\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{neg}\left(\left(-x\right)\right)}\right) \]
      4. lower-neg.f6499.7

        \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
    9. Applied rewrites99.7%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq -0.01:\\ \;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} + -1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(-\left(-x\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 74.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{-2 \cdot x} \leq 2:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{2 - \left(x + x\right)} + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 (*.f64 #s(literal -2 binary64) x)) < 2

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.3333333333333333, x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
    5. Applied rewrites69.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)} \]

    if 2 < (exp.f64 (*.f64 #s(literal -2 binary64) x))

    1. Initial program 100.0%

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

      \[\leadsto \frac{2}{\color{blue}{2 + -2 \cdot x}} - 1 \]
    4. Step-by-step derivation
      1. metadata-evalN/A

        \[\leadsto \frac{2}{2 + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \cdot x} - 1 \]
      2. cancel-sign-sub-invN/A

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

        \[\leadsto \frac{2}{\color{blue}{2 - 2 \cdot x}} - 1 \]
      4. count-2N/A

        \[\leadsto \frac{2}{2 - \color{blue}{\left(x + x\right)}} - 1 \]
      5. lower-+.f6497.6

        \[\leadsto \frac{2}{2 - \color{blue}{\left(x + x\right)}} - 1 \]
    5. Applied rewrites97.6%

      \[\leadsto \frac{2}{\color{blue}{2 - \left(x + x\right)}} - 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification75.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-2 \cdot x} \leq 2:\\ \;\;\;\;\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{2 - \left(x + x\right)} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 74.7% accurate, 1.2× speedup?

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

\\
\mathsf{expm1}\left(-\left(-x\right)\right)
\end{array}
Derivation
  1. Initial program 50.4%

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

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

      \[\leadsto \color{blue}{\frac{2}{1 + e^{-2 \cdot x}}} - 1 \]
    3. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{1 + e^{-2 \cdot x}}{2}}} - 1 \]
    4. inv-powN/A

      \[\leadsto \color{blue}{{\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{-1}} - 1 \]
    5. metadata-evalN/A

      \[\leadsto {\left(\frac{1 + e^{-2 \cdot x}}{2}\right)}^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
    6. pow-to-expN/A

      \[\leadsto \color{blue}{e^{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}} - 1 \]
    7. lower-expm1.f64N/A

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right)} \]
    8. lower-*.f64N/A

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)}\right) \]
    9. lower-log.f64N/A

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + e^{-2 \cdot x}}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
    10. div-invN/A

      \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
    11. lower-*.f64N/A

      \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\left(1 + e^{-2 \cdot x}\right) \cdot \frac{1}{2}\right)} \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \]
    13. metadata-eval50.4

      \[\leadsto \mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot \color{blue}{-1}\right) \]
  4. Applied rewrites50.4%

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\log \left(\left(1 + e^{-2 \cdot x}\right) \cdot 0.5\right) \cdot -1\right)} \]
  5. Taylor expanded in x around 0

    \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-1 \cdot x\right)} \cdot -1\right) \]
  6. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot -1\right) \]
    2. lower-neg.f6476.2

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\left(-x\right)} \cdot -1\right) \]
  7. Applied rewrites76.2%

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

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

      \[\leadsto \mathsf{expm1}\left(\color{blue}{-1 \cdot \left(-x\right)}\right) \]
    3. mul-1-negN/A

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{neg}\left(\left(-x\right)\right)}\right) \]
    4. lower-neg.f6476.2

      \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
  9. Applied rewrites76.2%

    \[\leadsto \mathsf{expm1}\left(\color{blue}{-\left(-x\right)}\right) \]
  10. Add Preprocessing

Alternative 9: 74.4% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -1.3333333333333333, 2\right), -2\right)} + -1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (* -2.0 x) 2e-13)
   (fma (fma (* x x) 0.13333333333333333 -0.3333333333333333) (* x (* x x)) x)
   (+ (/ 2.0 (* x (fma x (fma x -1.3333333333333333 2.0) -2.0))) -1.0)))
double code(double x, double y) {
	double tmp;
	if ((-2.0 * x) <= 2e-13) {
		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), (x * (x * x)), x);
	} else {
		tmp = (2.0 / (x * fma(x, fma(x, -1.3333333333333333, 2.0), -2.0))) + -1.0;
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (Float64(-2.0 * x) <= 2e-13)
		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(x * Float64(x * x)), x);
	else
		tmp = Float64(Float64(2.0 / Float64(x * fma(x, fma(x, -1.3333333333333333, 2.0), -2.0))) + -1.0);
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], 2e-13], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(2.0 / N[(x * N[(x * N[(x * -1.3333333333333333 + 2.0), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -1.3333333333333333, 2\right), -2\right)} + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal -2 binary64) x) < 2.0000000000000001e-13

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}, x \cdot {x}^{2}, x\right)} \]
      8. sub-negN/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2} \cdot \frac{2}{15}} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), x \cdot {x}^{2}, x\right) \]
      10. metadata-evalN/A

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
    5. Applied rewrites70.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)} \]

    if 2.0000000000000001e-13 < (*.f64 #s(literal -2 binary64) x)

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-4}{3}} + 2, -2\right), 2\right)} - 1 \]
      8. lower-fma.f6499.0

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -1.3333333333333333, 2\right)}, -2\right), 2\right)} - 1 \]
    5. Applied rewrites99.0%

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, -2, 2\right)} - 1 \]
    7. Step-by-step derivation
      1. Applied rewrites97.6%

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, -2, 2\right)} - 1 \]
      2. Taylor expanded in x around inf

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

        \[\leadsto \frac{2}{x \cdot \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, -1.3333333333333333, 2\right), -2\right)}} - 1 \]
    8. Recombined 2 regimes into one program.
    9. Final simplification76.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -1.3333333333333333, 2\right), -2\right)} + -1\\ \end{array} \]
    10. Add Preprocessing

    Alternative 10: 74.4% accurate, 2.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x \cdot \left(x \cdot \mathsf{fma}\left(x, -1.3333333333333333, 2\right)\right)} + -1\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (if (<= (* -2.0 x) 2e-13)
       (fma (fma (* x x) 0.13333333333333333 -0.3333333333333333) (* x (* x x)) x)
       (+ (/ 2.0 (* x (* x (fma x -1.3333333333333333 2.0)))) -1.0)))
    double code(double x, double y) {
    	double tmp;
    	if ((-2.0 * x) <= 2e-13) {
    		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), (x * (x * x)), x);
    	} else {
    		tmp = (2.0 / (x * (x * fma(x, -1.3333333333333333, 2.0)))) + -1.0;
    	}
    	return tmp;
    }
    
    function code(x, y)
    	tmp = 0.0
    	if (Float64(-2.0 * x) <= 2e-13)
    		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(x * Float64(x * x)), x);
    	else
    		tmp = Float64(Float64(2.0 / Float64(x * Float64(x * fma(x, -1.3333333333333333, 2.0)))) + -1.0);
    	end
    	return tmp
    end
    
    code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], 2e-13], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(2.0 / N[(x * N[(x * N[(x * -1.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{2}{x \cdot \left(x \cdot \mathsf{fma}\left(x, -1.3333333333333333, 2\right)\right)} + -1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 #s(literal -2 binary64) x) < 2.0000000000000001e-13

      1. Initial program 36.2%

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}, x \cdot {x}^{2}, x\right)} \]
        8. sub-negN/A

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2} \cdot \frac{2}{15}} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), x \cdot {x}^{2}, x\right) \]
        10. metadata-evalN/A

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
      5. Applied rewrites70.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)} \]

      if 2.0000000000000001e-13 < (*.f64 #s(literal -2 binary64) x)

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

          \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-4}{3}} + 2, -2\right), 2\right)} - 1 \]
        8. lower-fma.f6499.0

          \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -1.3333333333333333, 2\right)}, -2\right), 2\right)} - 1 \]
      5. Applied rewrites99.0%

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

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

          \[\leadsto \frac{2}{x \cdot \color{blue}{\left(x \cdot \mathsf{fma}\left(x, -1.3333333333333333, 2\right)\right)}} - 1 \]
      8. Recombined 2 regimes into one program.
      9. Final simplification76.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x \cdot \left(x \cdot \mathsf{fma}\left(x, -1.3333333333333333, 2\right)\right)} + -1\\ \end{array} \]
      10. Add Preprocessing

      Alternative 11: 74.4% accurate, 3.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x \cdot \left(-1.3333333333333333 \cdot \left(x \cdot x\right)\right)} + -1\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (<= (* -2.0 x) 2e-13)
         (fma (fma (* x x) 0.13333333333333333 -0.3333333333333333) (* x (* x x)) x)
         (+ (/ 2.0 (* x (* -1.3333333333333333 (* x x)))) -1.0)))
      double code(double x, double y) {
      	double tmp;
      	if ((-2.0 * x) <= 2e-13) {
      		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), (x * (x * x)), x);
      	} else {
      		tmp = (2.0 / (x * (-1.3333333333333333 * (x * x)))) + -1.0;
      	}
      	return tmp;
      }
      
      function code(x, y)
      	tmp = 0.0
      	if (Float64(-2.0 * x) <= 2e-13)
      		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(x * Float64(x * x)), x);
      	else
      		tmp = Float64(Float64(2.0 / Float64(x * Float64(-1.3333333333333333 * Float64(x * x)))) + -1.0);
      	end
      	return tmp
      end
      
      code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], 2e-13], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(2.0 / N[(x * N[(-1.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{2}{x \cdot \left(-1.3333333333333333 \cdot \left(x \cdot x\right)\right)} + -1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 #s(literal -2 binary64) x) < 2.0000000000000001e-13

        1. Initial program 36.2%

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}, x \cdot {x}^{2}, x\right)} \]
          8. sub-negN/A

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2} \cdot \frac{2}{15}} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), x \cdot {x}^{2}, x\right) \]
          10. metadata-evalN/A

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
        5. Applied rewrites70.3%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)} \]

        if 2.0000000000000001e-13 < (*.f64 #s(literal -2 binary64) x)

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

            \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-4}{3}} + 2, -2\right), 2\right)} - 1 \]
          8. lower-fma.f6499.0

            \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -1.3333333333333333, 2\right)}, -2\right), 2\right)} - 1 \]
        5. Applied rewrites99.0%

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

          \[\leadsto \frac{2}{\frac{-4}{3} \cdot \color{blue}{{x}^{3}}} - 1 \]
        7. Step-by-step derivation
          1. Applied rewrites99.0%

            \[\leadsto \frac{2}{x \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot -1.3333333333333333\right)}} - 1 \]
        8. Recombined 2 regimes into one program.
        9. Final simplification76.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x \cdot \left(-1.3333333333333333 \cdot \left(x \cdot x\right)\right)} + -1\\ \end{array} \]
        10. Add Preprocessing

        Alternative 12: 74.9% accurate, 3.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\mathsf{fma}\left(x, -2 + \left(x + x\right), 2\right)} + -1\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (if (<= (* -2.0 x) 2e-13)
           (fma (fma (* x x) 0.13333333333333333 -0.3333333333333333) (* x (* x x)) x)
           (+ (/ 2.0 (fma x (+ -2.0 (+ x x)) 2.0)) -1.0)))
        double code(double x, double y) {
        	double tmp;
        	if ((-2.0 * x) <= 2e-13) {
        		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), (x * (x * x)), x);
        	} else {
        		tmp = (2.0 / fma(x, (-2.0 + (x + x)), 2.0)) + -1.0;
        	}
        	return tmp;
        }
        
        function code(x, y)
        	tmp = 0.0
        	if (Float64(-2.0 * x) <= 2e-13)
        		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(x * Float64(x * x)), x);
        	else
        		tmp = Float64(Float64(2.0 / fma(x, Float64(-2.0 + Float64(x + x)), 2.0)) + -1.0);
        	end
        	return tmp
        end
        
        code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], 2e-13], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(2.0 / N[(x * N[(-2.0 + N[(x + x), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\
        \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{2}{\mathsf{fma}\left(x, -2 + \left(x + x\right), 2\right)} + -1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 #s(literal -2 binary64) x) < 2.0000000000000001e-13

          1. Initial program 36.2%

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}, x \cdot {x}^{2}, x\right)} \]
            8. sub-negN/A

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

              \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2} \cdot \frac{2}{15}} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), x \cdot {x}^{2}, x\right) \]
            10. metadata-evalN/A

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
          5. Applied rewrites70.3%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)} \]

          if 2.0000000000000001e-13 < (*.f64 #s(literal -2 binary64) x)

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

              \[\leadsto \frac{2}{\mathsf{fma}\left(x, -2 + \color{blue}{\left(x + x\right)}, 2\right)} - 1 \]
            8. lower-+.f6498.5

              \[\leadsto \frac{2}{\mathsf{fma}\left(x, -2 + \color{blue}{\left(x + x\right)}, 2\right)} - 1 \]
          5. Applied rewrites98.5%

            \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, -2 + \left(x + x\right), 2\right)}} - 1 \]
        3. Recombined 2 regimes into one program.
        4. Final simplification76.6%

          \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\mathsf{fma}\left(x, -2 + \left(x + x\right), 2\right)} + -1\\ \end{array} \]
        5. Add Preprocessing

        Alternative 13: 74.7% accurate, 3.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{2}{\mathsf{fma}\left(x, -2 + \left(x + x\right), 2\right)} + -1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (if (<= x -1.0)
           (+ (/ 2.0 (fma x (+ -2.0 (+ x x)) 2.0)) -1.0)
           (fma -0.3333333333333333 (* x (* x x)) x)))
        double code(double x, double y) {
        	double tmp;
        	if (x <= -1.0) {
        		tmp = (2.0 / fma(x, (-2.0 + (x + x)), 2.0)) + -1.0;
        	} else {
        		tmp = fma(-0.3333333333333333, (x * (x * x)), x);
        	}
        	return tmp;
        }
        
        function code(x, y)
        	tmp = 0.0
        	if (x <= -1.0)
        		tmp = Float64(Float64(2.0 / fma(x, Float64(-2.0 + Float64(x + x)), 2.0)) + -1.0);
        	else
        		tmp = fma(-0.3333333333333333, Float64(x * Float64(x * x)), x);
        	end
        	return tmp
        end
        
        code[x_, y_] := If[LessEqual[x, -1.0], N[(N[(2.0 / N[(x * N[(-2.0 + N[(x + x), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(-0.3333333333333333 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq -1:\\
        \;\;\;\;\frac{2}{\mathsf{fma}\left(x, -2 + \left(x + x\right), 2\right)} + -1\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < -1

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

              \[\leadsto \frac{2}{\mathsf{fma}\left(x, -2 + \color{blue}{\left(x + x\right)}, 2\right)} - 1 \]
            8. lower-+.f6498.5

              \[\leadsto \frac{2}{\mathsf{fma}\left(x, -2 + \color{blue}{\left(x + x\right)}, 2\right)} - 1 \]
          5. Applied rewrites98.5%

            \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, -2 + \left(x + x\right), 2\right)}} - 1 \]

          if -1 < x

          1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(-0.3333333333333333, x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
          5. Applied rewrites69.3%

            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification75.8%

          \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{2}{\mathsf{fma}\left(x, -2 + \left(x + x\right), 2\right)} + -1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)\\ \end{array} \]
        5. Add Preprocessing

        Alternative 14: 74.6% accurate, 3.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.2:\\ \;\;\;\;\frac{2}{x \cdot \mathsf{fma}\left(x, 2, -2\right)} + -1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (if (<= x -1.2)
           (+ (/ 2.0 (* x (fma x 2.0 -2.0))) -1.0)
           (fma -0.3333333333333333 (* x (* x x)) x)))
        double code(double x, double y) {
        	double tmp;
        	if (x <= -1.2) {
        		tmp = (2.0 / (x * fma(x, 2.0, -2.0))) + -1.0;
        	} else {
        		tmp = fma(-0.3333333333333333, (x * (x * x)), x);
        	}
        	return tmp;
        }
        
        function code(x, y)
        	tmp = 0.0
        	if (x <= -1.2)
        		tmp = Float64(Float64(2.0 / Float64(x * fma(x, 2.0, -2.0))) + -1.0);
        	else
        		tmp = fma(-0.3333333333333333, Float64(x * Float64(x * x)), x);
        	end
        	return tmp
        end
        
        code[x_, y_] := If[LessEqual[x, -1.2], N[(N[(2.0 / N[(x * N[(x * 2.0 + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(-0.3333333333333333 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq -1.2:\\
        \;\;\;\;\frac{2}{x \cdot \mathsf{fma}\left(x, 2, -2\right)} + -1\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < -1.19999999999999996

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

              \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-4}{3}} + 2, -2\right), 2\right)} - 1 \]
            8. lower-fma.f6499.0

              \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -1.3333333333333333, 2\right)}, -2\right), 2\right)} - 1 \]
          5. Applied rewrites99.0%

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

            \[\leadsto \frac{2}{\mathsf{fma}\left(x, -2, 2\right)} - 1 \]
          7. Step-by-step derivation
            1. Applied rewrites97.6%

              \[\leadsto \frac{2}{\mathsf{fma}\left(x, -2, 2\right)} - 1 \]
            2. Taylor expanded in x around inf

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

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

              \[\leadsto \frac{2}{x \cdot \mathsf{fma}\left(x, 2, -2\right)} - 1 \]
            5. Step-by-step derivation
              1. Applied rewrites98.5%

                \[\leadsto \frac{2}{x \cdot \mathsf{fma}\left(x, 2, -2\right)} - 1 \]

              if -1.19999999999999996 < x

              1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(-0.3333333333333333, x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
              5. Applied rewrites69.3%

                \[\leadsto \color{blue}{\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)} \]
            6. Recombined 2 regimes into one program.
            7. Final simplification75.8%

              \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.2:\\ \;\;\;\;\frac{2}{x \cdot \mathsf{fma}\left(x, 2, -2\right)} + -1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)\\ \end{array} \]
            8. Add Preprocessing

            Alternative 15: 49.8% accurate, 7.2× speedup?

            \[\begin{array}{l} \\ \mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right) \end{array} \]
            (FPCore (x y) :precision binary64 (fma -0.3333333333333333 (* x (* x x)) x))
            double code(double x, double y) {
            	return fma(-0.3333333333333333, (x * (x * x)), x);
            }
            
            function code(x, y)
            	return fma(-0.3333333333333333, Float64(x * Float64(x * x)), x)
            end
            
            code[x_, y_] := N[(-0.3333333333333333 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)
            \end{array}
            
            Derivation
            1. Initial program 50.4%

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\frac{-1}{3}, x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
              10. lower-*.f6454.0

                \[\leadsto \mathsf{fma}\left(-0.3333333333333333, x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
            5. Applied rewrites54.0%

              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.3333333333333333, x \cdot \left(x \cdot x\right), x\right)} \]
            6. Add Preprocessing

            Alternative 16: 6.6% accurate, 17.6× speedup?

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

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

              \[\leadsto \color{blue}{\left(1 + x\right)} - 1 \]
            4. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \color{blue}{\left(x + 1\right)} - 1 \]
              2. lower-+.f646.5

                \[\leadsto \color{blue}{\left(x + 1\right)} - 1 \]
            5. Applied rewrites6.5%

              \[\leadsto \color{blue}{\left(x + 1\right)} - 1 \]
            6. Final simplification6.5%

              \[\leadsto \left(x + 1\right) + -1 \]
            7. Add Preprocessing

            Alternative 17: 4.2% accurate, 30.8× speedup?

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

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

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

                \[\leadsto \color{blue}{1} - 1 \]
              2. Final simplification4.5%

                \[\leadsto 1 + -1 \]
              3. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2024221 
              (FPCore (x y)
                :name "Logistic function from Lakshay Garg"
                :precision binary64
                (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))