Quotient of sum of exps

Percentage Accurate: 98.9% → 98.5%
Time: 7.7s
Alternatives: 20
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 20 alternatives:

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

Initial Program: 98.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.5% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, b, 1\right), b, \color{blue}{1 + e^{a}}\right)} \]
      8. lower-exp.f6498.0

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

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

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

      if 0.999999997999999946 < (exp.f64 a)

      1. Initial program 99.4%

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;e^{a} \leq 0.999999998:\\ \;\;\;\;\frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, e^{a}\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + e^{b}}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 98.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\color{blue}{e^{b} + e^{a}}} \cdot \left(\mathsf{neg}\left(e^{a}\right)\right) \]
      12. lower-neg.f6498.8

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

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

      \[\leadsto \frac{--1}{e^{a} + e^{b}} \cdot e^{a} \]
    6. Add Preprocessing

    Alternative 3: 98.9% accurate, 1.0× speedup?

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

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

    Alternative 4: 98.4% accurate, 1.4× speedup?

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

      1. Initial program 97.1%

        \[\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}{\left(1 + b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)\right)}} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{1}{\frac{e^{a} + \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{6}, b, \frac{1}{2}\right), b, 1\right), b, 1\right)}{e^{a}}}} \]
        4. lower-/.f6498.2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 0.999999997999999946 < (exp.f64 a)

      1. Initial program 99.4%

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

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

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

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

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

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

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

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

    Alternative 5: 98.4% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1 + e^{b}\right)} \end{array} \]
    (FPCore (a b)
     :precision binary64
     (/ (exp a) (fma (fma 0.5 a 1.0) a (+ 1.0 (exp b)))))
    double code(double a, double b) {
    	return exp(a) / fma(fma(0.5, a, 1.0), a, (1.0 + exp(b)));
    }
    
    function code(a, b)
    	return Float64(exp(a) / fma(fma(0.5, a, 1.0), a, Float64(1.0 + exp(b))))
    end
    
    code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1 + e^{b}\right)}
    \end{array}
    
    Derivation
    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, a, 1\right), a, \color{blue}{e^{b} + 1}\right)} \]
      9. lower-exp.f6498.7

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

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

      \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1 + e^{b}\right)} \]
    7. Add Preprocessing

    Alternative 6: 98.5% accurate, 1.4× speedup?

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

      1. Initial program 96.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}{\left(1 + b\right)}} \]
      4. Step-by-step derivation
        1. lower-+.f64100.0

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

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

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

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

        if 0.0 < (exp.f64 a)

        1. Initial program 99.4%

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

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

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

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

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

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

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

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

      Alternative 7: 57.7% accurate, 2.4× speedup?

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

        1. Initial program 98.3%

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

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

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

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

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

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

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

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

            \[\leadsto 0.5 \]

          if 2 < (exp.f64 b)

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 8: 93.1% accurate, 2.5× speedup?

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

                1. Initial program 96.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}{\left(1 + b\right)}} \]
                4. Step-by-step derivation
                  1. lower-+.f64100.0

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

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

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

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

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

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

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

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

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

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

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

                  if -1.8999999999999999e154 < a < -6.1999999999999996e96

                  1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if -6.1999999999999996e96 < a

                      1. Initial program 99.5%

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\frac{1}{e^{b} + 1}} \]
                    7. Recombined 3 regimes into one program.
                    8. Final simplification92.3%

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

                    Alternative 9: 70.8% accurate, 4.9× speedup?

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

                      1. Initial program 100.0%

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

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

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

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

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

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

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

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

                          \[\leadsto 0.5 \]

                        if -6.8e8 < b < 720

                        1. Initial program 97.8%

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, b, 1\right), b, \color{blue}{1 + e^{a}}\right)} \]
                          8. lower-exp.f6498.9

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

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

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

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

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

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

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

                          if 720 < b < 2.65000000000000003e101

                          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}}{\color{blue}{1 + \left(e^{a} + b \cdot \left(1 + \frac{1}{2} \cdot b\right)\right)}} \]
                          4. Step-by-step derivation
                            1. associate-+r+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              if 2.65000000000000003e101 < b

                              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  Alternative 10: 68.1% accurate, 6.2× speedup?

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

                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                        \[\leadsto 0.5 \]

                                      if -6.8e8 < b < 1.05000000000000009e34

                                      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}}{\color{blue}{1 + \left(e^{a} + b \cdot \left(1 + \frac{1}{2} \cdot b\right)\right)}} \]
                                      4. Step-by-step derivation
                                        1. associate-+r+N/A

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

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

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

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

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

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

                                          \[\leadsto \frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2}, b, 1\right), b, \color{blue}{1 + e^{a}}\right)} \]
                                        8. lower-exp.f6495.7

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

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

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

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

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

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

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

                                        if 1.05000000000000009e34 < b

                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            Alternative 11: 67.9% accurate, 7.0× speedup?

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

                                              1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                  \[\leadsto 0.5 \]

                                                if -6.8e8 < b < 1.05000000000000009e34

                                                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}{\left(1 + b\right)}} \]
                                                4. Step-by-step derivation
                                                  1. lower-+.f6495.6

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

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

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

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

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

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

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

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

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

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

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

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

                                                if 1.05000000000000009e34 < b

                                                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    Alternative 12: 67.9% accurate, 7.5× speedup?

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

                                                      1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                          \[\leadsto 0.5 \]

                                                        if -6.8e8 < b < 7.4999999999999999e51

                                                        1. Initial program 98.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}{\left(1 + b\right)}} \]
                                                        4. Step-by-step derivation
                                                          1. lower-+.f6494.4

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

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

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

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

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

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

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

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

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

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

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

                                                          if 7.4999999999999999e51 < b

                                                          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                              Alternative 13: 58.3% accurate, 8.7× speedup?

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

                                                                1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                    \[\leadsto 0.5 \]

                                                                  if -1e8 < b

                                                                  1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

                                                                  Alternative 14: 58.0% accurate, 9.0× speedup?

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

                                                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                        \[\leadsto 0.5 \]

                                                                      if -1e8 < b

                                                                      1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

                                                                        Alternative 15: 57.6% accurate, 9.0× speedup?

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

                                                                          1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                              \[\leadsto 0.5 \]

                                                                            if -1e8 < b

                                                                            1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \frac{1}{\mathsf{fma}\left({b}^{2} \cdot \left(\frac{1}{6} + \frac{1}{2} \cdot \frac{1}{b}\right), b, 2\right)} \]
                                                                              3. Step-by-step derivation
                                                                                1. Applied rewrites67.7%

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

                                                                              Alternative 16: 57.6% accurate, 9.3× speedup?

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

                                                                                1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                                    \[\leadsto 0.5 \]

                                                                                  if -1e8 < b

                                                                                  1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

                                                                                    Alternative 17: 57.7% accurate, 9.3× speedup?

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

                                                                                      1. Initial program 98.3%

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

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

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

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

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

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

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

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

                                                                                          \[\leadsto 0.5 \]

                                                                                        if 1.6000000000000001 < b

                                                                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

                                                                                          Alternative 18: 53.8% accurate, 10.5× speedup?

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

                                                                                            1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                                                \[\leadsto 0.5 \]

                                                                                              if -1e8 < b

                                                                                              1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

                                                                                              Alternative 19: 53.3% accurate, 10.9× speedup?

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

                                                                                                1. Initial program 98.3%

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

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

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

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

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

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

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

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

                                                                                                    \[\leadsto 0.5 \]

                                                                                                  if 1.25 < b

                                                                                                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                      Alternative 20: 39.7% accurate, 315.0× speedup?

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

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

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

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

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

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

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

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

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

                                                                                                          \[\leadsto 0.5 \]
                                                                                                        2. Add Preprocessing

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

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

                                                                                                        Reproduce

                                                                                                        ?
                                                                                                        herbie shell --seed 2024276 
                                                                                                        (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))))