Quotient of sum of exps

Percentage Accurate: 98.9% → 98.4%
Time: 9.1s
Alternatives: 11
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 11 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: 98.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{a} \leq 0:\\ \;\;\;\;e^{a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{b} + 1}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (exp a) 0.0) (* (exp a) 0.5) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
	double tmp;
	if (exp(a) <= 0.0) {
		tmp = exp(a) * 0.5;
	} 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) * 0.5d0
    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) * 0.5;
	} 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) * 0.5
	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) * 0.5);
	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) * 0.5;
	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] * 0.5), $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:\\
\;\;\;\;e^{a} \cdot 0.5\\

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

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

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

          \[\leadsto \frac{e^{a}}{\color{blue}{2}} \]
        2. Step-by-step derivation
          1. lift-exp.f64N/A

            \[\leadsto \frac{\color{blue}{e^{a}}}{2} \]
          2. div-invN/A

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

            \[\leadsto e^{a} \cdot \color{blue}{\frac{1}{2}} \]
          4. lower-*.f64100.0

            \[\leadsto \color{blue}{e^{a} \cdot 0.5} \]
        3. Applied egg-rr100.0%

          \[\leadsto \color{blue}{e^{a} \cdot 0.5} \]

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

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

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

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

      Alternative 2: 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}
      
      Derivation
      1. Initial program 99.6%

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

      Alternative 3: 57.9% accurate, 2.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{b} \leq 2:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\ \end{array} \end{array} \]
      (FPCore (a b)
       :precision binary64
       (if (<= (exp b) 2.0) 0.5 (/ 6.0 (* b (* b b)))))
      double code(double a, double b) {
      	double tmp;
      	if (exp(b) <= 2.0) {
      		tmp = 0.5;
      	} else {
      		tmp = 6.0 / (b * (b * b));
      	}
      	return tmp;
      }
      
      real(8) function code(a, b)
          real(8), intent (in) :: a
          real(8), intent (in) :: b
          real(8) :: tmp
          if (exp(b) <= 2.0d0) then
              tmp = 0.5d0
          else
              tmp = 6.0d0 / (b * (b * b))
          end if
          code = tmp
      end function
      
      public static double code(double a, double b) {
      	double tmp;
      	if (Math.exp(b) <= 2.0) {
      		tmp = 0.5;
      	} else {
      		tmp = 6.0 / (b * (b * b));
      	}
      	return tmp;
      }
      
      def code(a, b):
      	tmp = 0
      	if math.exp(b) <= 2.0:
      		tmp = 0.5
      	else:
      		tmp = 6.0 / (b * (b * b))
      	return tmp
      
      function code(a, b)
      	tmp = 0.0
      	if (exp(b) <= 2.0)
      		tmp = 0.5;
      	else
      		tmp = Float64(6.0 / Float64(b * Float64(b * b)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b)
      	tmp = 0.0;
      	if (exp(b) <= 2.0)
      		tmp = 0.5;
      	else
      		tmp = 6.0 / (b * (b * b));
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_] := If[LessEqual[N[Exp[b], $MachinePrecision], 2.0], 0.5, N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;e^{b} \leq 2:\\
      \;\;\;\;0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (exp.f64 b) < 2

        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.f6475.0

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

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

          \[\leadsto \color{blue}{\frac{1}{2}} \]
        7. Step-by-step derivation
          1. Simplified51.6%

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

          if 2 < (exp.f64 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. 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{6}{{b}^{3}}} \]
          10. Step-by-step derivation
            1. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{6}{{b}^{3}}} \]
            2. cube-multN/A

              \[\leadsto \frac{6}{\color{blue}{b \cdot \left(b \cdot b\right)}} \]
            3. unpow2N/A

              \[\leadsto \frac{6}{b \cdot \color{blue}{{b}^{2}}} \]
            4. lower-*.f64N/A

              \[\leadsto \frac{6}{\color{blue}{b \cdot {b}^{2}}} \]
            5. unpow2N/A

              \[\leadsto \frac{6}{b \cdot \color{blue}{\left(b \cdot b\right)}} \]
            6. lower-*.f6466.8

              \[\leadsto \frac{6}{b \cdot \color{blue}{\left(b \cdot b\right)}} \]
          11. Simplified66.8%

            \[\leadsto \color{blue}{\frac{6}{b \cdot \left(b \cdot b\right)}} \]
        8. Recombined 2 regimes into one program.
        9. Add Preprocessing

        Alternative 4: 79.3% accurate, 2.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 5.4 \cdot 10^{+52}:\\ \;\;\;\;e^{a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\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)}{-1}, 2\right)}\\ \end{array} \end{array} \]
        (FPCore (a b)
         :precision binary64
         (if (<= b 5.4e+52)
           (* (exp a) 0.5)
           (/
            1.0
            (fma
             b
             (/
              (fma
               (fma b 0.16666666666666666 0.5)
               (* b (* b (fma b 0.16666666666666666 0.5)))
               -1.0)
              -1.0)
             2.0))))
        double code(double a, double b) {
        	double tmp;
        	if (b <= 5.4e+52) {
        		tmp = exp(a) * 0.5;
        	} else {
        		tmp = 1.0 / fma(b, (fma(fma(b, 0.16666666666666666, 0.5), (b * (b * fma(b, 0.16666666666666666, 0.5))), -1.0) / -1.0), 2.0);
        	}
        	return tmp;
        }
        
        function code(a, b)
        	tmp = 0.0
        	if (b <= 5.4e+52)
        		tmp = Float64(exp(a) * 0.5);
        	else
        		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) / -1.0), 2.0));
        	end
        	return tmp
        end
        
        code[a_, b_] := If[LessEqual[b, 5.4e+52], N[(N[Exp[a], $MachinePrecision] * 0.5), $MachinePrecision], 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] / -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;b \leq 5.4 \cdot 10^{+52}:\\
        \;\;\;\;e^{a} \cdot 0.5\\
        
        \mathbf{else}:\\
        \;\;\;\;\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)}{-1}, 2\right)}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < 5.4e52

          1. Initial program 99.5%

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

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

              \[\leadsto \frac{e^{a}}{\color{blue}{2}} \]
            3. Step-by-step derivation
              1. Simplified73.6%

                \[\leadsto \frac{e^{a}}{\color{blue}{2}} \]
              2. Step-by-step derivation
                1. lift-exp.f64N/A

                  \[\leadsto \frac{\color{blue}{e^{a}}}{2} \]
                2. div-invN/A

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

                  \[\leadsto e^{a} \cdot \color{blue}{\frac{1}{2}} \]
                4. lower-*.f6473.6

                  \[\leadsto \color{blue}{e^{a} \cdot 0.5} \]
              3. Applied egg-rr73.6%

                \[\leadsto \color{blue}{e^{a} \cdot 0.5} \]

              if 5.4e52 < 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. 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right), 2\right)}} \]
              9. Step-by-step derivation
                1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{\mathsf{fma}\left(b, \frac{\mathsf{fma}\left(\mathsf{fma}\left(b, \frac{1}{6}, \frac{1}{2}\right), b \cdot \left(b \cdot \mathsf{fma}\left(b, \frac{1}{6}, \frac{1}{2}\right)\right), -1\right)}{b \cdot \mathsf{fma}\left(b, \frac{1}{6}, \frac{1}{2}\right) + \color{blue}{-1}}, 2\right)} \]
                16. lower-fma.f6427.4

                  \[\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)}{\color{blue}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), -1\right)}}, 2\right)} \]
              10. Applied egg-rr27.4%

                \[\leadsto \frac{1}{\mathsf{fma}\left(b, \color{blue}{\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)} \]
              11. Taylor expanded in b around 0

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

                  \[\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)}{\color{blue}{-1}}, 2\right)} \]
              13. Recombined 2 regimes into one program.
              14. Add Preprocessing

              Alternative 5: 62.7% accurate, 5.0× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.15 \cdot 10^{+34}:\\ \;\;\;\;0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\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)}{-1}, 2\right)}\\ \end{array} \end{array} \]
              (FPCore (a b)
               :precision binary64
               (if (<= a -1.15e+34)
                 (* 0.020833333333333332 (* b (* b b)))
                 (/
                  1.0
                  (fma
                   b
                   (/
                    (fma
                     (fma b 0.16666666666666666 0.5)
                     (* b (* b (fma b 0.16666666666666666 0.5)))
                     -1.0)
                    -1.0)
                   2.0))))
              double code(double a, double b) {
              	double tmp;
              	if (a <= -1.15e+34) {
              		tmp = 0.020833333333333332 * (b * (b * b));
              	} else {
              		tmp = 1.0 / fma(b, (fma(fma(b, 0.16666666666666666, 0.5), (b * (b * fma(b, 0.16666666666666666, 0.5))), -1.0) / -1.0), 2.0);
              	}
              	return tmp;
              }
              
              function code(a, b)
              	tmp = 0.0
              	if (a <= -1.15e+34)
              		tmp = Float64(0.020833333333333332 * Float64(b * Float64(b * b)));
              	else
              		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) / -1.0), 2.0));
              	end
              	return tmp
              end
              
              code[a_, b_] := If[LessEqual[a, -1.15e+34], N[(0.020833333333333332 * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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] / -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;a \leq -1.15 \cdot 10^{+34}:\\
              \;\;\;\;0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\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)}{-1}, 2\right)}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if a < -1.1499999999999999e34

                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.f6430.6

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(b, \frac{1}{48} \cdot \color{blue}{\left(b \cdot b\right)} + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right), \frac{1}{2}\right) \]
                  5. associate-*r*N/A

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot \frac{1}{48}}, \frac{-1}{4}\right), \frac{1}{2}\right) \]
                  10. lower-*.f642.7

                    \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot 0.020833333333333332}, -0.25\right), 0.5\right) \]
                8. Simplified2.7%

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

                  \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                10. Step-by-step derivation
                  1. lower-*.f64N/A

                    \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                  2. cube-multN/A

                    \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot \left(b \cdot b\right)\right)} \]
                  3. unpow2N/A

                    \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{{b}^{2}}\right) \]
                  4. lower-*.f64N/A

                    \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot {b}^{2}\right)} \]
                  5. unpow2N/A

                    \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                  6. lower-*.f6448.4

                    \[\leadsto 0.020833333333333332 \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                11. Simplified48.4%

                  \[\leadsto \color{blue}{0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)} \]

                if -1.1499999999999999e34 < 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.f6498.0

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right), 2\right)}} \]
                9. Step-by-step derivation
                  1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{\mathsf{fma}\left(b, \frac{\mathsf{fma}\left(\mathsf{fma}\left(b, \frac{1}{6}, \frac{1}{2}\right), b \cdot \left(b \cdot \mathsf{fma}\left(b, \frac{1}{6}, \frac{1}{2}\right)\right), -1\right)}{b \cdot \mathsf{fma}\left(b, \frac{1}{6}, \frac{1}{2}\right) + \color{blue}{-1}}, 2\right)} \]
                  16. lower-fma.f6450.3

                    \[\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)}{\color{blue}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), -1\right)}}, 2\right)} \]
                10. Applied egg-rr50.3%

                  \[\leadsto \frac{1}{\mathsf{fma}\left(b, \color{blue}{\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)} \]
                11. Taylor expanded in b around 0

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

                    \[\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)}{\color{blue}{-1}}, 2\right)} \]
                13. Recombined 2 regimes into one program.
                14. Add Preprocessing

                Alternative 6: 60.4% accurate, 8.7× speedup?

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

                  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.f6430.6

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(b, \frac{1}{48} \cdot \color{blue}{\left(b \cdot b\right)} + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right), \frac{1}{2}\right) \]
                    5. associate-*r*N/A

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot \frac{1}{48}}, \frac{-1}{4}\right), \frac{1}{2}\right) \]
                    10. lower-*.f642.7

                      \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot 0.020833333333333332}, -0.25\right), 0.5\right) \]
                  8. Simplified2.7%

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

                    \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                  10. Step-by-step derivation
                    1. lower-*.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                    2. cube-multN/A

                      \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot \left(b \cdot b\right)\right)} \]
                    3. unpow2N/A

                      \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{{b}^{2}}\right) \]
                    4. lower-*.f64N/A

                      \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot {b}^{2}\right)} \]
                    5. unpow2N/A

                      \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                    6. lower-*.f6448.4

                      \[\leadsto 0.020833333333333332 \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                  11. Simplified48.4%

                    \[\leadsto \color{blue}{0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)} \]

                  if -2.3999999999999999e30 < 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.f6498.0

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

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

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

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

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

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

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

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

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

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

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

                Alternative 7: 59.7% accurate, 9.3× speedup?

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

                  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.f6430.6

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(b, \frac{1}{48} \cdot \color{blue}{\left(b \cdot b\right)} + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right), \frac{1}{2}\right) \]
                    5. associate-*r*N/A

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot \frac{1}{48}}, \frac{-1}{4}\right), \frac{1}{2}\right) \]
                    10. lower-*.f642.7

                      \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot 0.020833333333333332}, -0.25\right), 0.5\right) \]
                  8. Simplified2.7%

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

                    \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                  10. Step-by-step derivation
                    1. lower-*.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                    2. cube-multN/A

                      \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot \left(b \cdot b\right)\right)} \]
                    3. unpow2N/A

                      \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{{b}^{2}}\right) \]
                    4. lower-*.f64N/A

                      \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot {b}^{2}\right)} \]
                    5. unpow2N/A

                      \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                    6. lower-*.f6448.4

                      \[\leadsto 0.020833333333333332 \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                  11. Simplified48.4%

                    \[\leadsto \color{blue}{0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)} \]

                  if -2.3999999999999999e30 < 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.f6498.0

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{\mathsf{fma}\left(b, \color{blue}{\frac{1}{6} \cdot {b}^{2}}, 2\right)} \]
                  10. Step-by-step derivation
                    1. lower-*.f64N/A

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

                      \[\leadsto \frac{1}{\mathsf{fma}\left(b, \frac{1}{6} \cdot \color{blue}{\left(b \cdot b\right)}, 2\right)} \]
                    3. lower-*.f6461.1

                      \[\leadsto \frac{1}{\mathsf{fma}\left(b, 0.16666666666666666 \cdot \color{blue}{\left(b \cdot b\right)}, 2\right)} \]
                  11. Simplified61.1%

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

                Alternative 8: 57.4% accurate, 10.5× speedup?

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

                  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.f6430.6

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(b, \frac{1}{48} \cdot \color{blue}{\left(b \cdot b\right)} + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right), \frac{1}{2}\right) \]
                    5. associate-*r*N/A

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot \frac{1}{48}}, \frac{-1}{4}\right), \frac{1}{2}\right) \]
                    10. lower-*.f642.7

                      \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot 0.020833333333333332}, -0.25\right), 0.5\right) \]
                  8. Simplified2.7%

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

                    \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                  10. Step-by-step derivation
                    1. lower-*.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                    2. cube-multN/A

                      \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot \left(b \cdot b\right)\right)} \]
                    3. unpow2N/A

                      \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{{b}^{2}}\right) \]
                    4. lower-*.f64N/A

                      \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot {b}^{2}\right)} \]
                    5. unpow2N/A

                      \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                    6. lower-*.f6448.4

                      \[\leadsto 0.020833333333333332 \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                  11. Simplified48.4%

                    \[\leadsto \color{blue}{0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)} \]

                  if -2.3999999999999999e30 < 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.f6498.0

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

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

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

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

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

                      \[\leadsto \frac{1}{\mathsf{fma}\left(b, \color{blue}{\frac{1}{2} \cdot b + 1}, 2\right)} \]
                    4. lower-fma.f6458.4

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

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

                Alternative 9: 53.5% accurate, 13.7× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 2:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{b \cdot b}\\ \end{array} \end{array} \]
                (FPCore (a b) :precision binary64 (if (<= b 2.0) 0.5 (/ 2.0 (* b b))))
                double code(double a, double b) {
                	double tmp;
                	if (b <= 2.0) {
                		tmp = 0.5;
                	} else {
                		tmp = 2.0 / (b * b);
                	}
                	return tmp;
                }
                
                real(8) function code(a, b)
                    real(8), intent (in) :: a
                    real(8), intent (in) :: b
                    real(8) :: tmp
                    if (b <= 2.0d0) then
                        tmp = 0.5d0
                    else
                        tmp = 2.0d0 / (b * b)
                    end if
                    code = tmp
                end function
                
                public static double code(double a, double b) {
                	double tmp;
                	if (b <= 2.0) {
                		tmp = 0.5;
                	} else {
                		tmp = 2.0 / (b * b);
                	}
                	return tmp;
                }
                
                def code(a, b):
                	tmp = 0
                	if b <= 2.0:
                		tmp = 0.5
                	else:
                		tmp = 2.0 / (b * b)
                	return tmp
                
                function code(a, b)
                	tmp = 0.0
                	if (b <= 2.0)
                		tmp = 0.5;
                	else
                		tmp = Float64(2.0 / Float64(b * b));
                	end
                	return tmp
                end
                
                function tmp_2 = code(a, b)
                	tmp = 0.0;
                	if (b <= 2.0)
                		tmp = 0.5;
                	else
                		tmp = 2.0 / (b * b);
                	end
                	tmp_2 = tmp;
                end
                
                code[a_, b_] := If[LessEqual[b, 2.0], 0.5, N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;b \leq 2:\\
                \;\;\;\;0.5\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{2}{b \cdot b}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if b < 2

                  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.f6475.0

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

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

                    \[\leadsto \color{blue}{\frac{1}{2}} \]
                  7. Step-by-step derivation
                    1. Simplified51.6%

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

                    if 2 < 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. 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. Simplified100.0%

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{1}{\color{blue}{{b}^{3} \cdot \left(\frac{1}{6} + \frac{1}{2} \cdot \frac{1}{b}\right)}} \]
                    10. Step-by-step derivation
                      1. cube-multN/A

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

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

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

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

                        \[\leadsto \frac{1}{b \cdot \left(\color{blue}{\left(b \cdot b\right)} \cdot \left(\frac{1}{6} + \frac{1}{2} \cdot \frac{1}{b}\right)\right)} \]
                      6. associate-*l*N/A

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

                        \[\leadsto \frac{1}{b \cdot \color{blue}{\left(b \cdot \left(b \cdot \left(\frac{1}{6} + \frac{1}{2} \cdot \frac{1}{b}\right)\right)\right)}} \]
                      8. distribute-rgt-inN/A

                        \[\leadsto \frac{1}{b \cdot \left(b \cdot \color{blue}{\left(\frac{1}{6} \cdot b + \left(\frac{1}{2} \cdot \frac{1}{b}\right) \cdot b\right)}\right)} \]
                      9. associate-*l*N/A

                        \[\leadsto \frac{1}{b \cdot \left(b \cdot \left(\frac{1}{6} \cdot b + \color{blue}{\frac{1}{2} \cdot \left(\frac{1}{b} \cdot b\right)}\right)\right)} \]
                      10. lft-mult-inverseN/A

                        \[\leadsto \frac{1}{b \cdot \left(b \cdot \left(\frac{1}{6} \cdot b + \frac{1}{2} \cdot \color{blue}{1}\right)\right)} \]
                      11. metadata-evalN/A

                        \[\leadsto \frac{1}{b \cdot \left(b \cdot \left(\frac{1}{6} \cdot b + \color{blue}{\frac{1}{2}}\right)\right)} \]
                      12. lower-fma.f6466.8

                        \[\leadsto \frac{1}{b \cdot \left(b \cdot \color{blue}{\mathsf{fma}\left(0.16666666666666666, b, 0.5\right)}\right)} \]
                    11. Simplified66.8%

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

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

                        \[\leadsto \color{blue}{\frac{2}{{b}^{2}}} \]
                      2. unpow2N/A

                        \[\leadsto \frac{2}{\color{blue}{b \cdot b}} \]
                      3. lower-*.f6452.6

                        \[\leadsto \frac{2}{\color{blue}{b \cdot b}} \]
                    14. Simplified52.6%

                      \[\leadsto \color{blue}{\frac{2}{b \cdot b}} \]
                  8. Recombined 2 regimes into one program.
                  9. Add Preprocessing

                  Alternative 10: 50.8% accurate, 14.3× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -61000000000:\\ \;\;\;\;0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.25, a, 0.5\right)\\ \end{array} \end{array} \]
                  (FPCore (a b)
                   :precision binary64
                   (if (<= a -61000000000.0)
                     (* 0.020833333333333332 (* b (* b b)))
                     (fma 0.25 a 0.5)))
                  double code(double a, double b) {
                  	double tmp;
                  	if (a <= -61000000000.0) {
                  		tmp = 0.020833333333333332 * (b * (b * b));
                  	} else {
                  		tmp = fma(0.25, a, 0.5);
                  	}
                  	return tmp;
                  }
                  
                  function code(a, b)
                  	tmp = 0.0
                  	if (a <= -61000000000.0)
                  		tmp = Float64(0.020833333333333332 * Float64(b * Float64(b * b)));
                  	else
                  		tmp = fma(0.25, a, 0.5);
                  	end
                  	return tmp
                  end
                  
                  code[a_, b_] := If[LessEqual[a, -61000000000.0], N[(0.020833333333333332 * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * a + 0.5), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;a \leq -61000000000:\\
                  \;\;\;\;0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\mathsf{fma}\left(0.25, a, 0.5\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if a < -6.1e10

                    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.f6431.4

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

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(b, \frac{1}{48} \cdot \color{blue}{\left(b \cdot b\right)} + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right), \frac{1}{2}\right) \]
                      5. associate-*r*N/A

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot \frac{1}{48}}, \frac{-1}{4}\right), \frac{1}{2}\right) \]
                      10. lower-*.f642.7

                        \[\leadsto \mathsf{fma}\left(b, \mathsf{fma}\left(b, \color{blue}{b \cdot 0.020833333333333332}, -0.25\right), 0.5\right) \]
                    8. Simplified2.7%

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

                      \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                    10. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \color{blue}{\frac{1}{48} \cdot {b}^{3}} \]
                      2. cube-multN/A

                        \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot \left(b \cdot b\right)\right)} \]
                      3. unpow2N/A

                        \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{{b}^{2}}\right) \]
                      4. lower-*.f64N/A

                        \[\leadsto \frac{1}{48} \cdot \color{blue}{\left(b \cdot {b}^{2}\right)} \]
                      5. unpow2N/A

                        \[\leadsto \frac{1}{48} \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                      6. lower-*.f6446.4

                        \[\leadsto 0.020833333333333332 \cdot \left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
                    11. Simplified46.4%

                      \[\leadsto \color{blue}{0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)} \]

                    if -6.1e10 < a

                    1. Initial program 99.5%

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

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

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

                          \[\leadsto \color{blue}{\frac{1}{4} \cdot a + \frac{1}{2}} \]
                        2. lower-fma.f6449.3

                          \[\leadsto \color{blue}{\mathsf{fma}\left(0.25, a, 0.5\right)} \]
                      4. Simplified49.3%

                        \[\leadsto \color{blue}{\mathsf{fma}\left(0.25, a, 0.5\right)} \]
                    5. Recombined 2 regimes into one program.
                    6. Add Preprocessing

                    Alternative 11: 39.7% 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.2

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

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

                      \[\leadsto \color{blue}{\frac{1}{2}} \]
                    7. Step-by-step derivation
                      1. Simplified37.6%

                        \[\leadsto \color{blue}{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 2024207 
                      (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))))