Quotient of sum of exps

Percentage Accurate: 99.0% → 99.0%
Time: 6.6s
Alternatives: 14
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{e^{a}}{e^{a} + e^{b}} \end{array} \]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
	return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b):
	return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b)
	return Float64(exp(a) / Float64(exp(a) + exp(b)))
end
function tmp = code(a, b)
	tmp = exp(a) / (exp(a) + exp(b));
end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e^{a}}{e^{a} + e^{b}}
\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 14 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: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{e^{a}}{e^{a} + e^{b}} \end{array} \]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
	return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b):
	return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b)
	return Float64(exp(a) / Float64(exp(a) + exp(b)))
end
function tmp = code(a, b)
	tmp = exp(a) / (exp(a) + exp(b));
end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}

Alternative 1: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{e^{a}}{e^{b} + e^{a}} \end{array} \]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp b) (exp a))))
double code(double a, double b) {
	return exp(a) / (exp(b) + exp(a));
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = exp(a) / (exp(b) + exp(a))
end function
public static double code(double a, double b) {
	return Math.exp(a) / (Math.exp(b) + Math.exp(a));
}
def code(a, b):
	return math.exp(a) / (math.exp(b) + math.exp(a))
function code(a, b)
	return Float64(exp(a) / Float64(exp(b) + exp(a)))
end
function tmp = code(a, b)
	tmp = exp(a) / (exp(b) + exp(a));
end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[b], $MachinePrecision] + N[Exp[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e^{a}}{e^{b} + e^{a}}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{e^{a}}{e^{a} + e^{b}} \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto \frac{e^{a}}{e^{b} + e^{a}} \]
  4. Add Preprocessing

