Quotient of sum of exps

Percentage Accurate: 99.0% → 99.0%
Time: 8.5s
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^{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}
Derivation
  1. Initial program 99.6%

    \[\frac{e^{a}}{e^{a} + e^{b}} \]
  2. Add Preprocessing
  3. 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}{e^{b} + 1}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (exp a) 0.0) (/ (exp a) (+ 1.0 1.0)) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
	double tmp;
	if (exp(a) <= 0.0) {
		tmp = exp(a) / (1.0 + 1.0);
	} else {
		tmp = 1.0 / (exp(b) + 1.0);
	}
	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 / (exp(b) + 1.0d0)
    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 / (Math.exp(b) + 1.0);
	}
	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 / (math.exp(b) + 1.0)
	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(exp(b) + 1.0));
	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 / (exp(b) + 1.0);
	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[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\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 99.5%

          \[\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. lower-+.f64N/A

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

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

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

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

      Alternative 3: 92.8% accurate, 2.6× speedup?

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

        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} \]
            2. Taylor expanded in a around 0

              \[\leadsto \frac{\color{blue}{1 + a}}{1 + 1} \]
            3. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
              2. lower-+.f642.1

                \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
            4. Applied rewrites2.1%

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

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

                \[\leadsto \frac{a + 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. lower-fma.f64N/A

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

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

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

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

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

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

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

            if -5.25000000000000003e79 < a

            1. Initial program 99.5%

              \[\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. lower-+.f64N/A

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

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

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

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

          Alternative 4: 89.6% accurate, 2.9× speedup?

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

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

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

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

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

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

            if -14.5 < b < 1.59999999999999986e30

            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 rewrites97.7%

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

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

                  \[\leadsto \frac{\color{blue}{1 + a}}{1 + 1} \]
                3. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                  2. lower-+.f6461.3

                    \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                4. Applied rewrites61.3%

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

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

                    \[\leadsto \frac{a + 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. lower-fma.f64N/A

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

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

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

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

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

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

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

                if 1.59999999999999986e30 < b < 4.39999999999999984e51

                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 rewrites3.1%

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

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

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

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

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

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

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

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

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

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

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

                      if 4.39999999999999984e51 < b < 1.01999999999999991e103

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

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

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

                        \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                      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 rewrites6.8%

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

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

                          if 1.01999999999999991e103 < b

                          1. Initial program 98.1%

                            \[\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. lower-+.f64N/A

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

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

                            \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                          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 rewrites100.0%

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

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

                                \[\leadsto \frac{1}{b \cdot \left(b \cdot \color{blue}{\left(b \cdot 0.16666666666666666\right)}\right)} \]
                            4. Recombined 5 regimes into one program.
                            5. Final simplification90.9%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -14.5:\\ \;\;\;\;e^{b} + 1\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{+30}:\\ \;\;\;\;\frac{a + 1}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right), 1\right)}\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{+51}:\\ \;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right), b \cdot \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), b\right), -4\right)}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right), -2\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{b \cdot \left(b \cdot \left(b \cdot 0.16666666666666666\right)\right)}\\ \end{array} \]
                            6. Add Preprocessing

                            Alternative 5: 75.4% accurate, 3.2× speedup?

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

                              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 rewrites74.2%

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

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

                                    \[\leadsto \frac{\color{blue}{1 + a}}{1 + 1} \]
                                  3. Step-by-step derivation
                                    1. +-commutativeN/A

                                      \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                                    2. lower-+.f6448.7

                                      \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                                  4. Applied rewrites48.7%

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

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

                                      \[\leadsto \frac{a + 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. lower-fma.f64N/A

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

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

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

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

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

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

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

                                  if 1.59999999999999986e30 < b < 4.39999999999999984e51

                                  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 rewrites3.1%

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

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

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

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

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

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

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

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

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

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

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

                                        if 4.39999999999999984e51 < b < 1.01999999999999991e103

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

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

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

                                          \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                        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 rewrites6.8%

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

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

                                            if 1.01999999999999991e103 < b

                                            1. Initial program 98.1%

                                              \[\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. lower-+.f64N/A

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

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

                                              \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                            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 rewrites100.0%

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

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

                                                  \[\leadsto \frac{1}{b \cdot \left(b \cdot \color{blue}{\left(b \cdot 0.16666666666666666\right)}\right)} \]
                                              4. Recombined 4 regimes into one program.
                                              5. Final simplification73.4%

                                                \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.6 \cdot 10^{+30}:\\ \;\;\;\;\frac{a + 1}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right), 1\right)}\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{+51}:\\ \;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right), b \cdot \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), b\right), -4\right)}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right), -2\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{b \cdot \left(b \cdot \left(b \cdot 0.16666666666666666\right)\right)}\\ \end{array} \]
                                              6. Add Preprocessing

                                              Alternative 6: 73.9% accurate, 3.6× speedup?

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

                                                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 rewrites74.2%

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

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

                                                      \[\leadsto \frac{\color{blue}{1 + a}}{1 + 1} \]
                                                    3. Step-by-step derivation
                                                      1. +-commutativeN/A

                                                        \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                                                      2. lower-+.f6448.7

                                                        \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                                                    4. Applied rewrites48.7%

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

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

                                                        \[\leadsto \frac{a + 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. lower-fma.f64N/A

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

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

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

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

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

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

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

                                                    if 1.59999999999999986e30 < b < 2.9000000000000002e77

                                                    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 rewrites10.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 rewrites10.0%

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

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

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

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

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

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

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

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

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

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

                                                          if 2.9000000000000002e77 < b < 1.00000000000000004e154

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

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

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

                                                            \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                          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 rewrites78.2%

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

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

                                                              if 1.00000000000000004e154 < b

                                                              1. Initial program 97.2%

                                                                \[\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. lower-+.f64N/A

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

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

                                                                \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                              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 rewrites100.0%

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

                                                                \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.6 \cdot 10^{+30}:\\ \;\;\;\;\frac{a + 1}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right), 1\right)}\\ \mathbf{elif}\;b \leq 2.9 \cdot 10^{+77}:\\ \;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\ \mathbf{elif}\;b \leq 10^{+154}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(b, \frac{\mathsf{fma}\left(\mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), b \cdot \left(b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)\right), -1\right)}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), -1\right)}, 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\right)}\\ \end{array} \]
                                                              10. Add Preprocessing

                                                              Alternative 7: 72.4% accurate, 7.5× speedup?

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

                                                                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 rewrites74.2%

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

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

                                                                      \[\leadsto \frac{\color{blue}{1 + a}}{1 + 1} \]
                                                                    3. Step-by-step derivation
                                                                      1. +-commutativeN/A

                                                                        \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                                                                      2. lower-+.f6448.7

                                                                        \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                                                                    4. Applied rewrites48.7%

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

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

                                                                        \[\leadsto \frac{a + 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. lower-fma.f64N/A

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

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

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

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

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

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

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

                                                                    if 1.59999999999999986e30 < b < 4.3999999999999998e95

                                                                    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 rewrites15.2%

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

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

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

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

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

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

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

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

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

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

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

                                                                          if 4.3999999999999998e95 < b

                                                                          1. Initial program 98.2%

                                                                            \[\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. lower-+.f64N/A

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

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

                                                                            \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                          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 rewrites95.1%

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

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

                                                                                \[\leadsto \frac{1}{b \cdot \left(b \cdot \color{blue}{\mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)}\right)} \]
                                                                            4. Recombined 3 regimes into one program.
                                                                            5. Final simplification69.6%

                                                                              \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.6 \cdot 10^{+30}:\\ \;\;\;\;\frac{a + 1}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right), 1\right)}\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{+95}:\\ \;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{b \cdot \left(b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)\right)}\\ \end{array} \]
                                                                            6. Add Preprocessing

                                                                            Alternative 8: 69.1% accurate, 7.9× speedup?

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

                                                                              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 rewrites74.2%

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

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

                                                                                    \[\leadsto \frac{\color{blue}{1 + a}}{1 + 1} \]
                                                                                  3. Step-by-step derivation
                                                                                    1. +-commutativeN/A

                                                                                      \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                                                                                    2. lower-+.f6448.7

                                                                                      \[\leadsto \frac{\color{blue}{a + 1}}{1 + 1} \]
                                                                                  4. Applied rewrites48.7%

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

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

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

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

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

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

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

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

                                                                                  if 1.59999999999999986e30 < b < 4.3999999999999998e95

                                                                                  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 rewrites15.2%

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

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

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

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

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

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

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

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

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

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

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

                                                                                        if 4.3999999999999998e95 < b

                                                                                        1. Initial program 98.2%

                                                                                          \[\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. lower-+.f64N/A

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

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

                                                                                          \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                        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 rewrites95.1%

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

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

                                                                                              \[\leadsto \frac{1}{b \cdot \left(b \cdot \color{blue}{\mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)}\right)} \]
                                                                                          4. Recombined 3 regimes into one program.
                                                                                          5. Final simplification67.3%

                                                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.6 \cdot 10^{+30}:\\ \;\;\;\;\frac{a + 1}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, 1\right), 1\right)}\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{+95}:\\ \;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{b \cdot \left(b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)\right)}\\ \end{array} \]
                                                                                          6. Add Preprocessing

                                                                                          Alternative 9: 60.5% accurate, 7.9× speedup?

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

                                                                                            1. Initial program 100.0%

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

                                                                                              \[\leadsto \color{blue}{-1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}}} \]
                                                                                            4. Step-by-step derivation
                                                                                              1. associate-*r/N/A

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

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

                                                                                                \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot e^{a}}}{\left(1 + e^{a}\right) \cdot \left(1 + e^{a}\right)} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                              4. times-fracN/A

                                                                                                \[\leadsto \color{blue}{\frac{-1 \cdot b}{1 + e^{a}} \cdot \frac{e^{a}}{1 + e^{a}}} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                              5. distribute-lft1-inN/A

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

                                                                                                \[\leadsto \color{blue}{\left(\frac{-1 \cdot b}{1 + e^{a}} + 1\right) \cdot \frac{e^{a}}{1 + e^{a}}} \]
                                                                                            5. Applied rewrites70.7%

                                                                                              \[\leadsto \color{blue}{\left(\frac{b}{-1 - e^{a}} + 1\right) \cdot \frac{e^{a}}{e^{a} + 1}} \]
                                                                                            6. Taylor expanded in a around 0

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

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

                                                                                                \[\leadsto \frac{1}{2} + \frac{1}{4} \cdot \color{blue}{a} \]
                                                                                              3. Step-by-step derivation
                                                                                                1. Applied rewrites50.5%

                                                                                                  \[\leadsto \mathsf{fma}\left(a, 0.25, 0.5\right) \]

                                                                                                if 1.95e15 < b < 4.3999999999999998e95

                                                                                                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 rewrites22.5%

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

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

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

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

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

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

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

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

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

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

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

                                                                                                      if 4.3999999999999998e95 < b

                                                                                                      1. Initial program 98.2%

                                                                                                        \[\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. lower-+.f64N/A

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

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

                                                                                                        \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                      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 rewrites95.1%

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

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

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

                                                                                                        Alternative 10: 60.5% accurate, 8.1× speedup?

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

                                                                                                          1. Initial program 100.0%

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

                                                                                                            \[\leadsto \color{blue}{-1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}}} \]
                                                                                                          4. Step-by-step derivation
                                                                                                            1. associate-*r/N/A

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

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

                                                                                                              \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot e^{a}}}{\left(1 + e^{a}\right) \cdot \left(1 + e^{a}\right)} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                                            4. times-fracN/A

                                                                                                              \[\leadsto \color{blue}{\frac{-1 \cdot b}{1 + e^{a}} \cdot \frac{e^{a}}{1 + e^{a}}} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                                            5. distribute-lft1-inN/A

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

                                                                                                              \[\leadsto \color{blue}{\left(\frac{-1 \cdot b}{1 + e^{a}} + 1\right) \cdot \frac{e^{a}}{1 + e^{a}}} \]
                                                                                                          5. Applied rewrites70.7%

                                                                                                            \[\leadsto \color{blue}{\left(\frac{b}{-1 - e^{a}} + 1\right) \cdot \frac{e^{a}}{e^{a} + 1}} \]
                                                                                                          6. Taylor expanded in a around 0

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

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

                                                                                                              \[\leadsto \frac{1}{2} + \frac{1}{4} \cdot \color{blue}{a} \]
                                                                                                            3. Step-by-step derivation
                                                                                                              1. Applied rewrites50.5%

                                                                                                                \[\leadsto \mathsf{fma}\left(a, 0.25, 0.5\right) \]

                                                                                                              if 1.95e15 < b < 4.3999999999999998e95

                                                                                                              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 rewrites22.5%

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                    if 4.3999999999999998e95 < b

                                                                                                                    1. Initial program 98.2%

                                                                                                                      \[\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. lower-+.f64N/A

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

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

                                                                                                                      \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                    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 rewrites95.1%

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

                                                                                                                        \[\leadsto \frac{1}{\frac{1}{6} \cdot {b}^{\color{blue}{3}}} \]
                                                                                                                      3. Step-by-step derivation
                                                                                                                        1. Applied rewrites95.1%

                                                                                                                          \[\leadsto \frac{1}{b \cdot \left(b \cdot \color{blue}{\left(b \cdot 0.16666666666666666\right)}\right)} \]
                                                                                                                      4. Recombined 3 regimes into one program.
                                                                                                                      5. Add Preprocessing

                                                                                                                      Alternative 11: 57.7% accurate, 8.5× speedup?

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

                                                                                                                        1. Initial program 100.0%

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

                                                                                                                          \[\leadsto \color{blue}{-1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}}} \]
                                                                                                                        4. Step-by-step derivation
                                                                                                                          1. associate-*r/N/A

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

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

                                                                                                                            \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot e^{a}}}{\left(1 + e^{a}\right) \cdot \left(1 + e^{a}\right)} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                                                          4. times-fracN/A

                                                                                                                            \[\leadsto \color{blue}{\frac{-1 \cdot b}{1 + e^{a}} \cdot \frac{e^{a}}{1 + e^{a}}} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                                                          5. distribute-lft1-inN/A

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

                                                                                                                            \[\leadsto \color{blue}{\left(\frac{-1 \cdot b}{1 + e^{a}} + 1\right) \cdot \frac{e^{a}}{1 + e^{a}}} \]
                                                                                                                        5. Applied rewrites70.7%

                                                                                                                          \[\leadsto \color{blue}{\left(\frac{b}{-1 - e^{a}} + 1\right) \cdot \frac{e^{a}}{e^{a} + 1}} \]
                                                                                                                        6. Taylor expanded in a around 0

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

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

                                                                                                                            \[\leadsto \frac{1}{2} + \frac{1}{4} \cdot \color{blue}{a} \]
                                                                                                                          3. Step-by-step derivation
                                                                                                                            1. Applied rewrites50.5%

                                                                                                                              \[\leadsto \mathsf{fma}\left(a, 0.25, 0.5\right) \]

                                                                                                                            if 1.95e15 < b < 1.8999999999999999e154

                                                                                                                            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 rewrites25.5%

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                                  if 1.8999999999999999e154 < b

                                                                                                                                  1. Initial program 97.2%

                                                                                                                                    \[\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. lower-+.f64N/A

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

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

                                                                                                                                    \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                                  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 rewrites100.0%

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

                                                                                                                                  Alternative 12: 53.8% accurate, 10.5× speedup?

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

                                                                                                                                    1. Initial program 100.0%

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

                                                                                                                                      \[\leadsto \color{blue}{-1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}}} \]
                                                                                                                                    4. Step-by-step derivation
                                                                                                                                      1. associate-*r/N/A

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

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

                                                                                                                                        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot e^{a}}}{\left(1 + e^{a}\right) \cdot \left(1 + e^{a}\right)} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                                                                      4. times-fracN/A

                                                                                                                                        \[\leadsto \color{blue}{\frac{-1 \cdot b}{1 + e^{a}} \cdot \frac{e^{a}}{1 + e^{a}}} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                                                                      5. distribute-lft1-inN/A

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

                                                                                                                                        \[\leadsto \color{blue}{\left(\frac{-1 \cdot b}{1 + e^{a}} + 1\right) \cdot \frac{e^{a}}{1 + e^{a}}} \]
                                                                                                                                    5. Applied rewrites41.5%

                                                                                                                                      \[\leadsto \color{blue}{\left(\frac{b}{-1 - e^{a}} + 1\right) \cdot \frac{e^{a}}{e^{a} + 1}} \]
                                                                                                                                    6. Taylor expanded in a around 0

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

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

                                                                                                                                        \[\leadsto \frac{1}{2} + \frac{1}{4} \cdot \color{blue}{a} \]
                                                                                                                                      3. Step-by-step derivation
                                                                                                                                        1. Applied rewrites38.8%

                                                                                                                                          \[\leadsto \mathsf{fma}\left(a, 0.25, 0.5\right) \]

                                                                                                                                        if -2.5999999999999998e-190 < b

                                                                                                                                        1. Initial program 99.4%

                                                                                                                                          \[\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. lower-+.f64N/A

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

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

                                                                                                                                          \[\leadsto \color{blue}{\frac{1}{1 + e^{b}}} \]
                                                                                                                                        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 rewrites57.1%

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

                                                                                                                                        Alternative 13: 39.4% accurate, 45.0× speedup?

                                                                                                                                        \[\begin{array}{l} \\ \mathsf{fma}\left(a, 0.25, 0.5\right) \end{array} \]
                                                                                                                                        (FPCore (a b) :precision binary64 (fma a 0.25 0.5))
                                                                                                                                        double code(double a, double b) {
                                                                                                                                        	return fma(a, 0.25, 0.5);
                                                                                                                                        }
                                                                                                                                        
                                                                                                                                        function code(a, b)
                                                                                                                                        	return fma(a, 0.25, 0.5)
                                                                                                                                        end
                                                                                                                                        
                                                                                                                                        code[a_, b_] := N[(a * 0.25 + 0.5), $MachinePrecision]
                                                                                                                                        
                                                                                                                                        \begin{array}{l}
                                                                                                                                        
                                                                                                                                        \\
                                                                                                                                        \mathsf{fma}\left(a, 0.25, 0.5\right)
                                                                                                                                        \end{array}
                                                                                                                                        
                                                                                                                                        Derivation
                                                                                                                                        1. Initial program 99.6%

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

                                                                                                                                          \[\leadsto \color{blue}{-1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}}} \]
                                                                                                                                        4. Step-by-step derivation
                                                                                                                                          1. associate-*r/N/A

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

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

                                                                                                                                            \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot e^{a}}}{\left(1 + e^{a}\right) \cdot \left(1 + e^{a}\right)} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                                                                          4. times-fracN/A

                                                                                                                                            \[\leadsto \color{blue}{\frac{-1 \cdot b}{1 + e^{a}} \cdot \frac{e^{a}}{1 + e^{a}}} + \frac{e^{a}}{1 + e^{a}} \]
                                                                                                                                          5. distribute-lft1-inN/A

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

                                                                                                                                            \[\leadsto \color{blue}{\left(\frac{-1 \cdot b}{1 + e^{a}} + 1\right) \cdot \frac{e^{a}}{1 + e^{a}}} \]
                                                                                                                                        5. Applied rewrites57.9%

                                                                                                                                          \[\leadsto \color{blue}{\left(\frac{b}{-1 - e^{a}} + 1\right) \cdot \frac{e^{a}}{e^{a} + 1}} \]
                                                                                                                                        6. Taylor expanded in a around 0

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

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

                                                                                                                                            \[\leadsto \frac{1}{2} + \frac{1}{4} \cdot \color{blue}{a} \]
                                                                                                                                          3. Step-by-step derivation
                                                                                                                                            1. Applied rewrites36.5%

                                                                                                                                              \[\leadsto \mathsf{fma}\left(a, 0.25, 0.5\right) \]
                                                                                                                                            2. Add Preprocessing

                                                                                                                                            Alternative 14: 39.2% 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 99.6%

                                                                                                                                              \[\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. lower-+.f64N/A

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

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

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

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

                                                                                                                                                \[\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 2024232 
                                                                                                                                              (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))))