Logistic function from Lakshay Garg

Percentage Accurate: 54.5% → 99.4%
Time: 9.0s
Alternatives: 10
Speedup: 10.2×

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 10 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.5% 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.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq -5000:\\ \;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} + -1\\ \mathbf{elif}\;-2 \cdot x \leq 0.002:\\ \;\;\;\;\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}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (* -2.0 x) -5000.0)
   (+ (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) -1.0)
   (if (<= (* -2.0 x) 0.002)
     (fma
      (fma (* x x) 0.13333333333333333 -0.3333333333333333)
      (* x (* x x))
      x)
     -1.0)))
double code(double x, double y) {
	double tmp;
	if ((-2.0 * x) <= -5000.0) {
		tmp = (2.0 / (1.0 + exp((-2.0 * x)))) + -1.0;
	} else if ((-2.0 * x) <= 0.002) {
		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), (x * (x * x)), x);
	} else {
		tmp = -1.0;
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (Float64(-2.0 * x) <= -5000.0)
		tmp = Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) + -1.0);
	elseif (Float64(-2.0 * x) <= 0.002)
		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(x * Float64(x * x)), x);
	else
		tmp = -1.0;
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], -5000.0], N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(-2.0 * x), $MachinePrecision], 0.002], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], -1.0]]
\begin{array}{l}

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

