Quotient of sum of exps

Percentage Accurate: 98.9% → 100.0%
Time: 5.6s
Alternatives: 10
Speedup: 2.7×

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 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 98.9% 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: 100.0% accurate, 2.7× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{e^{a}}{e^{a} + e^{b}}} \]
    2. clear-numN/A

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

      \[\leadsto \color{blue}{\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}} \]
    4. lift-+.f64N/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e^{b} + e^{a}}}{e^{a}}} \]
    6. div-addN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + \frac{e^{a}}{e^{a}}}} \]
    7. *-inversesN/A

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

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + 1}} \]
    9. lift-exp.f64N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{e^{b}}}{e^{a}} + 1} \]
    10. lift-exp.f64N/A

      \[\leadsto \frac{1}{\frac{e^{b}}{\color{blue}{e^{a}}} + 1} \]
    11. div-expN/A

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

      \[\leadsto \frac{1}{\color{blue}{e^{b - a}} + 1} \]
    13. lower--.f6499.9

      \[\leadsto \frac{1}{e^{\color{blue}{b - a}} + 1} \]
  4. Applied rewrites99.9%

    \[\leadsto \color{blue}{\frac{1}{e^{b - a} + 1}} \]
  5. Add Preprocessing

Alternative 2: 56.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.6:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (/ (exp a) (+ (exp a) (exp b))) 0.6)
   (/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0))
   0.5))
double code(double a, double b) {
	double tmp;
	if ((exp(a) / (exp(a) + exp(b))) <= 0.6) {
		tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
	} else {
		tmp = 0.5;
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.6)
		tmp = Float64(1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0));
	else
		tmp = 0.5;
	end
	return tmp
end
code[a_, b_] := If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.6], N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision], 0.5]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.6:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\