Alternative 2: 98.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{a} \leq 0:\\ \;\;\;\;\frac{e^{a}}{1 + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + e^{b}}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (exp a) 0.0) (/ (exp a) (+ 1.0 1.0)) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
	double tmp;
	if (exp(a) <= 0.0) {
		tmp = exp(a) / (1.0 + 1.0);
	} else {
		tmp = 1.0 / (1.0 + exp(b));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (exp(a) <= 0.0d0) then
        tmp = exp(a) / (1.0d0 + 1.0d0)
    else
        tmp = 1.0d0 / (1.0d0 + exp(b))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if (Math.exp(a) <= 0.0) {
		tmp = Math.exp(a) / (1.0 + 1.0);
	} else {
		tmp = 1.0 / (1.0 + Math.exp(b));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if math.exp(a) <= 0.0:
		tmp = math.exp(a) / (1.0 + 1.0)
	else:
		tmp = 1.0 / (1.0 + math.exp(b))
	return tmp
function code(a, b)
	tmp = 0.0
	if (exp(a) <= 0.0)
		tmp = Float64(exp(a) / Float64(1.0 + 1.0));
	else
		tmp = Float64(1.0 / Float64(1.0 + exp(b)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (exp(a) <= 0.0)
		tmp = exp(a) / (1.0 + 1.0);
	else
		tmp = 1.0 / (1.0 + exp(b));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{e^{a}}{1 + 1}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\


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

    1. Initial program 100.0%

      \[\frac{e^{a}}{e^{a} + e^{b}} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

      \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
    4. Step-by-step derivation
      1. Applied rewrites100.0%

        \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
      2. Taylor expanded in a around 0

        \[\leadsto \frac{e^{a}}{\color{blue}{1} + 1} \]
      3. Step-by-step derivation
        1. Applied rewrites100.0%

          \[\leadsto \frac{e^{a}}{\color{blue}{1} + 1} \]

        if 0.0 < (exp.f64 a)

        1. Initial program 100.0%

          \[\frac{e^{a}}{e^{a} + e^{b}} \]
        2. Add Preprocessing
        3. Taylor expanded in a around 0

          \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
        4. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
          2. +-commutativeN/A

            \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
          3. lower-+.f64N/A

            \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
          4. lower-exp.f6499.6

            \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
        5. Applied rewrites99.6%

          \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
      4. Recombined 2 regimes into one program.
      5. Final simplification99.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;e^{a} \leq 0:\\ \;\;\;\;\frac{e^{a}}{1 + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + e^{b}}\\ \end{array} \]
      6. Add Preprocessing

      Alternative 3: 93.6% accurate, 2.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(0.5, a, 1\right) \cdot a\\ \mathbf{if}\;a \leq -5 \cdot 10^{+155}:\\ \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\ \mathbf{elif}\;a \leq -7.6 \cdot 10^{+62}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(t\_0, t\_0, -1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, -1\right)} + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + e^{b}}\\ \end{array} \end{array} \]
      (FPCore (a b)
       :precision binary64
       (let* ((t_0 (* (fma 0.5 a 1.0) a)))
         (if (<= a -5e+155)
           (/ 1.0 (+ (* (* a a) 0.5) 1.0))
           (if (<= a -7.6e+62)
             (/ 1.0 (+ (/ (fma t_0 t_0 -1.0) (fma (fma 0.5 a 1.0) a -1.0)) 1.0))
             (/ 1.0 (+ 1.0 (exp b)))))))
      double code(double a, double b) {
      	double t_0 = fma(0.5, a, 1.0) * a;
      	double tmp;
      	if (a <= -5e+155) {
      		tmp = 1.0 / (((a * a) * 0.5) + 1.0);
      	} else if (a <= -7.6e+62) {
      		tmp = 1.0 / ((fma(t_0, t_0, -1.0) / fma(fma(0.5, a, 1.0), a, -1.0)) + 1.0);
      	} else {
      		tmp = 1.0 / (1.0 + exp(b));
      	}
      	return tmp;
      }
      
      function code(a, b)
      	t_0 = Float64(fma(0.5, a, 1.0) * a)
      	tmp = 0.0
      	if (a <= -5e+155)
      		tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0));
      	elseif (a <= -7.6e+62)
      		tmp = Float64(1.0 / Float64(Float64(fma(t_0, t_0, -1.0) / fma(fma(0.5, a, 1.0), a, -1.0)) + 1.0));
      	else
      		tmp = Float64(1.0 / Float64(1.0 + exp(b)));
      	end
      	return tmp
      end
      
      code[a_, b_] := Block[{t$95$0 = N[(N[(0.5 * a + 1.0), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[a, -5e+155], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -7.6e+62], N[(1.0 / N[(N[(N[(t$95$0 * t$95$0 + -1.0), $MachinePrecision] / N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \mathsf{fma}\left(0.5, a, 1\right) \cdot a\\
      \mathbf{if}\;a \leq -5 \cdot 10^{+155}:\\
      \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
      
      \mathbf{elif}\;a \leq -7.6 \cdot 10^{+62}:\\
      \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(t\_0, t\_0, -1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, -1\right)} + 1}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{1}{1 + e^{b}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if a < -4.9999999999999999e155

        1. Initial program 100.0%

          \[\frac{e^{a}}{e^{a} + e^{b}} \]
        2. Add Preprocessing
        3. Taylor expanded in b around 0

          \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
        4. Step-by-step derivation
          1. Applied rewrites100.0%

            \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
          2. Taylor expanded in a around 0

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

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

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

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

              \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
            5. lower-fma.f64100.0

              \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
          4. Applied rewrites100.0%

            \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
          5. Taylor expanded in a around 0

            \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
          6. Step-by-step derivation
            1. Applied rewrites100.0%

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

              \[\leadsto \frac{1}{\frac{1}{2} \cdot \color{blue}{{a}^{2}} + 1} \]
            3. Step-by-step derivation
              1. Applied rewrites100.0%

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

              if -4.9999999999999999e155 < a < -7.59999999999999967e62

              1. Initial program 100.0%

                \[\frac{e^{a}}{e^{a} + e^{b}} \]
              2. Add Preprocessing
              3. Taylor expanded in b around 0

                \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
              4. Step-by-step derivation
                1. Applied rewrites100.0%

                  \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                2. Taylor expanded in a around 0

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

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

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

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

                    \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                  5. lower-fma.f64100.0

                    \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                4. Applied rewrites100.0%

                  \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                5. Taylor expanded in a around 0

                  \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                6. Step-by-step derivation
                  1. Applied rewrites6.5%

                    \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1} \]
                  2. Step-by-step derivation
                    1. Applied rewrites95.7%

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

                    if -7.59999999999999967e62 < a

                    1. Initial program 100.0%

                      \[\frac{e^{a}}{e^{a} + e^{b}} \]
                    2. Add Preprocessing
                    3. Taylor expanded in a around 0

                      \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                    4. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                      2. +-commutativeN/A

                        \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                      3. lower-+.f64N/A

                        \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                      4. lower-exp.f6497.2

                        \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                    5. Applied rewrites97.2%

                      \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                  3. Recombined 3 regimes into one program.
                  4. Final simplification97.5%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -5 \cdot 10^{+155}:\\ \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\ \mathbf{elif}\;a \leq -7.6 \cdot 10^{+62}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right) \cdot a, \mathsf{fma}\left(0.5, a, 1\right) \cdot a, -1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, -1\right)} + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + e^{b}}\\ \end{array} \]
                  5. Add Preprocessing

                  Alternative 4: 88.6% accurate, 5.0× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(b \cdot b\right) \cdot b\\ \mathbf{if}\;b \leq -6.6:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)}{\mathsf{fma}\left(0.5, a, 1\right) \cdot a + 1}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+51}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{64 - t\_0 \cdot t\_0}{32}}\\ \end{array} \end{array} \]
                  (FPCore (a b)
                   :precision binary64
                   (let* ((t_0 (* (* b b) b)))
                     (if (<= b -6.6)
                       (/ (fma (fma 0.5 a 1.0) a 1.0) (+ (* (fma 0.5 a 1.0) a) 1.0))
                       (if (<= b 2.3e+51)
                         (/ 1.0 (+ (fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 1.0) 1.0))
                         (/ 1.0 (/ (- 64.0 (* t_0 t_0)) 32.0))))))
                  double code(double a, double b) {
                  	double t_0 = (b * b) * b;
                  	double tmp;
                  	if (b <= -6.6) {
                  		tmp = fma(fma(0.5, a, 1.0), a, 1.0) / ((fma(0.5, a, 1.0) * a) + 1.0);
                  	} else if (b <= 2.3e+51) {
                  		tmp = 1.0 / (fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0);
                  	} else {
                  		tmp = 1.0 / ((64.0 - (t_0 * t_0)) / 32.0);
                  	}
                  	return tmp;
                  }
                  
                  function code(a, b)
                  	t_0 = Float64(Float64(b * b) * b)
                  	tmp = 0.0
                  	if (b <= -6.6)
                  		tmp = Float64(fma(fma(0.5, a, 1.0), a, 1.0) / Float64(Float64(fma(0.5, a, 1.0) * a) + 1.0));
                  	elseif (b <= 2.3e+51)
                  		tmp = Float64(1.0 / Float64(fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0));
                  	else
                  		tmp = Float64(1.0 / Float64(Float64(64.0 - Float64(t_0 * t_0)) / 32.0));
                  	end
                  	return tmp
                  end
                  
                  code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -6.6], N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e+51], N[(1.0 / N[(N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(64.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / 32.0), $MachinePrecision]), $MachinePrecision]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \left(b \cdot b\right) \cdot b\\
                  \mathbf{if}\;b \leq -6.6:\\
                  \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)}{\mathsf{fma}\left(0.5, a, 1\right) \cdot a + 1}\\
                  
                  \mathbf{elif}\;b \leq 2.3 \cdot 10^{+51}:\\
                  \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{1}{\frac{64 - t\_0 \cdot t\_0}{32}}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if b < -6.5999999999999996

                    1. Initial program 100.0%

                      \[\frac{e^{a}}{e^{a} + e^{b}} \]
                    2. Add Preprocessing
                    3. Taylor expanded in b around 0

                      \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                    4. Step-by-step derivation
                      1. Applied rewrites18.8%

                        \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                      2. Taylor expanded in a around 0

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

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

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

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

                          \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                        5. lower-fma.f6418.8

                          \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                      4. Applied rewrites18.8%

                        \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                      5. Taylor expanded in a around 0

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

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

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

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

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

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

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

                        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right)}{{a}^{2} \cdot \color{blue}{\left(\frac{1}{2} + \frac{1}{a}\right)} + 1} \]
                      9. Step-by-step derivation
                        1. Applied rewrites100.0%

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

                        if -6.5999999999999996 < b < 2.30000000000000005e51

                        1. Initial program 100.0%

                          \[\frac{e^{a}}{e^{a} + e^{b}} \]
                        2. Add Preprocessing
                        3. Taylor expanded in b around 0

                          \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                        4. Step-by-step derivation
                          1. Applied rewrites93.2%

                            \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                          2. Taylor expanded in a around 0

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

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

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

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

                              \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                            5. lower-fma.f6493.2

                              \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                          4. Applied rewrites93.2%

                            \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                          5. Taylor expanded in a around 0

                            \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                          6. Step-by-step derivation
                            1. Applied rewrites77.0%

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

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

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

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

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

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

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

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

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

                                \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.16666666666666666, a, 0.5\right)}, a, 1\right), a, 1\right) + 1} \]
                            4. Applied rewrites83.6%

                              \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right)} + 1} \]

                            if 2.30000000000000005e51 < b

                            1. Initial program 100.0%

                              \[\frac{e^{a}}{e^{a} + e^{b}} \]
                            2. Add Preprocessing
                            3. Taylor expanded in a around 0

                              \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                            4. Step-by-step derivation
                              1. lower-/.f64N/A

                                \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                              2. +-commutativeN/A

                                \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                              3. lower-+.f64N/A

                                \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                              4. lower-exp.f64100.0

                                \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                            5. Applied rewrites100.0%

                              \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                            6. Taylor expanded in b around 0

                              \[\leadsto \frac{1}{2 + \color{blue}{b}} \]
                            7. Step-by-step derivation
                              1. Applied rewrites5.9%

                                \[\leadsto \frac{1}{2 + \color{blue}{b}} \]
                              2. Step-by-step derivation
                                1. Applied rewrites4.8%

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

                                  \[\leadsto \frac{1}{\frac{\left(64 - \left(\left(b \cdot b\right) \cdot b\right) \cdot \left(\left(b \cdot b\right) \cdot b\right)\right) \cdot 1}{32}} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites100.0%

                                    \[\leadsto \frac{1}{\frac{\left(64 - \left(\left(b \cdot b\right) \cdot b\right) \cdot \left(\left(b \cdot b\right) \cdot b\right)\right) \cdot 1}{32}} \]
                                4. Recombined 3 regimes into one program.
                                5. Final simplification90.7%

                                  \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.6:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)}{\mathsf{fma}\left(0.5, a, 1\right) \cdot a + 1}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+51}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{64 - \left(\left(b \cdot b\right) \cdot b\right) \cdot \left(\left(b \cdot b\right) \cdot b\right)}{32}}\\ \end{array} \]
                                6. Add Preprocessing

                                Alternative 5: 85.2% accurate, 5.7× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)\\ \mathbf{if}\;b \leq -6.6:\\ \;\;\;\;\frac{t\_0}{\mathsf{fma}\left(0.5, a, 1\right) \cdot a + 1}\\ \mathbf{elif}\;b \leq 20000:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\ \mathbf{elif}\;b \leq 3.1 \cdot 10^{+82}:\\ \;\;\;\;\frac{\left(a \cdot a\right) \cdot 0.5}{t\_0 + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\ \end{array} \end{array} \]
                                (FPCore (a b)
                                 :precision binary64
                                 (let* ((t_0 (fma (fma 0.5 a 1.0) a 1.0)))
                                   (if (<= b -6.6)
                                     (/ t_0 (+ (* (fma 0.5 a 1.0) a) 1.0))
                                     (if (<= b 20000.0)
                                       (/ 1.0 (+ (fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 1.0) 1.0))
                                       (if (<= b 3.1e+82)
                                         (/ (* (* a a) 0.5) (+ t_0 1.0))
                                         (/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0)))))))
                                double code(double a, double b) {
                                	double t_0 = fma(fma(0.5, a, 1.0), a, 1.0);
                                	double tmp;
                                	if (b <= -6.6) {
                                		tmp = t_0 / ((fma(0.5, a, 1.0) * a) + 1.0);
                                	} else if (b <= 20000.0) {
                                		tmp = 1.0 / (fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0);
                                	} else if (b <= 3.1e+82) {
                                		tmp = ((a * a) * 0.5) / (t_0 + 1.0);
                                	} else {
                                		tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
                                	}
                                	return tmp;
                                }
                                
                                function code(a, b)
                                	t_0 = fma(fma(0.5, a, 1.0), a, 1.0)
                                	tmp = 0.0
                                	if (b <= -6.6)
                                		tmp = Float64(t_0 / Float64(Float64(fma(0.5, a, 1.0) * a) + 1.0));
                                	elseif (b <= 20000.0)
                                		tmp = Float64(1.0 / Float64(fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0));
                                	elseif (b <= 3.1e+82)
                                		tmp = Float64(Float64(Float64(a * a) * 0.5) / Float64(t_0 + 1.0));
                                	else
                                		tmp = Float64(1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0));
                                	end
                                	return tmp
                                end
                                
                                code[a_, b_] := Block[{t$95$0 = N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision]}, If[LessEqual[b, -6.6], N[(t$95$0 / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 20000.0], N[(1.0 / N[(N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.1e+82], N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]]]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)\\
                                \mathbf{if}\;b \leq -6.6:\\
                                \;\;\;\;\frac{t\_0}{\mathsf{fma}\left(0.5, a, 1\right) \cdot a + 1}\\
                                
                                \mathbf{elif}\;b \leq 20000:\\
                                \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\
                                
                                \mathbf{elif}\;b \leq 3.1 \cdot 10^{+82}:\\
                                \;\;\;\;\frac{\left(a \cdot a\right) \cdot 0.5}{t\_0 + 1}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 4 regimes
                                2. if b < -6.5999999999999996

                                  1. Initial program 100.0%

                                    \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in b around 0

                                    \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites18.8%

                                      \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                    2. Taylor expanded in a around 0

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

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

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

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

                                        \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                      5. lower-fma.f6418.8

                                        \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                    4. Applied rewrites18.8%

                                      \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                    5. Taylor expanded in a around 0

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

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

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

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

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

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

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

                                      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right)}{{a}^{2} \cdot \color{blue}{\left(\frac{1}{2} + \frac{1}{a}\right)} + 1} \]
                                    9. Step-by-step derivation
                                      1. Applied rewrites100.0%

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

                                      if -6.5999999999999996 < b < 2e4

                                      1. Initial program 100.0%

                                        \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in b around 0

                                        \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites99.1%

                                          \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                        2. Taylor expanded in a around 0

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

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

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

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

                                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                          5. lower-fma.f6499.1

                                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                        4. Applied rewrites99.1%

                                          \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                        5. Taylor expanded in a around 0

                                          \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites83.5%

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.16666666666666666, a, 0.5\right)}, a, 1\right), a, 1\right) + 1} \]
                                          4. Applied rewrites90.0%

                                            \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right)} + 1} \]

                                          if 2e4 < b < 3.10000000000000032e82

                                          1. Initial program 100.0%

                                            \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in b around 0

                                            \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                          4. Step-by-step derivation
                                            1. Applied rewrites29.5%

                                              \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                            2. Taylor expanded in a around 0

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

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

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

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

                                                \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                              5. lower-fma.f6429.5

                                                \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                            4. Applied rewrites29.5%

                                              \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                            5. Taylor expanded in a around 0

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

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

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

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

                                                \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                              5. lower-fma.f643.0

                                                \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1} \]
                                            7. Applied rewrites3.0%

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

                                              \[\leadsto \frac{\frac{1}{2} \cdot \color{blue}{{a}^{2}}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                            9. Step-by-step derivation
                                              1. Applied rewrites38.7%

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

                                              if 3.10000000000000032e82 < b

                                              1. Initial program 100.0%

                                                \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in a around 0

                                                \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                              4. Step-by-step derivation
                                                1. lower-/.f64N/A

                                                  \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                2. +-commutativeN/A

                                                  \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                3. lower-+.f64N/A

                                                  \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                4. lower-exp.f64100.0

                                                  \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                              5. Applied rewrites100.0%

                                                \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                              6. Taylor expanded in b around 0

                                                \[\leadsto \frac{1}{2 + \color{blue}{b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}} \]
                                              7. Step-by-step derivation
                                                1. Applied rewrites91.4%

                                                  \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), \color{blue}{b}, 2\right)} \]
                                              8. Recombined 4 regimes into one program.
                                              9. Add Preprocessing

                                              Alternative 6: 84.8% accurate, 5.7× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(a \cdot a\right) \cdot 0.5\\ \mathbf{if}\;b \leq -2.9:\\ \;\;\;\;\frac{1}{t\_0 + 1}\\ \mathbf{elif}\;b \leq 20000:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\ \mathbf{elif}\;b \leq 3.1 \cdot 10^{+82}:\\ \;\;\;\;\frac{t\_0}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\ \end{array} \end{array} \]
                                              (FPCore (a b)
                                               :precision binary64
                                               (let* ((t_0 (* (* a a) 0.5)))
                                                 (if (<= b -2.9)
                                                   (/ 1.0 (+ t_0 1.0))
                                                   (if (<= b 20000.0)
                                                     (/ 1.0 (+ (fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 1.0) 1.0))
                                                     (if (<= b 3.1e+82)
                                                       (/ t_0 (+ (fma (fma 0.5 a 1.0) a 1.0) 1.0))
                                                       (/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0)))))))
                                              double code(double a, double b) {
                                              	double t_0 = (a * a) * 0.5;
                                              	double tmp;
                                              	if (b <= -2.9) {
                                              		tmp = 1.0 / (t_0 + 1.0);
                                              	} else if (b <= 20000.0) {
                                              		tmp = 1.0 / (fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0);
                                              	} else if (b <= 3.1e+82) {
                                              		tmp = t_0 / (fma(fma(0.5, a, 1.0), a, 1.0) + 1.0);
                                              	} else {
                                              		tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(a, b)
                                              	t_0 = Float64(Float64(a * a) * 0.5)
                                              	tmp = 0.0
                                              	if (b <= -2.9)
                                              		tmp = Float64(1.0 / Float64(t_0 + 1.0));
                                              	elseif (b <= 20000.0)
                                              		tmp = Float64(1.0 / Float64(fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0));
                                              	elseif (b <= 3.1e+82)
                                              		tmp = Float64(t_0 / Float64(fma(fma(0.5, a, 1.0), a, 1.0) + 1.0));
                                              	else
                                              		tmp = Float64(1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0));
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[a_, b_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[b, -2.9], N[(1.0 / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 20000.0], N[(1.0 / N[(N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.1e+82], N[(t$95$0 / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]]]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              t_0 := \left(a \cdot a\right) \cdot 0.5\\
                                              \mathbf{if}\;b \leq -2.9:\\
                                              \;\;\;\;\frac{1}{t\_0 + 1}\\
                                              
                                              \mathbf{elif}\;b \leq 20000:\\
                                              \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\
                                              
                                              \mathbf{elif}\;b \leq 3.1 \cdot 10^{+82}:\\
                                              \;\;\;\;\frac{t\_0}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1}\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 4 regimes
                                              2. if b < -2.89999999999999991

                                                1. Initial program 100.0%

                                                  \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in b around 0

                                                  \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                4. Step-by-step derivation
                                                  1. Applied rewrites18.8%

                                                    \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                  2. Taylor expanded in a around 0

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

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

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

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

                                                      \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                    5. lower-fma.f6418.8

                                                      \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                  4. Applied rewrites18.8%

                                                    \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                  5. Taylor expanded in a around 0

                                                    \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                  6. Step-by-step derivation
                                                    1. Applied rewrites18.7%

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

                                                      \[\leadsto \frac{1}{\frac{1}{2} \cdot \color{blue}{{a}^{2}} + 1} \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites98.6%

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

                                                      if -2.89999999999999991 < b < 2e4

                                                      1. Initial program 100.0%

                                                        \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                      2. Add Preprocessing
                                                      3. Taylor expanded in b around 0

                                                        \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                      4. Step-by-step derivation
                                                        1. Applied rewrites99.1%

                                                          \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                        2. Taylor expanded in a around 0

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

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

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

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

                                                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                          5. lower-fma.f6499.1

                                                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                        4. Applied rewrites99.1%

                                                          \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                        5. Taylor expanded in a around 0

                                                          \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                        6. Step-by-step derivation
                                                          1. Applied rewrites83.5%

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.16666666666666666, a, 0.5\right)}, a, 1\right), a, 1\right) + 1} \]
                                                          4. Applied rewrites90.0%

                                                            \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right)} + 1} \]

                                                          if 2e4 < b < 3.10000000000000032e82

                                                          1. Initial program 100.0%

                                                            \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                          2. Add Preprocessing
                                                          3. Taylor expanded in b around 0

                                                            \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                          4. Step-by-step derivation
                                                            1. Applied rewrites29.5%

                                                              \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                            2. Taylor expanded in a around 0

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

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

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

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

                                                                \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                              5. lower-fma.f6429.5

                                                                \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                            4. Applied rewrites29.5%

                                                              \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                            5. Taylor expanded in a around 0

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

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

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

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

                                                                \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                              5. lower-fma.f643.0

                                                                \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1} \]
                                                            7. Applied rewrites3.0%

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

                                                              \[\leadsto \frac{\frac{1}{2} \cdot \color{blue}{{a}^{2}}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                            9. Step-by-step derivation
                                                              1. Applied rewrites38.7%

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

                                                              if 3.10000000000000032e82 < b

                                                              1. Initial program 100.0%

                                                                \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                              2. Add Preprocessing
                                                              3. Taylor expanded in a around 0

                                                                \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                              4. Step-by-step derivation
                                                                1. lower-/.f64N/A

                                                                  \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                2. +-commutativeN/A

                                                                  \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                3. lower-+.f64N/A

                                                                  \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                4. lower-exp.f64100.0

                                                                  \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                                              5. Applied rewrites100.0%

                                                                \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                                              6. Taylor expanded in b around 0

                                                                \[\leadsto \frac{1}{2 + \color{blue}{b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}} \]
                                                              7. Step-by-step derivation
                                                                1. Applied rewrites91.4%

                                                                  \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), \color{blue}{b}, 2\right)} \]
                                                              8. Recombined 4 regimes into one program.
                                                              9. Add Preprocessing

                                                              Alternative 7: 84.3% accurate, 7.0× speedup?

                                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.9:\\ \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\ \end{array} \end{array} \]
                                                              (FPCore (a b)
                                                               :precision binary64
                                                               (if (<= b -2.9)
                                                                 (/ 1.0 (+ (* (* a a) 0.5) 1.0))
                                                                 (if (<= b 8e+84)
                                                                   (/ 1.0 (+ (fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 1.0) 1.0))
                                                                   (/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0)))))
                                                              double code(double a, double b) {
                                                              	double tmp;
                                                              	if (b <= -2.9) {
                                                              		tmp = 1.0 / (((a * a) * 0.5) + 1.0);
                                                              	} else if (b <= 8e+84) {
                                                              		tmp = 1.0 / (fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0);
                                                              	} else {
                                                              		tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
                                                              	}
                                                              	return tmp;
                                                              }
                                                              
                                                              function code(a, b)
                                                              	tmp = 0.0
                                                              	if (b <= -2.9)
                                                              		tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0));
                                                              	elseif (b <= 8e+84)
                                                              		tmp = Float64(1.0 / Float64(fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0));
                                                              	else
                                                              		tmp = Float64(1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0));
                                                              	end
                                                              	return tmp
                                                              end
                                                              
                                                              code[a_, b_] := If[LessEqual[b, -2.9], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e+84], N[(1.0 / N[(N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]]
                                                              
                                                              \begin{array}{l}
                                                              
                                                              \\
                                                              \begin{array}{l}
                                                              \mathbf{if}\;b \leq -2.9:\\
                                                              \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
                                                              
                                                              \mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\
                                                              \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\
                                                              
                                                              \mathbf{else}:\\
                                                              \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\
                                                              
                                                              
                                                              \end{array}
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Split input into 3 regimes
                                                              2. if b < -2.89999999999999991

                                                                1. Initial program 100.0%

                                                                  \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                2. Add Preprocessing
                                                                3. Taylor expanded in b around 0

                                                                  \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                4. Step-by-step derivation
                                                                  1. Applied rewrites18.8%

                                                                    \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                  2. Taylor expanded in a around 0

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

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

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

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

                                                                      \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                    5. lower-fma.f6418.8

                                                                      \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                  4. Applied rewrites18.8%

                                                                    \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                  5. Taylor expanded in a around 0

                                                                    \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                  6. Step-by-step derivation
                                                                    1. Applied rewrites18.7%

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

                                                                      \[\leadsto \frac{1}{\frac{1}{2} \cdot \color{blue}{{a}^{2}} + 1} \]
                                                                    3. Step-by-step derivation
                                                                      1. Applied rewrites98.6%

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

                                                                      if -2.89999999999999991 < b < 8.00000000000000046e84

                                                                      1. Initial program 100.0%

                                                                        \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                      2. Add Preprocessing
                                                                      3. Taylor expanded in b around 0

                                                                        \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                      4. Step-by-step derivation
                                                                        1. Applied rewrites89.3%

                                                                          \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                        2. Taylor expanded in a around 0

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

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

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

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

                                                                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                          5. lower-fma.f6489.3

                                                                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                        4. Applied rewrites89.3%

                                                                          \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                        5. Taylor expanded in a around 0

                                                                          \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                        6. Step-by-step derivation
                                                                          1. Applied rewrites73.0%

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

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

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

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

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

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

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

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

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

                                                                              \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.16666666666666666, a, 0.5\right)}, a, 1\right), a, 1\right) + 1} \]
                                                                          4. Applied rewrites79.1%

                                                                            \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right)} + 1} \]

                                                                          if 8.00000000000000046e84 < b

                                                                          1. Initial program 100.0%

                                                                            \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                          2. Add Preprocessing
                                                                          3. Taylor expanded in a around 0

                                                                            \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                          4. Step-by-step derivation
                                                                            1. lower-/.f64N/A

                                                                              \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                            2. +-commutativeN/A

                                                                              \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                            3. lower-+.f64N/A

                                                                              \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                            4. lower-exp.f64100.0

                                                                              \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                                                          5. Applied rewrites100.0%

                                                                            \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                                                          6. Taylor expanded in b around 0

                                                                            \[\leadsto \frac{1}{2 + \color{blue}{b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}} \]
                                                                          7. Step-by-step derivation
                                                                            1. Applied rewrites94.7%

                                                                              \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), \color{blue}{b}, 2\right)} \]
                                                                          8. Recombined 3 regimes into one program.
                                                                          9. Add Preprocessing

                                                                          Alternative 8: 81.3% accurate, 7.5× speedup?

                                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-8}:\\ \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\ \;\;\;\;\frac{1 + a}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\ \end{array} \end{array} \]
                                                                          (FPCore (a b)
                                                                           :precision binary64
                                                                           (if (<= b -1.6e-8)
                                                                             (/ 1.0 (+ (* (* a a) 0.5) 1.0))
                                                                             (if (<= b 8e+84)
                                                                               (/ (+ 1.0 a) (+ (fma (fma 0.5 a 1.0) a 1.0) 1.0))
                                                                               (/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0)))))
                                                                          double code(double a, double b) {
                                                                          	double tmp;
                                                                          	if (b <= -1.6e-8) {
                                                                          		tmp = 1.0 / (((a * a) * 0.5) + 1.0);
                                                                          	} else if (b <= 8e+84) {
                                                                          		tmp = (1.0 + a) / (fma(fma(0.5, a, 1.0), a, 1.0) + 1.0);
                                                                          	} else {
                                                                          		tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          function code(a, b)
                                                                          	tmp = 0.0
                                                                          	if (b <= -1.6e-8)
                                                                          		tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0));
                                                                          	elseif (b <= 8e+84)
                                                                          		tmp = Float64(Float64(1.0 + a) / Float64(fma(fma(0.5, a, 1.0), a, 1.0) + 1.0));
                                                                          	else
                                                                          		tmp = Float64(1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0));
                                                                          	end
                                                                          	return tmp
                                                                          end
                                                                          
                                                                          code[a_, b_] := If[LessEqual[b, -1.6e-8], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e+84], N[(N[(1.0 + a), $MachinePrecision] / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]]
                                                                          
                                                                          \begin{array}{l}
                                                                          
                                                                          \\
                                                                          \begin{array}{l}
                                                                          \mathbf{if}\;b \leq -1.6 \cdot 10^{-8}:\\
                                                                          \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
                                                                          
                                                                          \mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\
                                                                          \;\;\;\;\frac{1 + a}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1}\\
                                                                          
                                                                          \mathbf{else}:\\
                                                                          \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\
                                                                          
                                                                          
                                                                          \end{array}
                                                                          \end{array}
                                                                          
                                                                          Derivation
                                                                          1. Split input into 3 regimes
                                                                          2. if b < -1.6000000000000001e-8

                                                                            1. Initial program 100.0%

                                                                              \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                            2. Add Preprocessing
                                                                            3. Taylor expanded in b around 0

                                                                              \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                            4. Step-by-step derivation
                                                                              1. Applied rewrites20.4%

                                                                                \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                              2. Taylor expanded in a around 0

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

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

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

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

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

                                                                                  \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                              4. Applied rewrites20.4%

                                                                                \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                              5. Taylor expanded in a around 0

                                                                                \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                              6. Step-by-step derivation
                                                                                1. Applied rewrites18.5%

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

                                                                                  \[\leadsto \frac{1}{\frac{1}{2} \cdot \color{blue}{{a}^{2}} + 1} \]
                                                                                3. Step-by-step derivation
                                                                                  1. Applied rewrites96.7%

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

                                                                                  if -1.6000000000000001e-8 < b < 8.00000000000000046e84

                                                                                  1. Initial program 100.0%

                                                                                    \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                  2. Add Preprocessing
                                                                                  3. Taylor expanded in b around 0

                                                                                    \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                  4. Step-by-step derivation
                                                                                    1. Applied rewrites89.2%

                                                                                      \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                    2. Taylor expanded in a around 0

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

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

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

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

                                                                                        \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                                      5. lower-fma.f6489.2

                                                                                        \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                                    4. Applied rewrites89.2%

                                                                                      \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                                    5. Taylor expanded in a around 0

                                                                                      \[\leadsto \frac{\color{blue}{1 + a}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                                    6. Step-by-step derivation
                                                                                      1. lower-+.f6473.6

                                                                                        \[\leadsto \frac{\color{blue}{1 + a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1} \]
                                                                                    7. Applied rewrites73.6%

                                                                                      \[\leadsto \frac{\color{blue}{1 + a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1} \]

                                                                                    if 8.00000000000000046e84 < b

                                                                                    1. Initial program 100.0%

                                                                                      \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                    2. Add Preprocessing
                                                                                    3. Taylor expanded in a around 0

                                                                                      \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                    4. Step-by-step derivation
                                                                                      1. lower-/.f64N/A

                                                                                        \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                      2. +-commutativeN/A

                                                                                        \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                      3. lower-+.f64N/A

                                                                                        \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                      4. lower-exp.f64100.0

                                                                                        \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                                                                    5. Applied rewrites100.0%

                                                                                      \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                                                                    6. Taylor expanded in b around 0

                                                                                      \[\leadsto \frac{1}{2 + \color{blue}{b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}} \]
                                                                                    7. Step-by-step derivation
                                                                                      1. Applied rewrites94.7%

                                                                                        \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), \color{blue}{b}, 2\right)} \]
                                                                                    8. Recombined 3 regimes into one program.
                                                                                    9. Add Preprocessing

                                                                                    Alternative 9: 81.2% accurate, 7.5× speedup?

                                                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.1:\\ \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(0.5 \cdot a, a, 1\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\ \end{array} \end{array} \]
                                                                                    (FPCore (a b)
                                                                                     :precision binary64
                                                                                     (if (<= b -1.1)
                                                                                       (/ 1.0 (+ (* (* a a) 0.5) 1.0))
                                                                                       (if (<= b 8e+84)
                                                                                         (/ 1.0 (+ (fma (* 0.5 a) a 1.0) 1.0))
                                                                                         (/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0)))))
                                                                                    double code(double a, double b) {
                                                                                    	double tmp;
                                                                                    	if (b <= -1.1) {
                                                                                    		tmp = 1.0 / (((a * a) * 0.5) + 1.0);
                                                                                    	} else if (b <= 8e+84) {
                                                                                    		tmp = 1.0 / (fma((0.5 * a), a, 1.0) + 1.0);
                                                                                    	} else {
                                                                                    		tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
                                                                                    	}
                                                                                    	return tmp;
                                                                                    }
                                                                                    
                                                                                    function code(a, b)
                                                                                    	tmp = 0.0
                                                                                    	if (b <= -1.1)
                                                                                    		tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0));
                                                                                    	elseif (b <= 8e+84)
                                                                                    		tmp = Float64(1.0 / Float64(fma(Float64(0.5 * a), a, 1.0) + 1.0));
                                                                                    	else
                                                                                    		tmp = Float64(1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0));
                                                                                    	end
                                                                                    	return tmp
                                                                                    end
                                                                                    
                                                                                    code[a_, b_] := If[LessEqual[b, -1.1], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e+84], N[(1.0 / N[(N[(N[(0.5 * a), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]]
                                                                                    
                                                                                    \begin{array}{l}
                                                                                    
                                                                                    \\
                                                                                    \begin{array}{l}
                                                                                    \mathbf{if}\;b \leq -1.1:\\
                                                                                    \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
                                                                                    
                                                                                    \mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\
                                                                                    \;\;\;\;\frac{1}{\mathsf{fma}\left(0.5 \cdot a, a, 1\right) + 1}\\
                                                                                    
                                                                                    \mathbf{else}:\\
                                                                                    \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\
                                                                                    
                                                                                    
                                                                                    \end{array}
                                                                                    \end{array}
                                                                                    
                                                                                    Derivation
                                                                                    1. Split input into 3 regimes
                                                                                    2. if b < -1.1000000000000001

                                                                                      1. Initial program 100.0%

                                                                                        \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                      2. Add Preprocessing
                                                                                      3. Taylor expanded in b around 0

                                                                                        \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                      4. Step-by-step derivation
                                                                                        1. Applied rewrites18.8%

                                                                                          \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                        2. Taylor expanded in a around 0

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

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

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

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

                                                                                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                                          5. lower-fma.f6418.8

                                                                                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                                        4. Applied rewrites18.8%

                                                                                          \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                                        5. Taylor expanded in a around 0

                                                                                          \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                                        6. Step-by-step derivation
                                                                                          1. Applied rewrites18.7%

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

                                                                                            \[\leadsto \frac{1}{\frac{1}{2} \cdot \color{blue}{{a}^{2}} + 1} \]
                                                                                          3. Step-by-step derivation
                                                                                            1. Applied rewrites98.6%

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

                                                                                            if -1.1000000000000001 < b < 8.00000000000000046e84

                                                                                            1. Initial program 100.0%

                                                                                              \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                            2. Add Preprocessing
                                                                                            3. Taylor expanded in b around 0

                                                                                              \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                            4. Step-by-step derivation
                                                                                              1. Applied rewrites89.3%

                                                                                                \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                              2. Taylor expanded in a around 0

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

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

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

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

                                                                                                  \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                                                5. lower-fma.f6489.3

                                                                                                  \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                                              4. Applied rewrites89.3%

                                                                                                \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                                              5. Taylor expanded in a around 0

                                                                                                \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                                              6. Step-by-step derivation
                                                                                                1. Applied rewrites73.0%

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

                                                                                                  \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{1}{2} \cdot a, a, 1\right) + 1} \]
                                                                                                3. Step-by-step derivation
                                                                                                  1. Applied rewrites73.1%

                                                                                                    \[\leadsto \frac{1}{\mathsf{fma}\left(0.5 \cdot a, a, 1\right) + 1} \]

                                                                                                  if 8.00000000000000046e84 < b

                                                                                                  1. Initial program 100.0%

                                                                                                    \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                  2. Add Preprocessing
                                                                                                  3. Taylor expanded in a around 0

                                                                                                    \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                  4. Step-by-step derivation
                                                                                                    1. lower-/.f64N/A

                                                                                                      \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                    2. +-commutativeN/A

                                                                                                      \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                    3. lower-+.f64N/A

                                                                                                      \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                    4. lower-exp.f64100.0

                                                                                                      \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                                                                                  5. Applied rewrites100.0%

                                                                                                    \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                                                                                  6. Taylor expanded in b around 0

                                                                                                    \[\leadsto \frac{1}{2 + \color{blue}{b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}} \]
                                                                                                  7. Step-by-step derivation
                                                                                                    1. Applied rewrites94.7%

                                                                                                      \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), \color{blue}{b}, 2\right)} \]
                                                                                                  8. Recombined 3 regimes into one program.
                                                                                                  9. Add Preprocessing

                                                                                                  Alternative 10: 77.1% accurate, 8.3× speedup?

                                                                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.1:\\ \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\ \mathbf{elif}\;b \leq 4.6 \cdot 10^{+117}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(0.5 \cdot a, a, 1\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\ \end{array} \end{array} \]
                                                                                                  (FPCore (a b)
                                                                                                   :precision binary64
                                                                                                   (if (<= b -1.1)
                                                                                                     (/ 1.0 (+ (* (* a a) 0.5) 1.0))
                                                                                                     (if (<= b 4.6e+117)
                                                                                                       (/ 1.0 (+ (fma (* 0.5 a) a 1.0) 1.0))
                                                                                                       (/ 1.0 (fma (fma 0.5 b 1.0) b 2.0)))))
                                                                                                  double code(double a, double b) {
                                                                                                  	double tmp;
                                                                                                  	if (b <= -1.1) {
                                                                                                  		tmp = 1.0 / (((a * a) * 0.5) + 1.0);
                                                                                                  	} else if (b <= 4.6e+117) {
                                                                                                  		tmp = 1.0 / (fma((0.5 * a), a, 1.0) + 1.0);
                                                                                                  	} else {
                                                                                                  		tmp = 1.0 / fma(fma(0.5, b, 1.0), b, 2.0);
                                                                                                  	}
                                                                                                  	return tmp;
                                                                                                  }
                                                                                                  
                                                                                                  function code(a, b)
                                                                                                  	tmp = 0.0
                                                                                                  	if (b <= -1.1)
                                                                                                  		tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0));
                                                                                                  	elseif (b <= 4.6e+117)
                                                                                                  		tmp = Float64(1.0 / Float64(fma(Float64(0.5 * a), a, 1.0) + 1.0));
                                                                                                  	else
                                                                                                  		tmp = Float64(1.0 / fma(fma(0.5, b, 1.0), b, 2.0));
                                                                                                  	end
                                                                                                  	return tmp
                                                                                                  end
                                                                                                  
                                                                                                  code[a_, b_] := If[LessEqual[b, -1.1], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.6e+117], N[(1.0 / N[(N[(N[(0.5 * a), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]]
                                                                                                  
                                                                                                  \begin{array}{l}
                                                                                                  
                                                                                                  \\
                                                                                                  \begin{array}{l}
                                                                                                  \mathbf{if}\;b \leq -1.1:\\
                                                                                                  \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
                                                                                                  
                                                                                                  \mathbf{elif}\;b \leq 4.6 \cdot 10^{+117}:\\
                                                                                                  \;\;\;\;\frac{1}{\mathsf{fma}\left(0.5 \cdot a, a, 1\right) + 1}\\
                                                                                                  
                                                                                                  \mathbf{else}:\\
                                                                                                  \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\
                                                                                                  
                                                                                                  
                                                                                                  \end{array}
                                                                                                  \end{array}
                                                                                                  
                                                                                                  Derivation
                                                                                                  1. Split input into 3 regimes
                                                                                                  2. if b < -1.1000000000000001

                                                                                                    1. Initial program 100.0%

                                                                                                      \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                    2. Add Preprocessing
                                                                                                    3. Taylor expanded in b around 0

                                                                                                      \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                    4. Step-by-step derivation
                                                                                                      1. Applied rewrites18.8%

                                                                                                        \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                      2. Taylor expanded in a around 0

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

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

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

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

                                                                                                          \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                                                        5. lower-fma.f6418.8

                                                                                                          \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                                                      4. Applied rewrites18.8%

                                                                                                        \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                                                      5. Taylor expanded in a around 0

                                                                                                        \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                                                      6. Step-by-step derivation
                                                                                                        1. Applied rewrites18.7%

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

                                                                                                          \[\leadsto \frac{1}{\frac{1}{2} \cdot \color{blue}{{a}^{2}} + 1} \]
                                                                                                        3. Step-by-step derivation
                                                                                                          1. Applied rewrites98.6%

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

                                                                                                          if -1.1000000000000001 < b < 4.59999999999999976e117

                                                                                                          1. Initial program 100.0%

                                                                                                            \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                          2. Add Preprocessing
                                                                                                          3. Taylor expanded in b around 0

                                                                                                            \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                          4. Step-by-step derivation
                                                                                                            1. Applied rewrites86.9%

                                                                                                              \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                            2. Taylor expanded in a around 0

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

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

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

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

                                                                                                                \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                                                              5. lower-fma.f6486.9

                                                                                                                \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                                                            4. Applied rewrites86.9%

                                                                                                              \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                                                            5. Taylor expanded in a around 0

                                                                                                              \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                                                            6. Step-by-step derivation
                                                                                                              1. Applied rewrites70.2%

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

                                                                                                                \[\leadsto \frac{1}{\mathsf{fma}\left(\frac{1}{2} \cdot a, a, 1\right) + 1} \]
                                                                                                              3. Step-by-step derivation
                                                                                                                1. Applied rewrites70.3%

                                                                                                                  \[\leadsto \frac{1}{\mathsf{fma}\left(0.5 \cdot a, a, 1\right) + 1} \]

                                                                                                                if 4.59999999999999976e117 < b

                                                                                                                1. Initial program 100.0%

                                                                                                                  \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                                2. Add Preprocessing
                                                                                                                3. Taylor expanded in a around 0

                                                                                                                  \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                4. Step-by-step derivation
                                                                                                                  1. lower-/.f64N/A

                                                                                                                    \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                  2. +-commutativeN/A

                                                                                                                    \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                                  3. lower-+.f64N/A

                                                                                                                    \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                                  4. lower-exp.f64100.0

                                                                                                                    \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                                                                                                5. Applied rewrites100.0%

                                                                                                                  \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                                                                                                6. Taylor expanded in b around 0

                                                                                                                  \[\leadsto \frac{1}{2 + \color{blue}{b \cdot \left(1 + \frac{1}{2} \cdot b\right)}} \]
                                                                                                                7. Step-by-step derivation
                                                                                                                  1. Applied rewrites91.8%

                                                                                                                    \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), \color{blue}{b}, 2\right)} \]
                                                                                                                8. Recombined 3 regimes into one program.
                                                                                                                9. Add Preprocessing

                                                                                                                Alternative 11: 65.1% accurate, 10.2× speedup?

                                                                                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.5 \cdot 10^{-79}:\\ \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\ \end{array} \end{array} \]
                                                                                                                (FPCore (a b)
                                                                                                                 :precision binary64
                                                                                                                 (if (<= b -2.5e-79)
                                                                                                                   (/ 1.0 (+ (* (* a a) 0.5) 1.0))
                                                                                                                   (/ 1.0 (fma (fma 0.5 b 1.0) b 2.0))))
                                                                                                                double code(double a, double b) {
                                                                                                                	double tmp;
                                                                                                                	if (b <= -2.5e-79) {
                                                                                                                		tmp = 1.0 / (((a * a) * 0.5) + 1.0);
                                                                                                                	} else {
                                                                                                                		tmp = 1.0 / fma(fma(0.5, b, 1.0), b, 2.0);
                                                                                                                	}
                                                                                                                	return tmp;
                                                                                                                }
                                                                                                                
                                                                                                                function code(a, b)
                                                                                                                	tmp = 0.0
                                                                                                                	if (b <= -2.5e-79)
                                                                                                                		tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0));
                                                                                                                	else
                                                                                                                		tmp = Float64(1.0 / fma(fma(0.5, b, 1.0), b, 2.0));
                                                                                                                	end
                                                                                                                	return tmp
                                                                                                                end
                                                                                                                
                                                                                                                code[a_, b_] := If[LessEqual[b, -2.5e-79], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]
                                                                                                                
                                                                                                                \begin{array}{l}
                                                                                                                
                                                                                                                \\
                                                                                                                \begin{array}{l}
                                                                                                                \mathbf{if}\;b \leq -2.5 \cdot 10^{-79}:\\
                                                                                                                \;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
                                                                                                                
                                                                                                                \mathbf{else}:\\
                                                                                                                \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\
                                                                                                                
                                                                                                                
                                                                                                                \end{array}
                                                                                                                \end{array}
                                                                                                                
                                                                                                                Derivation
                                                                                                                1. Split input into 2 regimes
                                                                                                                2. if b < -2.5e-79

                                                                                                                  1. Initial program 100.0%

                                                                                                                    \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                                  2. Add Preprocessing
                                                                                                                  3. Taylor expanded in b around 0

                                                                                                                    \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                                  4. Step-by-step derivation
                                                                                                                    1. Applied rewrites39.3%

                                                                                                                      \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                                    2. Taylor expanded in a around 0

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

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

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

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

                                                                                                                        \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                                                                      5. lower-fma.f6439.3

                                                                                                                        \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                                                                    4. Applied rewrites39.3%

                                                                                                                      \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                                                                    5. Taylor expanded in a around 0

                                                                                                                      \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                                                                    6. Step-by-step derivation
                                                                                                                      1. Applied rewrites32.8%

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

                                                                                                                        \[\leadsto \frac{1}{\frac{1}{2} \cdot \color{blue}{{a}^{2}} + 1} \]
                                                                                                                      3. Step-by-step derivation
                                                                                                                        1. Applied rewrites85.7%

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

                                                                                                                        if -2.5e-79 < b

                                                                                                                        1. Initial program 100.0%

                                                                                                                          \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                                        2. Add Preprocessing
                                                                                                                        3. Taylor expanded in a around 0

                                                                                                                          \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                        4. Step-by-step derivation
                                                                                                                          1. lower-/.f64N/A

                                                                                                                            \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                          2. +-commutativeN/A

                                                                                                                            \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                                          3. lower-+.f64N/A

                                                                                                                            \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                                          4. lower-exp.f6481.1

                                                                                                                            \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                                                                                                        5. Applied rewrites81.1%

                                                                                                                          \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                                                                                                        6. Taylor expanded in b around 0

                                                                                                                          \[\leadsto \frac{1}{2 + \color{blue}{b \cdot \left(1 + \frac{1}{2} \cdot b\right)}} \]
                                                                                                                        7. Step-by-step derivation
                                                                                                                          1. Applied rewrites62.5%

                                                                                                                            \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), \color{blue}{b}, 2\right)} \]
                                                                                                                        8. Recombined 2 regimes into one program.
                                                                                                                        9. Add Preprocessing

                                                                                                                        Alternative 12: 52.9% accurate, 10.5× speedup?

                                                                                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.25 \cdot 10^{-10}:\\ \;\;\;\;\frac{1}{\left(1 + a\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\ \end{array} \end{array} \]
                                                                                                                        (FPCore (a b)
                                                                                                                         :precision binary64
                                                                                                                         (if (<= b 1.25e-10)
                                                                                                                           (/ 1.0 (+ (+ 1.0 a) 1.0))
                                                                                                                           (/ 1.0 (fma (fma 0.5 b 1.0) b 2.0))))
                                                                                                                        double code(double a, double b) {
                                                                                                                        	double tmp;
                                                                                                                        	if (b <= 1.25e-10) {
                                                                                                                        		tmp = 1.0 / ((1.0 + a) + 1.0);
                                                                                                                        	} else {
                                                                                                                        		tmp = 1.0 / fma(fma(0.5, b, 1.0), b, 2.0);
                                                                                                                        	}
                                                                                                                        	return tmp;
                                                                                                                        }
                                                                                                                        
                                                                                                                        function code(a, b)
                                                                                                                        	tmp = 0.0
                                                                                                                        	if (b <= 1.25e-10)
                                                                                                                        		tmp = Float64(1.0 / Float64(Float64(1.0 + a) + 1.0));
                                                                                                                        	else
                                                                                                                        		tmp = Float64(1.0 / fma(fma(0.5, b, 1.0), b, 2.0));
                                                                                                                        	end
                                                                                                                        	return tmp
                                                                                                                        end
                                                                                                                        
                                                                                                                        code[a_, b_] := If[LessEqual[b, 1.25e-10], N[(1.0 / N[(N[(1.0 + a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]
                                                                                                                        
                                                                                                                        \begin{array}{l}
                                                                                                                        
                                                                                                                        \\
                                                                                                                        \begin{array}{l}
                                                                                                                        \mathbf{if}\;b \leq 1.25 \cdot 10^{-10}:\\
                                                                                                                        \;\;\;\;\frac{1}{\left(1 + a\right) + 1}\\
                                                                                                                        
                                                                                                                        \mathbf{else}:\\
                                                                                                                        \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\
                                                                                                                        
                                                                                                                        
                                                                                                                        \end{array}
                                                                                                                        \end{array}
                                                                                                                        
                                                                                                                        Derivation
                                                                                                                        1. Split input into 2 regimes
                                                                                                                        2. if b < 1.25000000000000008e-10

                                                                                                                          1. Initial program 100.0%

                                                                                                                            \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                                          2. Add Preprocessing
                                                                                                                          3. Taylor expanded in b around 0

                                                                                                                            \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                                          4. Step-by-step derivation
                                                                                                                            1. Applied rewrites77.7%

                                                                                                                              \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                                            2. Taylor expanded in a around 0

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

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

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

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

                                                                                                                                \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                                                                              5. lower-fma.f6477.7

                                                                                                                                \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                                                                            4. Applied rewrites77.7%

                                                                                                                              \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                                                                            5. Taylor expanded in a around 0

                                                                                                                              \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                                                                            6. Step-by-step derivation
                                                                                                                              1. Applied rewrites67.1%

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

                                                                                                                                \[\leadsto \frac{1}{\color{blue}{\left(1 + a\right)} + 1} \]
                                                                                                                              3. Step-by-step derivation
                                                                                                                                1. lower-+.f6452.3

                                                                                                                                  \[\leadsto \frac{1}{\color{blue}{\left(1 + a\right)} + 1} \]
                                                                                                                              4. Applied rewrites52.3%

                                                                                                                                \[\leadsto \frac{1}{\color{blue}{\left(1 + a\right)} + 1} \]

                                                                                                                              if 1.25000000000000008e-10 < b

                                                                                                                              1. Initial program 100.0%

                                                                                                                                \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                                              2. Add Preprocessing
                                                                                                                              3. Taylor expanded in a around 0

                                                                                                                                \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                              4. Step-by-step derivation
                                                                                                                                1. lower-/.f64N/A

                                                                                                                                  \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                                2. +-commutativeN/A

                                                                                                                                  \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                                                3. lower-+.f64N/A

                                                                                                                                  \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                                                4. lower-exp.f6498.8

                                                                                                                                  \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                                                                                                              5. Applied rewrites98.8%

                                                                                                                                \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                                                                                                              6. Taylor expanded in b around 0

                                                                                                                                \[\leadsto \frac{1}{2 + \color{blue}{b \cdot \left(1 + \frac{1}{2} \cdot b\right)}} \]
                                                                                                                              7. Step-by-step derivation
                                                                                                                                1. Applied rewrites53.8%

                                                                                                                                  \[\leadsto \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), \color{blue}{b}, 2\right)} \]
                                                                                                                              8. Recombined 2 regimes into one program.
                                                                                                                              9. Add Preprocessing

                                                                                                                              Alternative 13: 39.6% accurate, 17.5× speedup?

                                                                                                                              \[\begin{array}{l} \\ \frac{1}{\left(1 + a\right) + 1} \end{array} \]
                                                                                                                              (FPCore (a b) :precision binary64 (/ 1.0 (+ (+ 1.0 a) 1.0)))
                                                                                                                              double code(double a, double b) {
                                                                                                                              	return 1.0 / ((1.0 + a) + 1.0);
                                                                                                                              }
                                                                                                                              
                                                                                                                              real(8) function code(a, b)
                                                                                                                                  real(8), intent (in) :: a
                                                                                                                                  real(8), intent (in) :: b
                                                                                                                                  code = 1.0d0 / ((1.0d0 + a) + 1.0d0)
                                                                                                                              end function
                                                                                                                              
                                                                                                                              public static double code(double a, double b) {
                                                                                                                              	return 1.0 / ((1.0 + a) + 1.0);
                                                                                                                              }
                                                                                                                              
                                                                                                                              def code(a, b):
                                                                                                                              	return 1.0 / ((1.0 + a) + 1.0)
                                                                                                                              
                                                                                                                              function code(a, b)
                                                                                                                              	return Float64(1.0 / Float64(Float64(1.0 + a) + 1.0))
                                                                                                                              end
                                                                                                                              
                                                                                                                              function tmp = code(a, b)
                                                                                                                              	tmp = 1.0 / ((1.0 + a) + 1.0);
                                                                                                                              end
                                                                                                                              
                                                                                                                              code[a_, b_] := N[(1.0 / N[(N[(1.0 + a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
                                                                                                                              
                                                                                                                              \begin{array}{l}
                                                                                                                              
                                                                                                                              \\
                                                                                                                              \frac{1}{\left(1 + a\right) + 1}
                                                                                                                              \end{array}
                                                                                                                              
                                                                                                                              Derivation
                                                                                                                              1. Initial program 100.0%

                                                                                                                                \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                                              2. Add Preprocessing
                                                                                                                              3. Taylor expanded in b around 0

                                                                                                                                \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                                              4. Step-by-step derivation
                                                                                                                                1. Applied rewrites64.6%

                                                                                                                                  \[\leadsto \frac{e^{a}}{e^{a} + \color{blue}{1}} \]
                                                                                                                                2. Taylor expanded in a around 0

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

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

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

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

                                                                                                                                    \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot a + 1}, a, 1\right) + 1} \]
                                                                                                                                  5. lower-fma.f6464.6

                                                                                                                                    \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, a, 1\right)}, a, 1\right) + 1} \]
                                                                                                                                4. Applied rewrites64.6%

                                                                                                                                  \[\leadsto \frac{e^{a}}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)} + 1} \]
                                                                                                                                5. Taylor expanded in a around 0

                                                                                                                                  \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, 1\right) + 1} \]
                                                                                                                                6. Step-by-step derivation
                                                                                                                                  1. Applied rewrites52.2%

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

                                                                                                                                    \[\leadsto \frac{1}{\color{blue}{\left(1 + a\right)} + 1} \]
                                                                                                                                  3. Step-by-step derivation
                                                                                                                                    1. lower-+.f6437.4

                                                                                                                                      \[\leadsto \frac{1}{\color{blue}{\left(1 + a\right)} + 1} \]
                                                                                                                                  4. Applied rewrites37.4%

                                                                                                                                    \[\leadsto \frac{1}{\color{blue}{\left(1 + a\right)} + 1} \]
                                                                                                                                  5. Add Preprocessing

                                                                                                                                  Alternative 14: 39.1% accurate, 315.0× speedup?

                                                                                                                                  \[\begin{array}{l} \\ 0.5 \end{array} \]
                                                                                                                                  (FPCore (a b) :precision binary64 0.5)
                                                                                                                                  double code(double a, double b) {
                                                                                                                                  	return 0.5;
                                                                                                                                  }
                                                                                                                                  
                                                                                                                                  real(8) function code(a, b)
                                                                                                                                      real(8), intent (in) :: a
                                                                                                                                      real(8), intent (in) :: b
                                                                                                                                      code = 0.5d0
                                                                                                                                  end function
                                                                                                                                  
                                                                                                                                  public static double code(double a, double b) {
                                                                                                                                  	return 0.5;
                                                                                                                                  }
                                                                                                                                  
                                                                                                                                  def code(a, b):
                                                                                                                                  	return 0.5
                                                                                                                                  
                                                                                                                                  function code(a, b)
                                                                                                                                  	return 0.5
                                                                                                                                  end
                                                                                                                                  
                                                                                                                                  function tmp = code(a, b)
                                                                                                                                  	tmp = 0.5;
                                                                                                                                  end
                                                                                                                                  
                                                                                                                                  code[a_, b_] := 0.5
                                                                                                                                  
                                                                                                                                  \begin{array}{l}
                                                                                                                                  
                                                                                                                                  \\
                                                                                                                                  0.5
                                                                                                                                  \end{array}
                                                                                                                                  
                                                                                                                                  Derivation
                                                                                                                                  1. Initial program 100.0%

                                                                                                                                    \[\frac{e^{a}}{e^{a} + e^{b}} \]
                                                                                                                                  2. Add Preprocessing
                                                                                                                                  3. Taylor expanded in a around 0

                                                                                                                                    \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                                  4. Step-by-step derivation
                                                                                                                                    1. lower-/.f64N/A

                                                                                                                                      \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                                    2. +-commutativeN/A

                                                                                                                                      \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                                                    3. lower-+.f64N/A

                                                                                                                                      \[\leadsto \frac{1}{\color{blue}{e^{b} + 1}} \]
                                                                                                                                    4. lower-exp.f6481.6

                                                                                                                                      \[\leadsto \frac{1}{\color{blue}{e^{b}} + 1} \]
                                                                                                                                  5. Applied rewrites81.6%

                                                                                                                                    \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                                                                                                                                  6. Taylor expanded in b around 0

                                                                                                                                    \[\leadsto \frac{1}{2} \]
                                                                                                                                  7. Step-by-step derivation
                                                                                                                                    1. Applied rewrites36.7%

                                                                                                                                      \[\leadsto 0.5 \]
                                                                                                                                    2. Add Preprocessing

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

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

                                                                                                                                    Reproduce

                                                                                                                                    ?
                                                                                                                                    herbie shell --seed 2024235 
                                                                                                                                    (FPCore (a b)
                                                                                                                                      :name "Quotient of sum of exps"
                                                                                                                                      :precision binary64
                                                                                                                                    
                                                                                                                                      :alt
                                                                                                                                      (! :herbie-platform default (/ 1 (+ 1 (exp (- b a)))))
                                                                                                                                    
                                                                                                                                      (/ (exp a) (+ (exp a) (exp b))))