Quotient of sum of exps

Percentage Accurate: 99.0% → 98.6%
Time: 8.6s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 99.0% accurate, 1.0× speedup?

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

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

Alternative 1: 98.6% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -3000:\\ \;\;\;\;e^{a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{b} + 1}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -3000.0) (* (exp a) 0.5) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
	double tmp;
	if (a <= -3000.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 (a <= (-3000.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 (a <= -3000.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 a <= -3000.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 (a <= -3000.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 (a <= -3000.0)
		tmp = exp(a) * 0.5;
	else
		tmp = 1.0 / (exp(b) + 1.0);
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -3000.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}\;a \leq -3000:\\
\;\;\;\;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 a < -3e3

    1. Initial program 98.6%

      \[\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 -3e3 < a

        1. Initial program 98.4%

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

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

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

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

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

          \[\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}\;a \leq -3000:\\ \;\;\;\;e^{a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{b} + 1}\\ \end{array} \]
      6. Add Preprocessing

      Alternative 2: 99.0% accurate, 1.0× speedup?

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

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

      Alternative 3: 79.5% accurate, 2.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot \left(b \cdot b\right)\\ \mathbf{if}\;b \leq 2.8 \cdot 10^{+36}:\\ \;\;\;\;e^{a} \cdot 0.5\\ \mathbf{elif}\;b \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, b + -2, 4\right)}{\mathsf{fma}\left(b, \left(b \cdot b\right) \cdot t\_0, -64\right)} \cdot \mathsf{fma}\left(b, b \cdot b, -8\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{t\_0}\\ \end{array} \end{array} \]
      (FPCore (a b)
       :precision binary64
       (let* ((t_0 (* b (* b b))))
         (if (<= b 2.8e+36)
           (* (exp a) 0.5)
           (if (<= b 5.8e+102)
             (*
              (/ (fma b (+ b -2.0) 4.0) (fma b (* (* b b) t_0) -64.0))
              (fma b (* b b) -8.0))
             (/ 6.0 t_0)))))
      double code(double a, double b) {
      	double t_0 = b * (b * b);
      	double tmp;
      	if (b <= 2.8e+36) {
      		tmp = exp(a) * 0.5;
      	} else if (b <= 5.8e+102) {
      		tmp = (fma(b, (b + -2.0), 4.0) / fma(b, ((b * b) * t_0), -64.0)) * fma(b, (b * b), -8.0);
      	} else {
      		tmp = 6.0 / t_0;
      	}
      	return tmp;
      }
      
      function code(a, b)
      	t_0 = Float64(b * Float64(b * b))
      	tmp = 0.0
      	if (b <= 2.8e+36)
      		tmp = Float64(exp(a) * 0.5);
      	elseif (b <= 5.8e+102)
      		tmp = Float64(Float64(fma(b, Float64(b + -2.0), 4.0) / fma(b, Float64(Float64(b * b) * t_0), -64.0)) * fma(b, Float64(b * b), -8.0));
      	else
      		tmp = Float64(6.0 / t_0);
      	end
      	return tmp
      end
      
      code[a_, b_] := Block[{t$95$0 = N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 2.8e+36], N[(N[Exp[a], $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[b, 5.8e+102], N[(N[(N[(b * N[(b + -2.0), $MachinePrecision] + 4.0), $MachinePrecision] / N[(b * N[(N[(b * b), $MachinePrecision] * t$95$0), $MachinePrecision] + -64.0), $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * b), $MachinePrecision] + -8.0), $MachinePrecision]), $MachinePrecision], N[(6.0 / t$95$0), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := b \cdot \left(b \cdot b\right)\\
      \mathbf{if}\;b \leq 2.8 \cdot 10^{+36}:\\
      \;\;\;\;e^{a} \cdot 0.5\\
      
      \mathbf{elif}\;b \leq 5.8 \cdot 10^{+102}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(b, b + -2, 4\right)}{\mathsf{fma}\left(b, \left(b \cdot b\right) \cdot t\_0, -64\right)} \cdot \mathsf{fma}\left(b, b \cdot b, -8\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{6}{t\_0}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if b < 2.8000000000000001e36

        1. Initial program 97.9%

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

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

              \[\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-*.f6476.3

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

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

            if 2.8000000000000001e36 < b < 5.8000000000000005e102

            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}} \]
            7. Step-by-step derivation
              1. +-commutativeN/A

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

                \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
            8. Simplified3.7%

              \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
            9. Applied egg-rr83.0%

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, b + -2, 4\right)}{\mathsf{fma}\left(b, \left(b \cdot \left(b \cdot b\right)\right) \cdot \left(b \cdot b\right), -64\right)} \cdot \mathsf{fma}\left(b, b \cdot b, -8\right)} \]

            if 5.8000000000000005e102 < 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.f64100.0

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

              \[\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-*.f64100.0

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

              \[\leadsto \color{blue}{\frac{6}{b \cdot \left(b \cdot b\right)}} \]
          4. Recombined 3 regimes into one program.
          5. Final simplification80.8%

            \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 2.8 \cdot 10^{+36}:\\ \;\;\;\;e^{a} \cdot 0.5\\ \mathbf{elif}\;b \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, b + -2, 4\right)}{\mathsf{fma}\left(b, \left(b \cdot b\right) \cdot \left(b \cdot \left(b \cdot b\right)\right), -64\right)} \cdot \mathsf{fma}\left(b, b \cdot b, -8\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\ \end{array} \]
          6. Add Preprocessing

          Alternative 4: 64.4% accurate, 4.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot \left(b \cdot b\right)\\ \mathbf{if}\;b \leq 2.5 \cdot 10^{+36}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, a \cdot 0.0625, -0.25\right)}{\mathsf{fma}\left(a \cdot \left(a \cdot a\right), 0.015625, -0.125\right)} \cdot \mathsf{fma}\left(a, a \cdot 0.0625, \mathsf{fma}\left(a, 0.125, 0.25\right)\right)\\ \mathbf{elif}\;b \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, b + -2, 4\right)}{\mathsf{fma}\left(b, \left(b \cdot b\right) \cdot t\_0, -64\right)} \cdot \mathsf{fma}\left(b, b \cdot b, -8\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{t\_0}\\ \end{array} \end{array} \]
          (FPCore (a b)
           :precision binary64
           (let* ((t_0 (* b (* b b))))
             (if (<= b 2.5e+36)
               (*
                (/ (fma a (* a 0.0625) -0.25) (fma (* a (* a a)) 0.015625 -0.125))
                (fma a (* a 0.0625) (fma a 0.125 0.25)))
               (if (<= b 5.8e+102)
                 (*
                  (/ (fma b (+ b -2.0) 4.0) (fma b (* (* b b) t_0) -64.0))
                  (fma b (* b b) -8.0))
                 (/ 6.0 t_0)))))
          double code(double a, double b) {
          	double t_0 = b * (b * b);
          	double tmp;
          	if (b <= 2.5e+36) {
          		tmp = (fma(a, (a * 0.0625), -0.25) / fma((a * (a * a)), 0.015625, -0.125)) * fma(a, (a * 0.0625), fma(a, 0.125, 0.25));
          	} else if (b <= 5.8e+102) {
          		tmp = (fma(b, (b + -2.0), 4.0) / fma(b, ((b * b) * t_0), -64.0)) * fma(b, (b * b), -8.0);
          	} else {
          		tmp = 6.0 / t_0;
          	}
          	return tmp;
          }
          
          function code(a, b)
          	t_0 = Float64(b * Float64(b * b))
          	tmp = 0.0
          	if (b <= 2.5e+36)
          		tmp = Float64(Float64(fma(a, Float64(a * 0.0625), -0.25) / fma(Float64(a * Float64(a * a)), 0.015625, -0.125)) * fma(a, Float64(a * 0.0625), fma(a, 0.125, 0.25)));
          	elseif (b <= 5.8e+102)
          		tmp = Float64(Float64(fma(b, Float64(b + -2.0), 4.0) / fma(b, Float64(Float64(b * b) * t_0), -64.0)) * fma(b, Float64(b * b), -8.0));
          	else
          		tmp = Float64(6.0 / t_0);
          	end
          	return tmp
          end
          
          code[a_, b_] := Block[{t$95$0 = N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 2.5e+36], N[(N[(N[(a * N[(a * 0.0625), $MachinePrecision] + -0.25), $MachinePrecision] / N[(N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision] * 0.015625 + -0.125), $MachinePrecision]), $MachinePrecision] * N[(a * N[(a * 0.0625), $MachinePrecision] + N[(a * 0.125 + 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e+102], N[(N[(N[(b * N[(b + -2.0), $MachinePrecision] + 4.0), $MachinePrecision] / N[(b * N[(N[(b * b), $MachinePrecision] * t$95$0), $MachinePrecision] + -64.0), $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * b), $MachinePrecision] + -8.0), $MachinePrecision]), $MachinePrecision], N[(6.0 / t$95$0), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := b \cdot \left(b \cdot b\right)\\
          \mathbf{if}\;b \leq 2.5 \cdot 10^{+36}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(a, a \cdot 0.0625, -0.25\right)}{\mathsf{fma}\left(a \cdot \left(a \cdot a\right), 0.015625, -0.125\right)} \cdot \mathsf{fma}\left(a, a \cdot 0.0625, \mathsf{fma}\left(a, 0.125, 0.25\right)\right)\\
          
          \mathbf{elif}\;b \leq 5.8 \cdot 10^{+102}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(b, b + -2, 4\right)}{\mathsf{fma}\left(b, \left(b \cdot b\right) \cdot t\_0, -64\right)} \cdot \mathsf{fma}\left(b, b \cdot b, -8\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{6}{t\_0}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if b < 2.49999999999999988e36

            1. Initial program 97.9%

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

                \[\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. *-commutativeN/A

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(a, 0.25, 0.5\right)} \]
              5. Step-by-step derivation
                1. flip-+N/A

                  \[\leadsto \color{blue}{\frac{\left(a \cdot \frac{1}{4}\right) \cdot \left(a \cdot \frac{1}{4}\right) - \frac{1}{2} \cdot \frac{1}{2}}{a \cdot \frac{1}{4} - \frac{1}{2}}} \]
                2. flip3--N/A

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

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

                  \[\leadsto \color{blue}{\frac{\left(a \cdot \frac{1}{4}\right) \cdot \left(a \cdot \frac{1}{4}\right) - \frac{1}{2} \cdot \frac{1}{2}}{{\left(a \cdot \frac{1}{4}\right)}^{3} - {\frac{1}{2}}^{3}} \cdot \left(\left(a \cdot \frac{1}{4}\right) \cdot \left(a \cdot \frac{1}{4}\right) + \left(\frac{1}{2} \cdot \frac{1}{2} + \left(a \cdot \frac{1}{4}\right) \cdot \frac{1}{2}\right)\right)} \]
              6. Applied egg-rr53.2%

                \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, a \cdot 0.0625, -0.25\right)}{\mathsf{fma}\left(a \cdot \left(a \cdot a\right), 0.015625, -0.125\right)} \cdot \mathsf{fma}\left(a, a \cdot 0.0625, \mathsf{fma}\left(a, 0.125, 0.25\right)\right)} \]

              if 2.49999999999999988e36 < b < 5.8000000000000005e102

              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}} \]
              7. Step-by-step derivation
                1. +-commutativeN/A

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

                  \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
              8. Simplified3.7%

                \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
              9. Applied egg-rr83.0%

                \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, b + -2, 4\right)}{\mathsf{fma}\left(b, \left(b \cdot \left(b \cdot b\right)\right) \cdot \left(b \cdot b\right), -64\right)} \cdot \mathsf{fma}\left(b, b \cdot b, -8\right)} \]

              if 5.8000000000000005e102 < 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.f64100.0

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

                \[\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-*.f64100.0

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

                \[\leadsto \color{blue}{\frac{6}{b \cdot \left(b \cdot b\right)}} \]
            5. Recombined 3 regimes into one program.
            6. Final simplification63.2%

              \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 2.5 \cdot 10^{+36}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, a \cdot 0.0625, -0.25\right)}{\mathsf{fma}\left(a \cdot \left(a \cdot a\right), 0.015625, -0.125\right)} \cdot \mathsf{fma}\left(a, a \cdot 0.0625, \mathsf{fma}\left(a, 0.125, 0.25\right)\right)\\ \mathbf{elif}\;b \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, b + -2, 4\right)}{\mathsf{fma}\left(b, \left(b \cdot b\right) \cdot \left(b \cdot \left(b \cdot b\right)\right), -64\right)} \cdot \mathsf{fma}\left(b, b \cdot b, -8\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\ \end{array} \]
            7. Add Preprocessing

            Alternative 5: 63.4% accurate, 4.7× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 2 \cdot 10^{+36}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, a \cdot 0.0625, -0.25\right)}{\mathsf{fma}\left(a \cdot \left(a \cdot a\right), 0.015625, -0.125\right)} \cdot \mathsf{fma}\left(a, a \cdot 0.0625, \mathsf{fma}\left(a, 0.125, 0.25\right)\right)\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{+68}:\\ \;\;\;\;a \cdot \left(a \cdot 0.25\right)\\ \mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b \cdot b, b \cdot b, -16\right)} \cdot \mathsf{fma}\left(b, b, 4\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b, b, -4\right)}\\ \end{array} \end{array} \]
            (FPCore (a b)
             :precision binary64
             (if (<= b 2e+36)
               (*
                (/ (fma a (* a 0.0625) -0.25) (fma (* a (* a a)) 0.015625 -0.125))
                (fma a (* a 0.0625) (fma a 0.125 0.25)))
               (if (<= b 3.9e+68)
                 (* a (* a 0.25))
                 (if (<= b 1.35e+154)
                   (* (/ (+ b -2.0) (fma (* b b) (* b b) -16.0)) (fma b b 4.0))
                   (/ (+ b -2.0) (fma b b -4.0))))))
            double code(double a, double b) {
            	double tmp;
            	if (b <= 2e+36) {
            		tmp = (fma(a, (a * 0.0625), -0.25) / fma((a * (a * a)), 0.015625, -0.125)) * fma(a, (a * 0.0625), fma(a, 0.125, 0.25));
            	} else if (b <= 3.9e+68) {
            		tmp = a * (a * 0.25);
            	} else if (b <= 1.35e+154) {
            		tmp = ((b + -2.0) / fma((b * b), (b * b), -16.0)) * fma(b, b, 4.0);
            	} else {
            		tmp = (b + -2.0) / fma(b, b, -4.0);
            	}
            	return tmp;
            }
            
            function code(a, b)
            	tmp = 0.0
            	if (b <= 2e+36)
            		tmp = Float64(Float64(fma(a, Float64(a * 0.0625), -0.25) / fma(Float64(a * Float64(a * a)), 0.015625, -0.125)) * fma(a, Float64(a * 0.0625), fma(a, 0.125, 0.25)));
            	elseif (b <= 3.9e+68)
            		tmp = Float64(a * Float64(a * 0.25));
            	elseif (b <= 1.35e+154)
            		tmp = Float64(Float64(Float64(b + -2.0) / fma(Float64(b * b), Float64(b * b), -16.0)) * fma(b, b, 4.0));
            	else
            		tmp = Float64(Float64(b + -2.0) / fma(b, b, -4.0));
            	end
            	return tmp
            end
            
            code[a_, b_] := If[LessEqual[b, 2e+36], N[(N[(N[(a * N[(a * 0.0625), $MachinePrecision] + -0.25), $MachinePrecision] / N[(N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision] * 0.015625 + -0.125), $MachinePrecision]), $MachinePrecision] * N[(a * N[(a * 0.0625), $MachinePrecision] + N[(a * 0.125 + 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.9e+68], N[(a * N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(N[(N[(b + -2.0), $MachinePrecision] / N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision] + -16.0), $MachinePrecision]), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(b + -2.0), $MachinePrecision] / N[(b * b + -4.0), $MachinePrecision]), $MachinePrecision]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;b \leq 2 \cdot 10^{+36}:\\
            \;\;\;\;\frac{\mathsf{fma}\left(a, a \cdot 0.0625, -0.25\right)}{\mathsf{fma}\left(a \cdot \left(a \cdot a\right), 0.015625, -0.125\right)} \cdot \mathsf{fma}\left(a, a \cdot 0.0625, \mathsf{fma}\left(a, 0.125, 0.25\right)\right)\\
            
            \mathbf{elif}\;b \leq 3.9 \cdot 10^{+68}:\\
            \;\;\;\;a \cdot \left(a \cdot 0.25\right)\\
            
            \mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
            \;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b \cdot b, b \cdot b, -16\right)} \cdot \mathsf{fma}\left(b, b, 4\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b, b, -4\right)}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 4 regimes
            2. if b < 2.00000000000000008e36

              1. Initial program 97.9%

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

                  \[\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. *-commutativeN/A

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(a, 0.25, 0.5\right)} \]
                5. Step-by-step derivation
                  1. flip-+N/A

                    \[\leadsto \color{blue}{\frac{\left(a \cdot \frac{1}{4}\right) \cdot \left(a \cdot \frac{1}{4}\right) - \frac{1}{2} \cdot \frac{1}{2}}{a \cdot \frac{1}{4} - \frac{1}{2}}} \]
                  2. flip3--N/A

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

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

                    \[\leadsto \color{blue}{\frac{\left(a \cdot \frac{1}{4}\right) \cdot \left(a \cdot \frac{1}{4}\right) - \frac{1}{2} \cdot \frac{1}{2}}{{\left(a \cdot \frac{1}{4}\right)}^{3} - {\frac{1}{2}}^{3}} \cdot \left(\left(a \cdot \frac{1}{4}\right) \cdot \left(a \cdot \frac{1}{4}\right) + \left(\frac{1}{2} \cdot \frac{1}{2} + \left(a \cdot \frac{1}{4}\right) \cdot \frac{1}{2}\right)\right)} \]
                6. Applied egg-rr53.2%

                  \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, a \cdot 0.0625, -0.25\right)}{\mathsf{fma}\left(a \cdot \left(a \cdot a\right), 0.015625, -0.125\right)} \cdot \mathsf{fma}\left(a, a \cdot 0.0625, \mathsf{fma}\left(a, 0.125, 0.25\right)\right)} \]

                if 2.00000000000000008e36 < b < 3.90000000000000019e68

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\frac{1}{4} \cdot {a}^{2}} \]
                    6. Step-by-step derivation
                      1. unpow2N/A

                        \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(a \cdot a\right)} \]
                      2. associate-*r*N/A

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

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

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

                        \[\leadsto a \cdot \color{blue}{\left(a \cdot \frac{1}{4}\right)} \]
                      6. lower-*.f6452.5

                        \[\leadsto a \cdot \color{blue}{\left(a \cdot 0.25\right)} \]
                    7. Simplified52.5%

                      \[\leadsto \color{blue}{a \cdot \left(a \cdot 0.25\right)} \]

                    if 3.90000000000000019e68 < b < 1.35000000000000003e154

                    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}} \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                      2. lower-+.f644.1

                        \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                    8. Simplified4.1%

                      \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                    9. Step-by-step derivation
                      1. flip-+N/A

                        \[\leadsto \frac{1}{\color{blue}{\frac{b \cdot b - 2 \cdot 2}{b - 2}}} \]
                      2. clear-numN/A

                        \[\leadsto \color{blue}{\frac{b - 2}{b \cdot b - 2 \cdot 2}} \]
                      3. flip--N/A

                        \[\leadsto \frac{b - 2}{\color{blue}{\frac{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \left(2 \cdot 2\right) \cdot \left(2 \cdot 2\right)}{b \cdot b + 2 \cdot 2}}} \]
                      4. associate-/r/N/A

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

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

                        \[\leadsto \color{blue}{\frac{b - 2}{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \left(2 \cdot 2\right) \cdot \left(2 \cdot 2\right)}} \cdot \left(b \cdot b + 2 \cdot 2\right) \]
                      7. sub-negN/A

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

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

                        \[\leadsto \frac{b + \color{blue}{-2}}{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \left(2 \cdot 2\right) \cdot \left(2 \cdot 2\right)} \cdot \left(b \cdot b + 2 \cdot 2\right) \]
                      10. sub-negN/A

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{b + -2}{\mathsf{fma}\left(b \cdot b, b \cdot b, -16\right)} \cdot \color{blue}{\mathsf{fma}\left(b, b, 2 \cdot 2\right)} \]
                    10. Applied egg-rr88.0%

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

                    if 1.35000000000000003e154 < 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}} \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                      2. lower-+.f646.6

                        \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                    8. Simplified6.6%

                      \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                    9. Step-by-step derivation
                      1. flip-+N/A

                        \[\leadsto \frac{1}{\color{blue}{\frac{b \cdot b - 2 \cdot 2}{b - 2}}} \]
                      2. clear-numN/A

                        \[\leadsto \color{blue}{\frac{b - 2}{b \cdot b - 2 \cdot 2}} \]
                      3. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{b - 2}{b \cdot b - 2 \cdot 2}} \]
                      4. sub-negN/A

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

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

                        \[\leadsto \frac{b + \color{blue}{-2}}{b \cdot b - 2 \cdot 2} \]
                      7. sub-negN/A

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

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

                        \[\leadsto \frac{b + -2}{\mathsf{fma}\left(b, b, \mathsf{neg}\left(\color{blue}{4}\right)\right)} \]
                      10. metadata-eval100.0

                        \[\leadsto \frac{b + -2}{\mathsf{fma}\left(b, b, \color{blue}{-4}\right)} \]
                    10. Applied egg-rr100.0%

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

                  Alternative 6: 60.3% accurate, 5.2× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 5 \cdot 10^{+19}:\\ \;\;\;\;0.5\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{+68}:\\ \;\;\;\;a \cdot \left(a \cdot 0.25\right)\\ \mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b \cdot b, b \cdot b, -16\right)} \cdot \mathsf{fma}\left(b, b, 4\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b, b, -4\right)}\\ \end{array} \end{array} \]
                  (FPCore (a b)
                   :precision binary64
                   (if (<= b 5e+19)
                     0.5
                     (if (<= b 3.9e+68)
                       (* a (* a 0.25))
                       (if (<= b 1.35e+154)
                         (* (/ (+ b -2.0) (fma (* b b) (* b b) -16.0)) (fma b b 4.0))
                         (/ (+ b -2.0) (fma b b -4.0))))))
                  double code(double a, double b) {
                  	double tmp;
                  	if (b <= 5e+19) {
                  		tmp = 0.5;
                  	} else if (b <= 3.9e+68) {
                  		tmp = a * (a * 0.25);
                  	} else if (b <= 1.35e+154) {
                  		tmp = ((b + -2.0) / fma((b * b), (b * b), -16.0)) * fma(b, b, 4.0);
                  	} else {
                  		tmp = (b + -2.0) / fma(b, b, -4.0);
                  	}
                  	return tmp;
                  }
                  
                  function code(a, b)
                  	tmp = 0.0
                  	if (b <= 5e+19)
                  		tmp = 0.5;
                  	elseif (b <= 3.9e+68)
                  		tmp = Float64(a * Float64(a * 0.25));
                  	elseif (b <= 1.35e+154)
                  		tmp = Float64(Float64(Float64(b + -2.0) / fma(Float64(b * b), Float64(b * b), -16.0)) * fma(b, b, 4.0));
                  	else
                  		tmp = Float64(Float64(b + -2.0) / fma(b, b, -4.0));
                  	end
                  	return tmp
                  end
                  
                  code[a_, b_] := If[LessEqual[b, 5e+19], 0.5, If[LessEqual[b, 3.9e+68], N[(a * N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(N[(N[(b + -2.0), $MachinePrecision] / N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision] + -16.0), $MachinePrecision]), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(b + -2.0), $MachinePrecision] / N[(b * b + -4.0), $MachinePrecision]), $MachinePrecision]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;b \leq 5 \cdot 10^{+19}:\\
                  \;\;\;\;0.5\\
                  
                  \mathbf{elif}\;b \leq 3.9 \cdot 10^{+68}:\\
                  \;\;\;\;a \cdot \left(a \cdot 0.25\right)\\
                  
                  \mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
                  \;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b \cdot b, b \cdot b, -16\right)} \cdot \mathsf{fma}\left(b, b, 4\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b, b, -4\right)}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 4 regimes
                  2. if b < 5e19

                    1. Initial program 97.9%

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

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

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

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

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

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

                      if 5e19 < b < 3.90000000000000019e68

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \color{blue}{\frac{1}{4} \cdot {a}^{2}} \]
                          6. Step-by-step derivation
                            1. unpow2N/A

                              \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(a \cdot a\right)} \]
                            2. associate-*r*N/A

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

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

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

                              \[\leadsto a \cdot \color{blue}{\left(a \cdot \frac{1}{4}\right)} \]
                            6. lower-*.f6441.2

                              \[\leadsto a \cdot \color{blue}{\left(a \cdot 0.25\right)} \]
                          7. Simplified41.2%

                            \[\leadsto \color{blue}{a \cdot \left(a \cdot 0.25\right)} \]

                          if 3.90000000000000019e68 < b < 1.35000000000000003e154

                          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}} \]
                          7. Step-by-step derivation
                            1. +-commutativeN/A

                              \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                            2. lower-+.f644.1

                              \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                          8. Simplified4.1%

                            \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                          9. Step-by-step derivation
                            1. flip-+N/A

                              \[\leadsto \frac{1}{\color{blue}{\frac{b \cdot b - 2 \cdot 2}{b - 2}}} \]
                            2. clear-numN/A

                              \[\leadsto \color{blue}{\frac{b - 2}{b \cdot b - 2 \cdot 2}} \]
                            3. flip--N/A

                              \[\leadsto \frac{b - 2}{\color{blue}{\frac{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \left(2 \cdot 2\right) \cdot \left(2 \cdot 2\right)}{b \cdot b + 2 \cdot 2}}} \]
                            4. associate-/r/N/A

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

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

                              \[\leadsto \color{blue}{\frac{b - 2}{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \left(2 \cdot 2\right) \cdot \left(2 \cdot 2\right)}} \cdot \left(b \cdot b + 2 \cdot 2\right) \]
                            7. sub-negN/A

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

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

                              \[\leadsto \frac{b + \color{blue}{-2}}{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \left(2 \cdot 2\right) \cdot \left(2 \cdot 2\right)} \cdot \left(b \cdot b + 2 \cdot 2\right) \]
                            10. sub-negN/A

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{b + -2}{\mathsf{fma}\left(b \cdot b, b \cdot b, -16\right)} \cdot \color{blue}{\mathsf{fma}\left(b, b, 2 \cdot 2\right)} \]
                          10. Applied egg-rr88.0%

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

                          if 1.35000000000000003e154 < 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}} \]
                          7. Step-by-step derivation
                            1. +-commutativeN/A

                              \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                            2. lower-+.f646.6

                              \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                          8. Simplified6.6%

                            \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                          9. Step-by-step derivation
                            1. flip-+N/A

                              \[\leadsto \frac{1}{\color{blue}{\frac{b \cdot b - 2 \cdot 2}{b - 2}}} \]
                            2. clear-numN/A

                              \[\leadsto \color{blue}{\frac{b - 2}{b \cdot b - 2 \cdot 2}} \]
                            3. lower-/.f64N/A

                              \[\leadsto \color{blue}{\frac{b - 2}{b \cdot b - 2 \cdot 2}} \]
                            4. sub-negN/A

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

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

                              \[\leadsto \frac{b + \color{blue}{-2}}{b \cdot b - 2 \cdot 2} \]
                            7. sub-negN/A

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

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

                              \[\leadsto \frac{b + -2}{\mathsf{fma}\left(b, b, \mathsf{neg}\left(\color{blue}{4}\right)\right)} \]
                            10. metadata-eval100.0

                              \[\leadsto \frac{b + -2}{\mathsf{fma}\left(b, b, \color{blue}{-4}\right)} \]
                          10. Applied egg-rr100.0%

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

                        Alternative 7: 58.3% accurate, 9.3× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 5 \cdot 10^{+19}:\\ \;\;\;\;0.5\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{+68}:\\ \;\;\;\;a \cdot \left(a \cdot 0.25\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\ \end{array} \end{array} \]
                        (FPCore (a b)
                         :precision binary64
                         (if (<= b 5e+19)
                           0.5
                           (if (<= b 3.9e+68) (* a (* a 0.25)) (/ 6.0 (* b (* b b))))))
                        double code(double a, double b) {
                        	double tmp;
                        	if (b <= 5e+19) {
                        		tmp = 0.5;
                        	} else if (b <= 3.9e+68) {
                        		tmp = a * (a * 0.25);
                        	} 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 (b <= 5d+19) then
                                tmp = 0.5d0
                            else if (b <= 3.9d+68) then
                                tmp = a * (a * 0.25d0)
                            else
                                tmp = 6.0d0 / (b * (b * b))
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double a, double b) {
                        	double tmp;
                        	if (b <= 5e+19) {
                        		tmp = 0.5;
                        	} else if (b <= 3.9e+68) {
                        		tmp = a * (a * 0.25);
                        	} else {
                        		tmp = 6.0 / (b * (b * b));
                        	}
                        	return tmp;
                        }
                        
                        def code(a, b):
                        	tmp = 0
                        	if b <= 5e+19:
                        		tmp = 0.5
                        	elif b <= 3.9e+68:
                        		tmp = a * (a * 0.25)
                        	else:
                        		tmp = 6.0 / (b * (b * b))
                        	return tmp
                        
                        function code(a, b)
                        	tmp = 0.0
                        	if (b <= 5e+19)
                        		tmp = 0.5;
                        	elseif (b <= 3.9e+68)
                        		tmp = Float64(a * Float64(a * 0.25));
                        	else
                        		tmp = Float64(6.0 / Float64(b * Float64(b * b)));
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(a, b)
                        	tmp = 0.0;
                        	if (b <= 5e+19)
                        		tmp = 0.5;
                        	elseif (b <= 3.9e+68)
                        		tmp = a * (a * 0.25);
                        	else
                        		tmp = 6.0 / (b * (b * b));
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[a_, b_] := If[LessEqual[b, 5e+19], 0.5, If[LessEqual[b, 3.9e+68], N[(a * N[(a * 0.25), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;b \leq 5 \cdot 10^{+19}:\\
                        \;\;\;\;0.5\\
                        
                        \mathbf{elif}\;b \leq 3.9 \cdot 10^{+68}:\\
                        \;\;\;\;a \cdot \left(a \cdot 0.25\right)\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 3 regimes
                        2. if b < 5e19

                          1. Initial program 97.9%

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

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

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

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

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

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

                            if 5e19 < b < 3.90000000000000019e68

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \color{blue}{\frac{1}{4} \cdot {a}^{2}} \]
                                6. Step-by-step derivation
                                  1. unpow2N/A

                                    \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(a \cdot a\right)} \]
                                  2. associate-*r*N/A

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

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

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

                                    \[\leadsto a \cdot \color{blue}{\left(a \cdot \frac{1}{4}\right)} \]
                                  6. lower-*.f6441.2

                                    \[\leadsto a \cdot \color{blue}{\left(a \cdot 0.25\right)} \]
                                7. Simplified41.2%

                                  \[\leadsto \color{blue}{a \cdot \left(a \cdot 0.25\right)} \]

                                if 3.90000000000000019e68 < 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.f6487.2

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

                                  \[\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-*.f6487.2

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

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

                              Alternative 8: 55.9% accurate, 9.5× speedup?

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

                                1. Initial program 97.9%

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

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

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

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

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

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

                                  if 5e19 < b < 1.3499999999999999e139

                                  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. Simplified32.9%

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

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

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

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

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

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

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

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

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

                                        \[\leadsto \color{blue}{\frac{1}{4} \cdot {a}^{2}} \]
                                      6. Step-by-step derivation
                                        1. unpow2N/A

                                          \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(a \cdot a\right)} \]
                                        2. associate-*r*N/A

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

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

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

                                          \[\leadsto a \cdot \color{blue}{\left(a \cdot \frac{1}{4}\right)} \]
                                        6. lower-*.f6429.9

                                          \[\leadsto a \cdot \color{blue}{\left(a \cdot 0.25\right)} \]
                                      7. Simplified29.9%

                                        \[\leadsto \color{blue}{a \cdot \left(a \cdot 0.25\right)} \]

                                      if 1.3499999999999999e139 < 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}} \]
                                      7. Step-by-step derivation
                                        1. +-commutativeN/A

                                          \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                                        2. lower-+.f646.4

                                          \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                                      8. Simplified6.4%

                                        \[\leadsto \frac{1}{\color{blue}{b + 2}} \]
                                      9. Step-by-step derivation
                                        1. flip-+N/A

                                          \[\leadsto \frac{1}{\color{blue}{\frac{b \cdot b - 2 \cdot 2}{b - 2}}} \]
                                        2. clear-numN/A

                                          \[\leadsto \color{blue}{\frac{b - 2}{b \cdot b - 2 \cdot 2}} \]
                                        3. lower-/.f64N/A

                                          \[\leadsto \color{blue}{\frac{b - 2}{b \cdot b - 2 \cdot 2}} \]
                                        4. sub-negN/A

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

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

                                          \[\leadsto \frac{b + \color{blue}{-2}}{b \cdot b - 2 \cdot 2} \]
                                        7. sub-negN/A

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

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

                                          \[\leadsto \frac{b + -2}{\mathsf{fma}\left(b, b, \mathsf{neg}\left(\color{blue}{4}\right)\right)} \]
                                        10. metadata-eval92.5

                                          \[\leadsto \frac{b + -2}{\mathsf{fma}\left(b, b, \color{blue}{-4}\right)} \]
                                      10. Applied egg-rr92.5%

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

                                    Alternative 9: 47.4% accurate, 18.5× speedup?

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

                                      1. Initial program 97.9%

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

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

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

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

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

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

                                        if 5e19 < b

                                        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. Simplified33.4%

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \color{blue}{\frac{1}{4} \cdot {a}^{2}} \]
                                            6. Step-by-step derivation
                                              1. unpow2N/A

                                                \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(a \cdot a\right)} \]
                                              2. associate-*r*N/A

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

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

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

                                                \[\leadsto a \cdot \color{blue}{\left(a \cdot \frac{1}{4}\right)} \]
                                              6. lower-*.f6438.3

                                                \[\leadsto a \cdot \color{blue}{\left(a \cdot 0.25\right)} \]
                                            7. Simplified38.3%

                                              \[\leadsto \color{blue}{a \cdot \left(a \cdot 0.25\right)} \]
                                          4. Recombined 2 regimes into one program.
                                          5. Add Preprocessing

                                          Alternative 10: 38.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 98.4%

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

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

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

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

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

                                            \[\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. Simplified38.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 2024208 
                                            (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))))