\mathbf{else}:\\
\;\;\;\;0.5\\


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

      if 0.599999999999999978 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b)))

      1. Initial program 95.8%

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

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

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

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

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

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

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

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

          \[\leadsto 0.5 \]
      8. Recombined 2 regimes into one program.
      9. Add Preprocessing

      Alternative 3: 53.0% accurate, 0.9× speedup?

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

        1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

          if 0.599999999999999978 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b)))

          1. Initial program 95.8%

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

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

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

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

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

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

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

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

              \[\leadsto 0.5 \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 4: 52.6% accurate, 0.9× speedup?

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

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

                if 0.49980000000000002 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b)))

                1. Initial program 98.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. +-commutativeN/A

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

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

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

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

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

                    \[\leadsto 0.5 \]
                8. Recombined 2 regimes into one program.
                9. Add Preprocessing

                Alternative 5: 99.1% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{e^{b} + 1}\\ \mathbf{if}\;e^{b} \leq 0.9999999:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;e^{b} \leq 1.00000000002:\\ \;\;\;\;\frac{1}{e^{-a} + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                (FPCore (a b)
                 :precision binary64
                 (let* ((t_0 (/ 1.0 (+ (exp b) 1.0))))
                   (if (<= (exp b) 0.9999999)
                     t_0
                     (if (<= (exp b) 1.00000000002) (/ 1.0 (+ (exp (- a)) 1.0)) t_0))))
                double code(double a, double b) {
                	double t_0 = 1.0 / (exp(b) + 1.0);
                	double tmp;
                	if (exp(b) <= 0.9999999) {
                		tmp = t_0;
                	} else if (exp(b) <= 1.00000000002) {
                		tmp = 1.0 / (exp(-a) + 1.0);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                real(8) function code(a, b)
                    real(8), intent (in) :: a
                    real(8), intent (in) :: b
                    real(8) :: t_0
                    real(8) :: tmp
                    t_0 = 1.0d0 / (exp(b) + 1.0d0)
                    if (exp(b) <= 0.9999999d0) then
                        tmp = t_0
                    else if (exp(b) <= 1.00000000002d0) then
                        tmp = 1.0d0 / (exp(-a) + 1.0d0)
                    else
                        tmp = t_0
                    end if
                    code = tmp
                end function
                
                public static double code(double a, double b) {
                	double t_0 = 1.0 / (Math.exp(b) + 1.0);
                	double tmp;
                	if (Math.exp(b) <= 0.9999999) {
                		tmp = t_0;
                	} else if (Math.exp(b) <= 1.00000000002) {
                		tmp = 1.0 / (Math.exp(-a) + 1.0);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(a, b):
                	t_0 = 1.0 / (math.exp(b) + 1.0)
                	tmp = 0
                	if math.exp(b) <= 0.9999999:
                		tmp = t_0
                	elif math.exp(b) <= 1.00000000002:
                		tmp = 1.0 / (math.exp(-a) + 1.0)
                	else:
                		tmp = t_0
                	return tmp
                
                function code(a, b)
                	t_0 = Float64(1.0 / Float64(exp(b) + 1.0))
                	tmp = 0.0
                	if (exp(b) <= 0.9999999)
                		tmp = t_0;
                	elseif (exp(b) <= 1.00000000002)
                		tmp = Float64(1.0 / Float64(exp(Float64(-a)) + 1.0));
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(a, b)
                	t_0 = 1.0 / (exp(b) + 1.0);
                	tmp = 0.0;
                	if (exp(b) <= 0.9999999)
                		tmp = t_0;
                	elseif (exp(b) <= 1.00000000002)
                		tmp = 1.0 / (exp(-a) + 1.0);
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[a_, b_] := Block[{t$95$0 = N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Exp[b], $MachinePrecision], 0.9999999], t$95$0, If[LessEqual[N[Exp[b], $MachinePrecision], 1.00000000002], N[(1.0 / N[(N[Exp[(-a)], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := \frac{1}{e^{b} + 1}\\
                \mathbf{if}\;e^{b} \leq 0.9999999:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;e^{b} \leq 1.00000000002:\\
                \;\;\;\;\frac{1}{e^{-a} + 1}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (exp.f64 b) < 0.999999900000000053 or 1.00000000002 < (exp.f64 b)

                  1. Initial program 99.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. +-commutativeN/A

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

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

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

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

                  if 0.999999900000000053 < (exp.f64 b) < 1.00000000002

                  1. Initial program 99.2%

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

                      \[\leadsto \color{blue}{\frac{e^{a}}{e^{a} + e^{b}}} \]
                    2. clear-numN/A

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

                      \[\leadsto \color{blue}{\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}} \]
                    4. lift-+.f64N/A

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

                      \[\leadsto \frac{1}{\frac{\color{blue}{e^{b} + e^{a}}}{e^{a}}} \]
                    6. div-addN/A

                      \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + \frac{e^{a}}{e^{a}}}} \]
                    7. *-inversesN/A

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

                      \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + 1}} \]
                    9. lift-exp.f64N/A

                      \[\leadsto \frac{1}{\frac{\color{blue}{e^{b}}}{e^{a}} + 1} \]
                    10. lift-exp.f64N/A

                      \[\leadsto \frac{1}{\frac{e^{b}}{\color{blue}{e^{a}}} + 1} \]
                    11. div-expN/A

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

                      \[\leadsto \frac{1}{\color{blue}{e^{b - a}} + 1} \]
                    13. lower--.f6499.9

                      \[\leadsto \frac{1}{e^{\color{blue}{b - a}} + 1} \]
                  4. Applied rewrites99.9%

                    \[\leadsto \color{blue}{\frac{1}{e^{b - a} + 1}} \]
                  5. Taylor expanded in a around inf

                    \[\leadsto \frac{1}{e^{\color{blue}{-1 \cdot a}} + 1} \]
                  6. Step-by-step derivation
                    1. neg-mul-1N/A

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

                      \[\leadsto \frac{1}{e^{\color{blue}{-a}} + 1} \]
                  7. Applied rewrites99.6%

                    \[\leadsto \frac{1}{e^{\color{blue}{-a}} + 1} \]
                3. Recombined 2 regimes into one program.
                4. Add Preprocessing

                Alternative 6: 92.7% accurate, 2.5× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -9.6 \cdot 10^{+41}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(b + 1, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, a, 0.5\right), a, -1\right), a, 1\right), 1\right)}\\ \mathbf{elif}\;a \leq -880000000:\\ \;\;\;\;{b}^{3} \cdot 0.020833333333333332\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{b} + 1}\\ \end{array} \end{array} \]
                (FPCore (a b)
                 :precision binary64
                 (if (<= a -9.6e+41)
                   (/
                    1.0
                    (fma
                     (+ b 1.0)
                     (fma (fma (fma -0.16666666666666666 a 0.5) a -1.0) a 1.0)
                     1.0))
                   (if (<= a -880000000.0)
                     (* (pow b 3.0) 0.020833333333333332)
                     (/ 1.0 (+ (exp b) 1.0)))))
                double code(double a, double b) {
                	double tmp;
                	if (a <= -9.6e+41) {
                		tmp = 1.0 / fma((b + 1.0), fma(fma(fma(-0.16666666666666666, a, 0.5), a, -1.0), a, 1.0), 1.0);
                	} else if (a <= -880000000.0) {
                		tmp = pow(b, 3.0) * 0.020833333333333332;
                	} else {
                		tmp = 1.0 / (exp(b) + 1.0);
                	}
                	return tmp;
                }
                
                function code(a, b)
                	tmp = 0.0
                	if (a <= -9.6e+41)
                		tmp = Float64(1.0 / fma(Float64(b + 1.0), fma(fma(fma(-0.16666666666666666, a, 0.5), a, -1.0), a, 1.0), 1.0));
                	elseif (a <= -880000000.0)
                		tmp = Float64((b ^ 3.0) * 0.020833333333333332);
                	else
                		tmp = Float64(1.0 / Float64(exp(b) + 1.0));
                	end
                	return tmp
                end
                
                code[a_, b_] := If[LessEqual[a, -9.6e+41], N[(1.0 / N[(N[(b + 1.0), $MachinePrecision] * N[(N[(N[(-0.16666666666666666 * a + 0.5), $MachinePrecision] * a + -1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -880000000.0], N[(N[Power[b, 3.0], $MachinePrecision] * 0.020833333333333332), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;a \leq -9.6 \cdot 10^{+41}:\\
                \;\;\;\;\frac{1}{\mathsf{fma}\left(b + 1, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, a, 0.5\right), a, -1\right), a, 1\right), 1\right)}\\
                
                \mathbf{elif}\;a \leq -880000000:\\
                \;\;\;\;{b}^{3} \cdot 0.020833333333333332\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{1}{e^{b} + 1}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if a < -9.6000000000000007e41

                  1. Initial program 100.0%

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

                      \[\leadsto \color{blue}{\frac{e^{a}}{e^{a} + e^{b}}} \]
                    2. clear-numN/A

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

                      \[\leadsto \color{blue}{\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}} \]
                    4. lift-+.f64N/A

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

                      \[\leadsto \frac{1}{\frac{\color{blue}{e^{b} + e^{a}}}{e^{a}}} \]
                    6. div-addN/A

                      \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + \frac{e^{a}}{e^{a}}}} \]
                    7. *-inversesN/A

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

                      \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + 1}} \]
                    9. lift-exp.f64N/A

                      \[\leadsto \frac{1}{\frac{\color{blue}{e^{b}}}{e^{a}} + 1} \]
                    10. lift-exp.f64N/A

                      \[\leadsto \frac{1}{\frac{e^{b}}{\color{blue}{e^{a}}} + 1} \]
                    11. div-expN/A

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(1 + b, e^{\mathsf{neg}\left(a\right)}, 1\right)}} \]
                    5. lower-+.f64N/A

                      \[\leadsto \frac{1}{\mathsf{fma}\left(\color{blue}{1 + b}, e^{\mathsf{neg}\left(a\right)}, 1\right)} \]
                    6. neg-mul-1N/A

                      \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{-1 \cdot a}}, 1\right)} \]
                    7. lower-exp.f64N/A

                      \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, \color{blue}{e^{-1 \cdot a}}, 1\right)} \]
                    8. neg-mul-1N/A

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

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

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

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

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

                    if -9.6000000000000007e41 < a < -8.8e8

                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(b \cdot b, 0.020833333333333332, -0.25\right), \color{blue}{b}, 0.5\right) \]
                      2. Taylor expanded in b around inf

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

                          \[\leadsto {b}^{3} \cdot 0.020833333333333332 \]

                        if -8.8e8 < a

                        1. Initial program 98.8%

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

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

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

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

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

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

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

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

                      Alternative 7: 71.6% accurate, 6.2× speedup?

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

                        1. Initial program 97.8%

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

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

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

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

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

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

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

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

                            \[\leadsto 0.5 \]

                          if -2300 < b < 9.1999999999999995e102

                          1. Initial program 99.3%

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

                              \[\leadsto \color{blue}{\frac{e^{a}}{e^{a} + e^{b}}} \]
                            2. clear-numN/A

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

                              \[\leadsto \color{blue}{\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}} \]
                            4. lift-+.f64N/A

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

                              \[\leadsto \frac{1}{\frac{\color{blue}{e^{b} + e^{a}}}{e^{a}}} \]
                            6. div-addN/A

                              \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + \frac{e^{a}}{e^{a}}}} \]
                            7. *-inversesN/A

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

                              \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + 1}} \]
                            9. lift-exp.f64N/A

                              \[\leadsto \frac{1}{\frac{\color{blue}{e^{b}}}{e^{a}} + 1} \]
                            10. lift-exp.f64N/A

                              \[\leadsto \frac{1}{\frac{e^{b}}{\color{blue}{e^{a}}} + 1} \]
                            11. div-expN/A

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

                              \[\leadsto \frac{1}{\color{blue}{e^{b - a}} + 1} \]
                            13. lower--.f6499.9

                              \[\leadsto \frac{1}{e^{\color{blue}{b - a}} + 1} \]
                          4. Applied rewrites99.9%

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

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

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

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

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

                              \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(1 + b, e^{\mathsf{neg}\left(a\right)}, 1\right)}} \]
                            5. lower-+.f64N/A

                              \[\leadsto \frac{1}{\mathsf{fma}\left(\color{blue}{1 + b}, e^{\mathsf{neg}\left(a\right)}, 1\right)} \]
                            6. neg-mul-1N/A

                              \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{-1 \cdot a}}, 1\right)} \]
                            7. lower-exp.f64N/A

                              \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, \color{blue}{e^{-1 \cdot a}}, 1\right)} \]
                            8. neg-mul-1N/A

                              \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{\mathsf{neg}\left(a\right)}}, 1\right)} \]
                            9. lower-neg.f6490.6

                              \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{-a}}, 1\right)} \]
                          7. Applied rewrites90.6%

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

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

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

                            if 9.1999999999999995e102 < b

                            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                            Alternative 8: 68.5% accurate, 7.0× speedup?

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

                              1. Initial program 97.8%

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

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

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

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

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

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

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

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

                                  \[\leadsto 0.5 \]

                                if -2300 < b < 5.20000000000000013e102

                                1. Initial program 99.3%

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

                                    \[\leadsto \color{blue}{\frac{e^{a}}{e^{a} + e^{b}}} \]
                                  2. clear-numN/A

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

                                    \[\leadsto \color{blue}{\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}} \]
                                  4. lift-+.f64N/A

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

                                    \[\leadsto \frac{1}{\frac{\color{blue}{e^{b} + e^{a}}}{e^{a}}} \]
                                  6. div-addN/A

                                    \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + \frac{e^{a}}{e^{a}}}} \]
                                  7. *-inversesN/A

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

                                    \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + 1}} \]
                                  9. lift-exp.f64N/A

                                    \[\leadsto \frac{1}{\frac{\color{blue}{e^{b}}}{e^{a}} + 1} \]
                                  10. lift-exp.f64N/A

                                    \[\leadsto \frac{1}{\frac{e^{b}}{\color{blue}{e^{a}}} + 1} \]
                                  11. div-expN/A

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

                                    \[\leadsto \frac{1}{\color{blue}{e^{b - a}} + 1} \]
                                  13. lower--.f6499.9

                                    \[\leadsto \frac{1}{e^{\color{blue}{b - a}} + 1} \]
                                4. Applied rewrites99.9%

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

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

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

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

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

                                    \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(1 + b, e^{\mathsf{neg}\left(a\right)}, 1\right)}} \]
                                  5. lower-+.f64N/A

                                    \[\leadsto \frac{1}{\mathsf{fma}\left(\color{blue}{1 + b}, e^{\mathsf{neg}\left(a\right)}, 1\right)} \]
                                  6. neg-mul-1N/A

                                    \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{-1 \cdot a}}, 1\right)} \]
                                  7. lower-exp.f64N/A

                                    \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, \color{blue}{e^{-1 \cdot a}}, 1\right)} \]
                                  8. neg-mul-1N/A

                                    \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{\mathsf{neg}\left(a\right)}}, 1\right)} \]
                                  9. lower-neg.f6490.6

                                    \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{-a}}, 1\right)} \]
                                7. Applied rewrites90.6%

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

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

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

                                  if 5.20000000000000013e102 < b

                                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                                  Alternative 9: 54.3% accurate, 8.7× speedup?

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

                                    1. Initial program 97.8%

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

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

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

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

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

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

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

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

                                        \[\leadsto 0.5 \]

                                      if -1.3999999999999999 < b < 2.49999999999999986e118

                                      1. Initial program 99.3%

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

                                          \[\leadsto \color{blue}{\frac{e^{a}}{e^{a} + e^{b}}} \]
                                        2. clear-numN/A

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

                                          \[\leadsto \color{blue}{\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}} \]
                                        4. lift-+.f64N/A

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

                                          \[\leadsto \frac{1}{\frac{\color{blue}{e^{b} + e^{a}}}{e^{a}}} \]
                                        6. div-addN/A

                                          \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + \frac{e^{a}}{e^{a}}}} \]
                                        7. *-inversesN/A

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

                                          \[\leadsto \frac{1}{\color{blue}{\frac{e^{b}}{e^{a}} + 1}} \]
                                        9. lift-exp.f64N/A

                                          \[\leadsto \frac{1}{\frac{\color{blue}{e^{b}}}{e^{a}} + 1} \]
                                        10. lift-exp.f64N/A

                                          \[\leadsto \frac{1}{\frac{e^{b}}{\color{blue}{e^{a}}} + 1} \]
                                        11. div-expN/A

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

                                          \[\leadsto \frac{1}{\color{blue}{e^{b - a}} + 1} \]
                                        13. lower--.f6499.9

                                          \[\leadsto \frac{1}{e^{\color{blue}{b - a}} + 1} \]
                                      4. Applied rewrites99.9%

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

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

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

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

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

                                          \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(1 + b, e^{\mathsf{neg}\left(a\right)}, 1\right)}} \]
                                        5. lower-+.f64N/A

                                          \[\leadsto \frac{1}{\mathsf{fma}\left(\color{blue}{1 + b}, e^{\mathsf{neg}\left(a\right)}, 1\right)} \]
                                        6. neg-mul-1N/A

                                          \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{-1 \cdot a}}, 1\right)} \]
                                        7. lower-exp.f64N/A

                                          \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, \color{blue}{e^{-1 \cdot a}}, 1\right)} \]
                                        8. neg-mul-1N/A

                                          \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{\mathsf{neg}\left(a\right)}}, 1\right)} \]
                                        9. lower-neg.f6489.6

                                          \[\leadsto \frac{1}{\mathsf{fma}\left(1 + b, e^{\color{blue}{-a}}, 1\right)} \]
                                      7. Applied rewrites89.6%

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

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

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

                                        if 2.49999999999999986e118 < b

                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                                        Alternative 10: 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.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. +-commutativeN/A

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

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

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

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

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

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