\mathbf{elif}\;-2 \cdot x \leq 0.002:\\
\;\;\;\;\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}:\\
\;\;\;\;-1\\


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

    1. Initial program 100.0%

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

    if -5e3 < (*.f64 #s(literal -2 binary64) x) < 2e-3

    1. Initial program 8.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 + {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-*.f64100.0

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

      \[\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 2e-3 < (*.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.f64100.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. Simplified100.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 \color{blue}{-1} \]
    7. Step-by-step derivation
      1. Simplified100.0%

        \[\leadsto \color{blue}{-1} \]
    8. Recombined 3 regimes into one program.
    9. Final simplification100.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq -5000:\\ \;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} + -1\\ \mathbf{elif}\;-2 \cdot x \leq 0.002:\\ \;\;\;\;\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}:\\ \;\;\;\;-1\\ \end{array} \]
    10. Add Preprocessing

    Alternative 2: 79.4% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-2 \cdot x}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\mathsf{fma}\left(x, x \cdot x, 1\right)}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right)\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\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}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (let* ((t_0 (exp (* -2.0 x))))
       (if (<= t_0 0.0)
         (fma (/ (fma x x -1.0) (fma x (* x x) 1.0)) (fma x (+ x -1.0) 1.0) 1.0)
         (if (<= t_0 2.0)
           (fma
            (fma (* x x) 0.13333333333333333 -0.3333333333333333)
            (* x (* x x))
            x)
           -1.0))))
    double code(double x, double y) {
    	double t_0 = exp((-2.0 * x));
    	double tmp;
    	if (t_0 <= 0.0) {
    		tmp = fma((fma(x, x, -1.0) / fma(x, (x * x), 1.0)), fma(x, (x + -1.0), 1.0), 1.0);
    	} else if (t_0 <= 2.0) {
    		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), (x * (x * x)), x);
    	} else {
    		tmp = -1.0;
    	}
    	return tmp;
    }
    
    function code(x, y)
    	t_0 = exp(Float64(-2.0 * x))
    	tmp = 0.0
    	if (t_0 <= 0.0)
    		tmp = fma(Float64(fma(x, x, -1.0) / fma(x, Float64(x * x), 1.0)), fma(x, Float64(x + -1.0), 1.0), 1.0);
    	elseif (t_0 <= 2.0)
    		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(x * Float64(x * x)), x);
    	else
    		tmp = -1.0;
    	end
    	return tmp
    end
    
    code[x_, y_] := Block[{t$95$0 = N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(x * x + -1.0), $MachinePrecision] / N[(x * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], -1.0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := e^{-2 \cdot x}\\
    \mathbf{if}\;t\_0 \leq 0:\\
    \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\mathsf{fma}\left(x, x \cdot x, 1\right)}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right)\\
    
    \mathbf{elif}\;t\_0 \leq 2:\\
    \;\;\;\;\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}:\\
    \;\;\;\;-1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (exp.f64 (*.f64 #s(literal -2 binary64) x)) < 0.0

      1. Initial program 100.0%

        \[\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-+.f645.3

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

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

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

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

          \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
        4. flip--N/A

          \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
        5. flip3-+N/A

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

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

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

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

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

      1. Initial program 8.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 + {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-*.f64100.0

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

        \[\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 < (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 + 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.f64100.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. Simplified100.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 \color{blue}{-1} \]
      7. Step-by-step derivation
        1. Simplified100.0%

          \[\leadsto \color{blue}{-1} \]
      8. Recombined 3 regimes into one program.
      9. Add Preprocessing

      Alternative 3: 79.4% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-2 \cdot x}\\ t_1 := x \cdot \left(x \cdot x\right)\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{t\_1}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right)\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), t\_1, x\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (let* ((t_0 (exp (* -2.0 x))) (t_1 (* x (* x x))))
         (if (<= t_0 0.0)
           (fma (/ (fma x x -1.0) t_1) (fma x (+ x -1.0) 1.0) 1.0)
           (if (<= t_0 2.0)
             (fma (fma (* x x) 0.13333333333333333 -0.3333333333333333) t_1 x)
             -1.0))))
      double code(double x, double y) {
      	double t_0 = exp((-2.0 * x));
      	double t_1 = x * (x * x);
      	double tmp;
      	if (t_0 <= 0.0) {
      		tmp = fma((fma(x, x, -1.0) / t_1), fma(x, (x + -1.0), 1.0), 1.0);
      	} else if (t_0 <= 2.0) {
      		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), t_1, x);
      	} else {
      		tmp = -1.0;
      	}
      	return tmp;
      }
      
      function code(x, y)
      	t_0 = exp(Float64(-2.0 * x))
      	t_1 = Float64(x * Float64(x * x))
      	tmp = 0.0
      	if (t_0 <= 0.0)
      		tmp = fma(Float64(fma(x, x, -1.0) / t_1), fma(x, Float64(x + -1.0), 1.0), 1.0);
      	elseif (t_0 <= 2.0)
      		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), t_1, x);
      	else
      		tmp = -1.0;
      	end
      	return tmp
      end
      
      code[x_, y_] := Block[{t$95$0 = N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(x * x + -1.0), $MachinePrecision] / t$95$1), $MachinePrecision] * N[(x * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * t$95$1 + x), $MachinePrecision], -1.0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := e^{-2 \cdot x}\\
      t_1 := x \cdot \left(x \cdot x\right)\\
      \mathbf{if}\;t\_0 \leq 0:\\
      \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{t\_1}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right)\\
      
      \mathbf{elif}\;t\_0 \leq 2:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), t\_1, x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;-1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (exp.f64 (*.f64 #s(literal -2 binary64) x)) < 0.0

        1. Initial program 100.0%

          \[\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-+.f645.3

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

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

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

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

            \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
          4. flip--N/A

            \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
          5. flip3-+N/A

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\color{blue}{{x}^{3}}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
        9. Step-by-step derivation
          1. cube-multN/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{x \cdot \color{blue}{\left(x \cdot x\right)}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
        10. Simplified20.8%

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

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

        1. Initial program 8.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 + {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-*.f64100.0

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

          \[\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 < (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 + 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.f64100.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. Simplified100.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 \color{blue}{-1} \]
        7. Step-by-step derivation
          1. Simplified100.0%

            \[\leadsto \color{blue}{-1} \]
        8. Recombined 3 regimes into one program.
        9. Add Preprocessing

        Alternative 4: 75.6% accurate, 0.9× speedup?

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

          1. Initial program 36.0%

            \[\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-+.f647.1

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

            \[\leadsto \color{blue}{\left(x + 1\right)} - 1 \]
          6. Step-by-step derivation
            1. associate--l+N/A

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

              \[\leadsto x + \color{blue}{0} \]
            3. +-rgt-identity70.8

              \[\leadsto \color{blue}{x} \]
          7. Applied egg-rr70.8%

            \[\leadsto \color{blue}{x} \]

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

          1. Initial program 99.8%

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

              \[\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. Simplified99.5%

            \[\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 \]
        3. Recombined 2 regimes into one program.
        4. Final simplification77.6%

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

        Alternative 5: 83.4% accurate, 1.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(x, x + -1, 1\right)\\ t_1 := x \cdot \left(x \cdot x\right)\\ \mathbf{if}\;x \leq -1.22:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.6:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), t\_1, x\right)\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\mathsf{fma}\left(t\_1, t\_1, -1\right)} \cdot \mathsf{fma}\left(x, x \cdot x, -1\right), t\_0, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{t\_1}, t\_0, 1\right)\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (let* ((t_0 (fma x (+ x -1.0) 1.0)) (t_1 (* x (* x x))))
           (if (<= x -1.22)
             -1.0
             (if (<= x 1.6)
               (fma (fma (* x x) 0.13333333333333333 -0.3333333333333333) t_1 x)
               (if (<= x 5.8e+102)
                 (fma
                  (* (/ (fma x x -1.0) (fma t_1 t_1 -1.0)) (fma x (* x x) -1.0))
                  t_0
                  1.0)
                 (fma (/ (fma x x -1.0) t_1) t_0 1.0))))))
        double code(double x, double y) {
        	double t_0 = fma(x, (x + -1.0), 1.0);
        	double t_1 = x * (x * x);
        	double tmp;
        	if (x <= -1.22) {
        		tmp = -1.0;
        	} else if (x <= 1.6) {
        		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), t_1, x);
        	} else if (x <= 5.8e+102) {
        		tmp = fma(((fma(x, x, -1.0) / fma(t_1, t_1, -1.0)) * fma(x, (x * x), -1.0)), t_0, 1.0);
        	} else {
        		tmp = fma((fma(x, x, -1.0) / t_1), t_0, 1.0);
        	}
        	return tmp;
        }
        
        function code(x, y)
        	t_0 = fma(x, Float64(x + -1.0), 1.0)
        	t_1 = Float64(x * Float64(x * x))
        	tmp = 0.0
        	if (x <= -1.22)
        		tmp = -1.0;
        	elseif (x <= 1.6)
        		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), t_1, x);
        	elseif (x <= 5.8e+102)
        		tmp = fma(Float64(Float64(fma(x, x, -1.0) / fma(t_1, t_1, -1.0)) * fma(x, Float64(x * x), -1.0)), t_0, 1.0);
        	else
        		tmp = fma(Float64(fma(x, x, -1.0) / t_1), t_0, 1.0);
        	end
        	return tmp
        end
        
        code[x_, y_] := Block[{t$95$0 = N[(x * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.22], -1.0, If[LessEqual[x, 1.6], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * t$95$1 + x), $MachinePrecision], If[LessEqual[x, 5.8e+102], N[(N[(N[(N[(x * x + -1.0), $MachinePrecision] / N[(t$95$1 * t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision], N[(N[(N[(x * x + -1.0), $MachinePrecision] / t$95$1), $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \mathsf{fma}\left(x, x + -1, 1\right)\\
        t_1 := x \cdot \left(x \cdot x\right)\\
        \mathbf{if}\;x \leq -1.22:\\
        \;\;\;\;-1\\
        
        \mathbf{elif}\;x \leq 1.6:\\
        \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), t\_1, x\right)\\
        
        \mathbf{elif}\;x \leq 5.8 \cdot 10^{+102}:\\
        \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\mathsf{fma}\left(t\_1, t\_1, -1\right)} \cdot \mathsf{fma}\left(x, x \cdot x, -1\right), t\_0, 1\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{t\_1}, t\_0, 1\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 4 regimes
        2. if x < -1.21999999999999997

          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.f64100.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. Simplified100.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 \color{blue}{-1} \]
          7. Step-by-step derivation
            1. Simplified100.0%

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

            if -1.21999999999999997 < x < 1.6000000000000001

            1. Initial program 8.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 + {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-*.f64100.0

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

              \[\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 1.6000000000000001 < x < 5.8000000000000005e102

            1. Initial program 100.0%

              \[\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-+.f647.7

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

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

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

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

                \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
              4. flip--N/A

                \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
              5. flip3-+N/A

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

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

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

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

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

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

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

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

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

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

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

            if 5.8000000000000005e102 < 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 \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-+.f644.2

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

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

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

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

                \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
              4. flip--N/A

                \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
              5. flip3-+N/A

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\color{blue}{{x}^{3}}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
            9. Step-by-step derivation
              1. cube-multN/A

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{x \cdot \color{blue}{\left(x \cdot x\right)}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
            10. Simplified26.8%

              \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\color{blue}{x \cdot \left(x \cdot x\right)}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
          8. Recombined 4 regimes into one program.
          9. Add Preprocessing

          Alternative 6: 82.5% accurate, 1.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(x, x + -1, 1\right)\\ t_1 := x \cdot \left(x \cdot x\right)\\ \mathbf{if}\;x \leq -1.22:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.6:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), t\_1, x\right)\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, t\_1, -1\right)}{\mathsf{fma}\left(x, x \cdot x, 1\right) \cdot \mathsf{fma}\left(x, x, 1\right)}, t\_0, 1\right)\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot x, -1\right), \frac{\mathsf{fma}\left(x, x, 1 - x\right)}{\mathsf{fma}\left(x, t\_1, 1 + x \cdot x\right)}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{t\_1}, t\_0, 1\right)\\ \end{array} \end{array} \]
          (FPCore (x y)
           :precision binary64
           (let* ((t_0 (fma x (+ x -1.0) 1.0)) (t_1 (* x (* x x))))
             (if (<= x -1.22)
               -1.0
               (if (<= x 1.6)
                 (fma (fma (* x x) 0.13333333333333333 -0.3333333333333333) t_1 x)
                 (if (<= x 1.15e+77)
                   (fma
                    (/ (fma x t_1 -1.0) (* (fma x (* x x) 1.0) (fma x x 1.0)))
                    t_0
                    1.0)
                   (if (<= x 5.8e+102)
                     (fma
                      (fma x (* x x) -1.0)
                      (/ (fma x x (- 1.0 x)) (fma x t_1 (+ 1.0 (* x x))))
                      1.0)
                     (fma (/ (fma x x -1.0) t_1) t_0 1.0)))))))
          double code(double x, double y) {
          	double t_0 = fma(x, (x + -1.0), 1.0);
          	double t_1 = x * (x * x);
          	double tmp;
          	if (x <= -1.22) {
          		tmp = -1.0;
          	} else if (x <= 1.6) {
          		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), t_1, x);
          	} else if (x <= 1.15e+77) {
          		tmp = fma((fma(x, t_1, -1.0) / (fma(x, (x * x), 1.0) * fma(x, x, 1.0))), t_0, 1.0);
          	} else if (x <= 5.8e+102) {
          		tmp = fma(fma(x, (x * x), -1.0), (fma(x, x, (1.0 - x)) / fma(x, t_1, (1.0 + (x * x)))), 1.0);
          	} else {
          		tmp = fma((fma(x, x, -1.0) / t_1), t_0, 1.0);
          	}
          	return tmp;
          }
          
          function code(x, y)
          	t_0 = fma(x, Float64(x + -1.0), 1.0)
          	t_1 = Float64(x * Float64(x * x))
          	tmp = 0.0
          	if (x <= -1.22)
          		tmp = -1.0;
          	elseif (x <= 1.6)
          		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), t_1, x);
          	elseif (x <= 1.15e+77)
          		tmp = fma(Float64(fma(x, t_1, -1.0) / Float64(fma(x, Float64(x * x), 1.0) * fma(x, x, 1.0))), t_0, 1.0);
          	elseif (x <= 5.8e+102)
          		tmp = fma(fma(x, Float64(x * x), -1.0), Float64(fma(x, x, Float64(1.0 - x)) / fma(x, t_1, Float64(1.0 + Float64(x * x)))), 1.0);
          	else
          		tmp = fma(Float64(fma(x, x, -1.0) / t_1), t_0, 1.0);
          	end
          	return tmp
          end
          
          code[x_, y_] := Block[{t$95$0 = N[(x * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.22], -1.0, If[LessEqual[x, 1.6], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * t$95$1 + x), $MachinePrecision], If[LessEqual[x, 1.15e+77], N[(N[(N[(x * t$95$1 + -1.0), $MachinePrecision] / N[(N[(x * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision], If[LessEqual[x, 5.8e+102], N[(N[(x * N[(x * x), $MachinePrecision] + -1.0), $MachinePrecision] * N[(N[(x * x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(x * t$95$1 + N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(x * x + -1.0), $MachinePrecision] / t$95$1), $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]]]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \mathsf{fma}\left(x, x + -1, 1\right)\\
          t_1 := x \cdot \left(x \cdot x\right)\\
          \mathbf{if}\;x \leq -1.22:\\
          \;\;\;\;-1\\
          
          \mathbf{elif}\;x \leq 1.6:\\
          \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), t\_1, x\right)\\
          
          \mathbf{elif}\;x \leq 1.15 \cdot 10^{+77}:\\
          \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, t\_1, -1\right)}{\mathsf{fma}\left(x, x \cdot x, 1\right) \cdot \mathsf{fma}\left(x, x, 1\right)}, t\_0, 1\right)\\
          
          \mathbf{elif}\;x \leq 5.8 \cdot 10^{+102}:\\
          \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot x, -1\right), \frac{\mathsf{fma}\left(x, x, 1 - x\right)}{\mathsf{fma}\left(x, t\_1, 1 + x \cdot x\right)}, 1\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{t\_1}, t\_0, 1\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 5 regimes
          2. if x < -1.21999999999999997

            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.f64100.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. Simplified100.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 \color{blue}{-1} \]
            7. Step-by-step derivation
              1. Simplified100.0%

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

              if -1.21999999999999997 < x < 1.6000000000000001

              1. Initial program 8.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 + {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-*.f64100.0

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

                \[\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 1.6000000000000001 < x < 1.14999999999999997e77

              1. Initial program 100.0%

                \[\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-+.f648.5

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

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

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

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

                  \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
                4. flip--N/A

                  \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
                5. flip3-+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x \cdot \left(x \cdot x\right), -1\right)}{\mathsf{fma}\left(x, x \cdot x, 1\right) \cdot \left(x \cdot x + \color{blue}{1}\right)}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
                18. lower-fma.f6444.5

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

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

              if 1.14999999999999997e77 < x < 5.8000000000000005e102

              1. Initial program 100.0%

                \[\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-+.f645.9

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

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

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

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

                  \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
                4. flip--N/A

                  \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
                5. flip3-+N/A

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\mathsf{fma}\left(x, x \cdot x, 1\right)}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right)} \]
              8. Applied egg-rr100.0%

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

              if 5.8000000000000005e102 < 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 \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-+.f644.2

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

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

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

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

                  \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
                4. flip--N/A

                  \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
                5. flip3-+N/A

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\color{blue}{{x}^{3}}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
              9. Step-by-step derivation
                1. cube-multN/A

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{x \cdot \color{blue}{\left(x \cdot x\right)}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
              10. Simplified26.8%

                \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\color{blue}{x \cdot \left(x \cdot x\right)}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
            8. Recombined 5 regimes into one program.
            9. Add Preprocessing

            Alternative 7: 81.2% accurate, 1.5× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(x \cdot x\right)\\ \mathbf{if}\;x \leq -1.22:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.6:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), t\_0, x\right)\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot x, -1\right), \frac{\mathsf{fma}\left(x, x, 1 - x\right)}{\mathsf{fma}\left(x, t\_0, 1 + x \cdot x\right)}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{t\_0}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right)\\ \end{array} \end{array} \]
            (FPCore (x y)
             :precision binary64
             (let* ((t_0 (* x (* x x))))
               (if (<= x -1.22)
                 -1.0
                 (if (<= x 1.6)
                   (fma (fma (* x x) 0.13333333333333333 -0.3333333333333333) t_0 x)
                   (if (<= x 5.8e+102)
                     (fma
                      (fma x (* x x) -1.0)
                      (/ (fma x x (- 1.0 x)) (fma x t_0 (+ 1.0 (* x x))))
                      1.0)
                     (fma (/ (fma x x -1.0) t_0) (fma x (+ x -1.0) 1.0) 1.0))))))
            double code(double x, double y) {
            	double t_0 = x * (x * x);
            	double tmp;
            	if (x <= -1.22) {
            		tmp = -1.0;
            	} else if (x <= 1.6) {
            		tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), t_0, x);
            	} else if (x <= 5.8e+102) {
            		tmp = fma(fma(x, (x * x), -1.0), (fma(x, x, (1.0 - x)) / fma(x, t_0, (1.0 + (x * x)))), 1.0);
            	} else {
            		tmp = fma((fma(x, x, -1.0) / t_0), fma(x, (x + -1.0), 1.0), 1.0);
            	}
            	return tmp;
            }
            
            function code(x, y)
            	t_0 = Float64(x * Float64(x * x))
            	tmp = 0.0
            	if (x <= -1.22)
            		tmp = -1.0;
            	elseif (x <= 1.6)
            		tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), t_0, x);
            	elseif (x <= 5.8e+102)
            		tmp = fma(fma(x, Float64(x * x), -1.0), Float64(fma(x, x, Float64(1.0 - x)) / fma(x, t_0, Float64(1.0 + Float64(x * x)))), 1.0);
            	else
            		tmp = fma(Float64(fma(x, x, -1.0) / t_0), fma(x, Float64(x + -1.0), 1.0), 1.0);
            	end
            	return tmp
            end
            
            code[x_, y_] := Block[{t$95$0 = N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.22], -1.0, If[LessEqual[x, 1.6], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * t$95$0 + x), $MachinePrecision], If[LessEqual[x, 5.8e+102], N[(N[(x * N[(x * x), $MachinePrecision] + -1.0), $MachinePrecision] * N[(N[(x * x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(x * t$95$0 + N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(x * x + -1.0), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(x * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := x \cdot \left(x \cdot x\right)\\
            \mathbf{if}\;x \leq -1.22:\\
            \;\;\;\;-1\\
            
            \mathbf{elif}\;x \leq 1.6:\\
            \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), t\_0, x\right)\\
            
            \mathbf{elif}\;x \leq 5.8 \cdot 10^{+102}:\\
            \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot x, -1\right), \frac{\mathsf{fma}\left(x, x, 1 - x\right)}{\mathsf{fma}\left(x, t\_0, 1 + x \cdot x\right)}, 1\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{t\_0}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 4 regimes
            2. if x < -1.21999999999999997

              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.f64100.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. Simplified100.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 \color{blue}{-1} \]
              7. Step-by-step derivation
                1. Simplified100.0%

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

                if -1.21999999999999997 < x < 1.6000000000000001

                1. Initial program 8.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 + {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-*.f64100.0

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

                  \[\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 1.6000000000000001 < x < 5.8000000000000005e102

                1. Initial program 100.0%

                  \[\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-+.f647.7

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

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

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

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

                    \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
                  4. flip--N/A

                    \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
                  5. flip3-+N/A

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

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\mathsf{fma}\left(x, x \cdot x, 1\right)}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right)} \]
                8. Applied egg-rr37.4%

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

                if 5.8000000000000005e102 < 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 \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-+.f644.2

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

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

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

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

                    \[\leadsto \color{blue}{\left(x - 1\right) + 1} \]
                  4. flip--N/A

                    \[\leadsto \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} + 1 \]
                  5. flip3-+N/A

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\color{blue}{{x}^{3}}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
                9. Step-by-step derivation
                  1. cube-multN/A

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{x \cdot \color{blue}{\left(x \cdot x\right)}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
                10. Simplified26.8%

                  \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(x, x, -1\right)}{\color{blue}{x \cdot \left(x \cdot x\right)}}, \mathsf{fma}\left(x, x + -1, 1\right), 1\right) \]
              8. Recombined 4 regimes into one program.
              9. Add Preprocessing

              Alternative 8: 75.7% accurate, 10.2× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-2 \cdot x \leq 0.002:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
              (FPCore (x y) :precision binary64 (if (<= (* -2.0 x) 0.002) x -1.0))
              double code(double x, double y) {
              	double tmp;
              	if ((-2.0 * x) <= 0.002) {
              		tmp = x;
              	} else {
              		tmp = -1.0;
              	}
              	return tmp;
              }
              
              real(8) function code(x, y)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8) :: tmp
                  if (((-2.0d0) * x) <= 0.002d0) then
                      tmp = x
                  else
                      tmp = -1.0d0
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y) {
              	double tmp;
              	if ((-2.0 * x) <= 0.002) {
              		tmp = x;
              	} else {
              		tmp = -1.0;
              	}
              	return tmp;
              }
              
              def code(x, y):
              	tmp = 0
              	if (-2.0 * x) <= 0.002:
              		tmp = x
              	else:
              		tmp = -1.0
              	return tmp
              
              function code(x, y)
              	tmp = 0.0
              	if (Float64(-2.0 * x) <= 0.002)
              		tmp = x;
              	else
              		tmp = -1.0;
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y)
              	tmp = 0.0;
              	if ((-2.0 * x) <= 0.002)
              		tmp = x;
              	else
              		tmp = -1.0;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], 0.002], x, -1.0]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;-2 \cdot x \leq 0.002:\\
              \;\;\;\;x\\
              
              \mathbf{else}:\\
              \;\;\;\;-1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (*.f64 #s(literal -2 binary64) x) < 2e-3

                1. Initial program 36.3%

                  \[\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-+.f647.3

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

                  \[\leadsto \color{blue}{\left(x + 1\right)} - 1 \]
                6. Step-by-step derivation
                  1. associate--l+N/A

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

                    \[\leadsto x + \color{blue}{0} \]
                  3. +-rgt-identity70.8

                    \[\leadsto \color{blue}{x} \]
                7. Applied egg-rr70.8%

                  \[\leadsto \color{blue}{x} \]

                if 2e-3 < (*.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.f64100.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. Simplified100.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 \color{blue}{-1} \]
                7. Step-by-step derivation
                  1. Simplified100.0%

                    \[\leadsto \color{blue}{-1} \]
                8. Recombined 2 regimes into one program.
                9. Add Preprocessing

                Alternative 9: 29.1% accurate, 17.5× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.12 \cdot 10^{-154}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
                (FPCore (x y) :precision binary64 (if (<= x -1.12e-154) -1.0 0.0))
                double code(double x, double y) {
                	double tmp;
                	if (x <= -1.12e-154) {
                		tmp = -1.0;
                	} else {
                		tmp = 0.0;
                	}
                	return tmp;
                }
                
                real(8) function code(x, y)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8) :: tmp
                    if (x <= (-1.12d-154)) then
                        tmp = -1.0d0
                    else
                        tmp = 0.0d0
                    end if
                    code = tmp
                end function
                
                public static double code(double x, double y) {
                	double tmp;
                	if (x <= -1.12e-154) {
                		tmp = -1.0;
                	} else {
                		tmp = 0.0;
                	}
                	return tmp;
                }
                
                def code(x, y):
                	tmp = 0
                	if x <= -1.12e-154:
                		tmp = -1.0
                	else:
                		tmp = 0.0
                	return tmp
                
                function code(x, y)
                	tmp = 0.0
                	if (x <= -1.12e-154)
                		tmp = -1.0;
                	else
                		tmp = 0.0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y)
                	tmp = 0.0;
                	if (x <= -1.12e-154)
                		tmp = -1.0;
                	else
                		tmp = 0.0;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_] := If[LessEqual[x, -1.12e-154], -1.0, 0.0]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;x \leq -1.12 \cdot 10^{-154}:\\
                \;\;\;\;-1\\
                
                \mathbf{else}:\\
                \;\;\;\;0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if x < -1.12e-154

                  1. Initial program 67.9%

                    \[\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.f6467.7

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

                    \[\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 \color{blue}{-1} \]
                  7. Step-by-step derivation
                    1. Simplified66.7%

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

                    if -1.12e-154 < x

                    1. Initial program 41.5%

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

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

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

                        \[\leadsto \color{blue}{0} \]
                    5. Recombined 2 regimes into one program.
                    6. Add Preprocessing

                    Alternative 10: 27.5% accurate, 123.0× speedup?

                    \[\begin{array}{l} \\ -1 \end{array} \]
                    (FPCore (x y) :precision binary64 -1.0)
                    double code(double x, double y) {
                    	return -1.0;
                    }
                    
                    real(8) function code(x, y)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        code = -1.0d0
                    end function
                    
                    public static double code(double x, double y) {
                    	return -1.0;
                    }
                    
                    def code(x, y):
                    	return -1.0
                    
                    function code(x, y)
                    	return -1.0
                    end
                    
                    function tmp = code(x, y)
                    	tmp = -1.0;
                    end
                    
                    code[x_, y_] := -1.0
                    
                    \begin{array}{l}
                    
                    \\
                    -1
                    \end{array}
                    
                    Derivation
                    1. Initial program 51.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.f6427.8

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

                      \[\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 \color{blue}{-1} \]
                    7. Step-by-step derivation
                      1. Simplified25.5%

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

                      Reproduce

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