Quotient of sum of exps

Percentage Accurate: 98.9% → 100.0%
Time: 3.2s
Alternatives: 12
Speedup: 0.9×

Specification

?
\[\frac{e^{a}}{e^{a} + e^{b}} \]
(FPCore (a b)
  :precision binary64
  (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b)
use fmin_fmax_functions
    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]
\frac{e^{a}}{e^{a} + e^{b}}

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 12 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?

\[\frac{e^{a}}{e^{a} + e^{b}} \]
(FPCore (a b)
  :precision binary64
  (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b)
use fmin_fmax_functions
    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]
\frac{e^{a}}{e^{a} + e^{b}}

Alternative 1: 100.0% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \frac{1}{e^{-a}}\\ \frac{t\_0}{t\_0 + e^{b}} \end{array} \]
(FPCore (a b)
  :precision binary64
  (let* ((t_0 (/ 1.0 (exp (- a))))) (/ t_0 (+ t_0 (exp b)))))
double code(double a, double b) {
	double t_0 = 1.0 / exp(-a);
	return t_0 / (t_0 + exp(b));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_0
    t_0 = 1.0d0 / exp(-a)
    code = t_0 / (t_0 + exp(b))
end function
public static double code(double a, double b) {
	double t_0 = 1.0 / Math.exp(-a);
	return t_0 / (t_0 + Math.exp(b));
}
def code(a, b):
	t_0 = 1.0 / math.exp(-a)
	return t_0 / (t_0 + math.exp(b))
function code(a, b)
	t_0 = Float64(1.0 / exp(Float64(-a)))
	return Float64(t_0 / Float64(t_0 + exp(b)))
end
function tmp = code(a, b)
	t_0 = 1.0 / exp(-a);
	tmp = t_0 / (t_0 + exp(b));
end
code[a_, b_] := Block[{t$95$0 = N[(1.0 / N[Exp[(-a)], $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 / N[(t$95$0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{1}{e^{-a}}\\
\frac{t\_0}{t\_0 + e^{b}}
\end{array}
Derivation
  1. Initial program 98.9%

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

      \[\leadsto \frac{\color{blue}{e^{a}}}{e^{a} + e^{b}} \]
    2. sinh-+-cosh-revN/A

      \[\leadsto \frac{\color{blue}{\cosh a + \sinh a}}{e^{a} + e^{b}} \]
    3. add-flipN/A

      \[\leadsto \frac{\color{blue}{\cosh a - \left(\mathsf{neg}\left(\sinh a\right)\right)}}{e^{a} + e^{b}} \]
    4. cosh-neg-revN/A

      \[\leadsto \frac{\color{blue}{\cosh \left(\mathsf{neg}\left(a\right)\right)} - \left(\mathsf{neg}\left(\sinh a\right)\right)}{e^{a} + e^{b}} \]
    5. sinh-neg-revN/A

      \[\leadsto \frac{\cosh \left(\mathsf{neg}\left(a\right)\right) - \color{blue}{\sinh \left(\mathsf{neg}\left(a\right)\right)}}{e^{a} + e^{b}} \]
    6. sinh---cosh-revN/A

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{e^{-a}}}{\color{blue}{\left(\cosh a + \sinh a\right)} + e^{b}} \]
    3. add-flipN/A

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

      \[\leadsto \frac{\frac{1}{e^{-a}}}{\left(\color{blue}{\cosh \left(\mathsf{neg}\left(a\right)\right)} - \left(\mathsf{neg}\left(\sinh a\right)\right)\right) + e^{b}} \]
    5. sinh-neg-revN/A

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

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

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

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

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

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

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

Alternative 2: 98.9% accurate, 2.6× speedup?

\[\frac{1}{e^{\left(-a\right) + b} + 1} \]
(FPCore (a b)
  :precision binary64
  (/ 1.0 (+ (exp (+ (- a) b)) 1.0)))
double code(double a, double b) {
	return 1.0 / (exp((-a + b)) + 1.0);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = 1.0d0 / (exp((-a + b)) + 1.0d0)
end function
public static double code(double a, double b) {
	return 1.0 / (Math.exp((-a + b)) + 1.0);
}
def code(a, b):
	return 1.0 / (math.exp((-a + b)) + 1.0)
function code(a, b)
	return Float64(1.0 / Float64(exp(Float64(Float64(-a) + b)) + 1.0))
end
function tmp = code(a, b)
	tmp = 1.0 / (exp((-a + b)) + 1.0);
end
code[a_, b_] := N[(1.0 / N[(N[Exp[N[((-a) + b), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\frac{1}{e^{\left(-a\right) + b} + 1}
Derivation
  1. Initial program 98.9%

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

      \[\leadsto \frac{\color{blue}{e^{a}}}{e^{a} + e^{b}} \]
    2. sinh-+-cosh-revN/A

      \[\leadsto \frac{\color{blue}{\cosh a + \sinh a}}{e^{a} + e^{b}} \]
    3. add-flipN/A

      \[\leadsto \frac{\color{blue}{\cosh a - \left(\mathsf{neg}\left(\sinh a\right)\right)}}{e^{a} + e^{b}} \]
    4. cosh-neg-revN/A

      \[\leadsto \frac{\color{blue}{\cosh \left(\mathsf{neg}\left(a\right)\right)} - \left(\mathsf{neg}\left(\sinh a\right)\right)}{e^{a} + e^{b}} \]
    5. sinh-neg-revN/A

      \[\leadsto \frac{\cosh \left(\mathsf{neg}\left(a\right)\right) - \color{blue}{\sinh \left(\mathsf{neg}\left(a\right)\right)}}{e^{a} + e^{b}} \]
    6. sinh---cosh-revN/A

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{e^{-a}}}{\color{blue}{\left(\cosh a + \sinh a\right)} + e^{b}} \]
    3. add-flipN/A

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

      \[\leadsto \frac{\frac{1}{e^{-a}}}{\left(\color{blue}{\cosh \left(\mathsf{neg}\left(a\right)\right)} - \left(\mathsf{neg}\left(\sinh a\right)\right)\right) + e^{b}} \]
    5. sinh-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{e^{-a} \cdot e^{b} + \frac{1}{\color{blue}{e^{a}}} \cdot e^{a}} \]
    18. inv-powN/A

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

    \[\leadsto \color{blue}{\frac{1}{e^{\left(-a\right) + b} + 1}} \]
  8. Add Preprocessing

Alternative 3: 98.4% accurate, 2.6× speedup?

\[\begin{array}{l} \mathbf{if}\;a \leq -2.1 \cdot 10^{-5}:\\ \;\;\;\;\frac{1}{e^{-a} + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + e^{b}}\\ \end{array} \]
(FPCore (a b)
  :precision binary64
  (if (<= a -2.1e-5)
  (/ 1.0 (+ (exp (- a)) 1.0))
  (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
	double tmp;
	if (a <= -2.1e-5) {
		tmp = 1.0 / (exp(-a) + 1.0);
	} else {
		tmp = 1.0 / (1.0 + exp(b));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (a <= (-2.1d-5)) then
        tmp = 1.0d0 / (exp(-a) + 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 (a <= -2.1e-5) {
		tmp = 1.0 / (Math.exp(-a) + 1.0);
	} else {
		tmp = 1.0 / (1.0 + Math.exp(b));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -2.1e-5:
		tmp = 1.0 / (math.exp(-a) + 1.0)
	else:
		tmp = 1.0 / (1.0 + math.exp(b))
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -2.1e-5)
		tmp = Float64(1.0 / Float64(exp(Float64(-a)) + 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 (a <= -2.1e-5)
		tmp = 1.0 / (exp(-a) + 1.0);
	else
		tmp = 1.0 / (1.0 + exp(b));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -2.1e-5], N[(1.0 / N[(N[Exp[(-a)], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;a \leq -2.1 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{e^{-a} + 1}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.0999999999999999e-5

    1. Initial program 98.9%

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

        \[\leadsto \frac{\color{blue}{e^{a}}}{e^{a} + e^{b}} \]
      2. sinh-+-cosh-revN/A

        \[\leadsto \frac{\color{blue}{\cosh a + \sinh a}}{e^{a} + e^{b}} \]
      3. add-flipN/A

        \[\leadsto \frac{\color{blue}{\cosh a - \left(\mathsf{neg}\left(\sinh a\right)\right)}}{e^{a} + e^{b}} \]
      4. cosh-neg-revN/A

        \[\leadsto \frac{\color{blue}{\cosh \left(\mathsf{neg}\left(a\right)\right)} - \left(\mathsf{neg}\left(\sinh a\right)\right)}{e^{a} + e^{b}} \]
      5. sinh-neg-revN/A

        \[\leadsto \frac{\cosh \left(\mathsf{neg}\left(a\right)\right) - \color{blue}{\sinh \left(\mathsf{neg}\left(a\right)\right)}}{e^{a} + e^{b}} \]
      6. sinh---cosh-revN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{e^{-a}}}{\color{blue}{\left(\cosh a + \sinh a\right)} + e^{b}} \]
      3. add-flipN/A

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

        \[\leadsto \frac{\frac{1}{e^{-a}}}{\left(\color{blue}{\cosh \left(\mathsf{neg}\left(a\right)\right)} - \left(\mathsf{neg}\left(\sinh a\right)\right)\right) + e^{b}} \]
      5. sinh-neg-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{e^{-a} \cdot e^{b} + \frac{1}{\color{blue}{e^{a}}} \cdot e^{a}} \]
      18. inv-powN/A

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

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

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

        \[\leadsto \frac{1}{e^{\mathsf{neg}\left(a\right)} + 1} \]
      2. lower-neg.f6466.7%

        \[\leadsto \frac{1}{e^{-a} + 1} \]
    10. Applied rewrites66.7%

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

    if -2.0999999999999999e-5 < a

    1. Initial program 98.9%

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

      \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
    3. Step-by-step derivation
      1. Applied rewrites80.6%

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

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

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

      Alternative 4: 98.1% accurate, 2.6× speedup?

      \[\begin{array}{l} \mathbf{if}\;a \leq -2.1 \cdot 10^{-5}:\\ \;\;\;\;\frac{e^{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + e^{b}}\\ \end{array} \]
      (FPCore (a b)
        :precision binary64
        (if (<= a -2.1e-5) (/ (exp a) 2.0) (/ 1.0 (+ 1.0 (exp b)))))
      double code(double a, double b) {
      	double tmp;
      	if (a <= -2.1e-5) {
      		tmp = exp(a) / 2.0;
      	} else {
      		tmp = 1.0 / (1.0 + exp(b));
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(a, b)
      use fmin_fmax_functions
          real(8), intent (in) :: a
          real(8), intent (in) :: b
          real(8) :: tmp
          if (a <= (-2.1d-5)) then
              tmp = exp(a) / 2.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 (a <= -2.1e-5) {
      		tmp = Math.exp(a) / 2.0;
      	} else {
      		tmp = 1.0 / (1.0 + Math.exp(b));
      	}
      	return tmp;
      }
      
      def code(a, b):
      	tmp = 0
      	if a <= -2.1e-5:
      		tmp = math.exp(a) / 2.0
      	else:
      		tmp = 1.0 / (1.0 + math.exp(b))
      	return tmp
      
      function code(a, b)
      	tmp = 0.0
      	if (a <= -2.1e-5)
      		tmp = Float64(exp(a) / 2.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 (a <= -2.1e-5)
      		tmp = exp(a) / 2.0;
      	else
      		tmp = 1.0 / (1.0 + exp(b));
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_] := If[LessEqual[a, -2.1e-5], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      \mathbf{if}\;a \leq -2.1 \cdot 10^{-5}:\\
      \;\;\;\;\frac{e^{a}}{2}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{1}{1 + e^{b}}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if a < -2.0999999999999999e-5

        1. Initial program 98.9%

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

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

            \[\leadsto \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
          2. lower-exp.f6466.1%

            \[\leadsto \frac{e^{a}}{1 + e^{a}} \]
        4. Applied rewrites66.1%

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

          \[\leadsto \frac{e^{a}}{2} \]
        6. Step-by-step derivation
          1. Applied rewrites65.1%

            \[\leadsto \frac{e^{a}}{2} \]

          if -2.0999999999999999e-5 < a

          1. Initial program 98.9%

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

            \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
          3. Step-by-step derivation
            1. Applied rewrites80.6%

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

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

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

            Alternative 5: 79.7% accurate, 2.7× speedup?

            \[\begin{array}{l} t_0 := \left(\left(0.16666666666666666 \cdot b - -0.5\right) \cdot b\right) \cdot b\\ \mathbf{if}\;b \leq 4.5 \cdot 10^{+29}:\\ \;\;\;\;\frac{e^{a}}{2}\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\frac{1}{1 + \left(1 + \frac{b \cdot b - t\_0 \cdot t\_0}{b - t\_0}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\ \end{array} \]
            (FPCore (a b)
              :precision binary64
              (let* ((t_0 (* (* (- (* 0.16666666666666666 b) -0.5) b) b)))
              (if (<= b 4.5e+29)
                (/ (exp a) 2.0)
                (if (<= b 1.02e+103)
                  (/ 1.0 (+ 1.0 (+ 1.0 (/ (- (* b b) (* t_0 t_0)) (- b t_0)))))
                  (/
                   1.0
                   (+
                    1.0
                    (+
                     1.0
                     (* b (+ 1.0 (* b (+ 0.5 (* 0.16666666666666666 b))))))))))))
            double code(double a, double b) {
            	double t_0 = (((0.16666666666666666 * b) - -0.5) * b) * b;
            	double tmp;
            	if (b <= 4.5e+29) {
            		tmp = exp(a) / 2.0;
            	} else if (b <= 1.02e+103) {
            		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
            	} else {
            		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(a, b)
            use fmin_fmax_functions
                real(8), intent (in) :: a
                real(8), intent (in) :: b
                real(8) :: t_0
                real(8) :: tmp
                t_0 = (((0.16666666666666666d0 * b) - (-0.5d0)) * b) * b
                if (b <= 4.5d+29) then
                    tmp = exp(a) / 2.0d0
                else if (b <= 1.02d+103) then
                    tmp = 1.0d0 / (1.0d0 + (1.0d0 + (((b * b) - (t_0 * t_0)) / (b - t_0))))
                else
                    tmp = 1.0d0 / (1.0d0 + (1.0d0 + (b * (1.0d0 + (b * (0.5d0 + (0.16666666666666666d0 * b)))))))
                end if
                code = tmp
            end function
            
            public static double code(double a, double b) {
            	double t_0 = (((0.16666666666666666 * b) - -0.5) * b) * b;
            	double tmp;
            	if (b <= 4.5e+29) {
            		tmp = Math.exp(a) / 2.0;
            	} else if (b <= 1.02e+103) {
            		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
            	} else {
            		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
            	}
            	return tmp;
            }
            
            def code(a, b):
            	t_0 = (((0.16666666666666666 * b) - -0.5) * b) * b
            	tmp = 0
            	if b <= 4.5e+29:
            		tmp = math.exp(a) / 2.0
            	elif b <= 1.02e+103:
            		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))))
            	else:
            		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))))
            	return tmp
            
            function code(a, b)
            	t_0 = Float64(Float64(Float64(Float64(0.16666666666666666 * b) - -0.5) * b) * b)
            	tmp = 0.0
            	if (b <= 4.5e+29)
            		tmp = Float64(exp(a) / 2.0);
            	elseif (b <= 1.02e+103)
            		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(Float64(Float64(b * b) - Float64(t_0 * t_0)) / Float64(b - t_0)))));
            	else
            		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(0.16666666666666666 * b))))))));
            	end
            	return tmp
            end
            
            function tmp_2 = code(a, b)
            	t_0 = (((0.16666666666666666 * b) - -0.5) * b) * b;
            	tmp = 0.0;
            	if (b <= 4.5e+29)
            		tmp = exp(a) / 2.0;
            	elseif (b <= 1.02e+103)
            		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
            	else
            		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
            	end
            	tmp_2 = tmp;
            end
            
            code[a_, b_] := Block[{t$95$0 = N[(N[(N[(N[(0.16666666666666666 * b), $MachinePrecision] - -0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, 4.5e+29], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[b, 1.02e+103], N[(1.0 / N[(1.0 + N[(1.0 + N[(N[(N[(b * b), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[(1.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(0.16666666666666666 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
            
            \begin{array}{l}
            t_0 := \left(\left(0.16666666666666666 \cdot b - -0.5\right) \cdot b\right) \cdot b\\
            \mathbf{if}\;b \leq 4.5 \cdot 10^{+29}:\\
            \;\;\;\;\frac{e^{a}}{2}\\
            
            \mathbf{elif}\;b \leq 1.02 \cdot 10^{+103}:\\
            \;\;\;\;\frac{1}{1 + \left(1 + \frac{b \cdot b - t\_0 \cdot t\_0}{b - t\_0}\right)}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if b < 4.5000000000000002e29

              1. Initial program 98.9%

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

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

                  \[\leadsto \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
                2. lower-exp.f6466.1%

                  \[\leadsto \frac{e^{a}}{1 + e^{a}} \]
              4. Applied rewrites66.1%

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

                \[\leadsto \frac{e^{a}}{2} \]
              6. Step-by-step derivation
                1. Applied rewrites65.1%

                  \[\leadsto \frac{e^{a}}{2} \]

                if 4.5000000000000002e29 < b < 1.0199999999999999e103

                1. Initial program 98.9%

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

                  \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                3. Step-by-step derivation
                  1. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot \color{blue}{b}\right)\right)\right)} \]
                    4. Applied rewrites55.7%

                      \[\leadsto \frac{1}{1 + \color{blue}{\left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}} \]
                    5. Step-by-step derivation
                      1. lift-*.f64N/A

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

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

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

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

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

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

                        \[\leadsto \frac{1}{1 + \left(1 + \frac{\left(1 \cdot b\right) \cdot \left(1 \cdot b\right) - \left(\left(b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right) \cdot b\right) \cdot \left(\left(b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right) \cdot b\right)}{\color{blue}{b \cdot 1 - b \cdot \left(b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}}\right)} \]
                    6. Applied rewrites40.3%

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

                    if 1.0199999999999999e103 < b

                    1. Initial program 98.9%

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

                      \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                    3. Step-by-step derivation
                      1. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot \color{blue}{b}\right)\right)\right)} \]
                        4. Applied rewrites55.7%

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

                      Alternative 6: 62.5% accurate, 2.8× speedup?

                      \[\begin{array}{l} t_0 := \left(\left(0.16666666666666666 \cdot b - -0.5\right) \cdot b\right) \cdot b\\ \mathbf{if}\;b \leq -9.8 \cdot 10^{-6}:\\ \;\;\;\;0.5\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\frac{1}{1 + \left(1 + \frac{b \cdot b - t\_0 \cdot t\_0}{b - t\_0}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\ \end{array} \]
                      (FPCore (a b)
                        :precision binary64
                        (let* ((t_0 (* (* (- (* 0.16666666666666666 b) -0.5) b) b)))
                        (if (<= b -9.8e-6)
                          0.5
                          (if (<= b 1.02e+103)
                            (/ 1.0 (+ 1.0 (+ 1.0 (/ (- (* b b) (* t_0 t_0)) (- b t_0)))))
                            (/
                             1.0
                             (+
                              1.0
                              (+
                               1.0
                               (* b (+ 1.0 (* b (+ 0.5 (* 0.16666666666666666 b))))))))))))
                      double code(double a, double b) {
                      	double t_0 = (((0.16666666666666666 * b) - -0.5) * b) * b;
                      	double tmp;
                      	if (b <= -9.8e-6) {
                      		tmp = 0.5;
                      	} else if (b <= 1.02e+103) {
                      		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
                      	} else {
                      		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(a, b)
                      use fmin_fmax_functions
                          real(8), intent (in) :: a
                          real(8), intent (in) :: b
                          real(8) :: t_0
                          real(8) :: tmp
                          t_0 = (((0.16666666666666666d0 * b) - (-0.5d0)) * b) * b
                          if (b <= (-9.8d-6)) then
                              tmp = 0.5d0
                          else if (b <= 1.02d+103) then
                              tmp = 1.0d0 / (1.0d0 + (1.0d0 + (((b * b) - (t_0 * t_0)) / (b - t_0))))
                          else
                              tmp = 1.0d0 / (1.0d0 + (1.0d0 + (b * (1.0d0 + (b * (0.5d0 + (0.16666666666666666d0 * b)))))))
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double a, double b) {
                      	double t_0 = (((0.16666666666666666 * b) - -0.5) * b) * b;
                      	double tmp;
                      	if (b <= -9.8e-6) {
                      		tmp = 0.5;
                      	} else if (b <= 1.02e+103) {
                      		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
                      	} else {
                      		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                      	}
                      	return tmp;
                      }
                      
                      def code(a, b):
                      	t_0 = (((0.16666666666666666 * b) - -0.5) * b) * b
                      	tmp = 0
                      	if b <= -9.8e-6:
                      		tmp = 0.5
                      	elif b <= 1.02e+103:
                      		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))))
                      	else:
                      		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))))
                      	return tmp
                      
                      function code(a, b)
                      	t_0 = Float64(Float64(Float64(Float64(0.16666666666666666 * b) - -0.5) * b) * b)
                      	tmp = 0.0
                      	if (b <= -9.8e-6)
                      		tmp = 0.5;
                      	elseif (b <= 1.02e+103)
                      		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(Float64(Float64(b * b) - Float64(t_0 * t_0)) / Float64(b - t_0)))));
                      	else
                      		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(0.16666666666666666 * b))))))));
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(a, b)
                      	t_0 = (((0.16666666666666666 * b) - -0.5) * b) * b;
                      	tmp = 0.0;
                      	if (b <= -9.8e-6)
                      		tmp = 0.5;
                      	elseif (b <= 1.02e+103)
                      		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
                      	else
                      		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[a_, b_] := Block[{t$95$0 = N[(N[(N[(N[(0.16666666666666666 * b), $MachinePrecision] - -0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -9.8e-6], 0.5, If[LessEqual[b, 1.02e+103], N[(1.0 / N[(1.0 + N[(1.0 + N[(N[(N[(b * b), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[(1.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(0.16666666666666666 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
                      
                      \begin{array}{l}
                      t_0 := \left(\left(0.16666666666666666 \cdot b - -0.5\right) \cdot b\right) \cdot b\\
                      \mathbf{if}\;b \leq -9.8 \cdot 10^{-6}:\\
                      \;\;\;\;0.5\\
                      
                      \mathbf{elif}\;b \leq 1.02 \cdot 10^{+103}:\\
                      \;\;\;\;\frac{1}{1 + \left(1 + \frac{b \cdot b - t\_0 \cdot t\_0}{b - t\_0}\right)}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 3 regimes
                      2. if b < -9.7999999999999993e-6

                        1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
                          12. lower-exp.f6464.0%

                            \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}} \]
                        4. Applied rewrites64.0%

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

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

                            \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{b} \]
                          2. lower-*.f6437.4%

                            \[\leadsto 0.5 + -0.25 \cdot b \]
                        7. Applied rewrites37.4%

                          \[\leadsto 0.5 + \color{blue}{-0.25 \cdot b} \]
                        8. Taylor expanded in b around 0

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

                            \[\leadsto 0.5 \]

                          if -9.7999999999999993e-6 < b < 1.0199999999999999e103

                          1. Initial program 98.9%

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

                            \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                          3. Step-by-step derivation
                            1. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot \color{blue}{b}\right)\right)\right)} \]
                              4. Applied rewrites55.7%

                                \[\leadsto \frac{1}{1 + \color{blue}{\left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}} \]
                              5. Step-by-step derivation
                                1. lift-*.f64N/A

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

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

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

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

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

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

                                  \[\leadsto \frac{1}{1 + \left(1 + \frac{\left(1 \cdot b\right) \cdot \left(1 \cdot b\right) - \left(\left(b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right) \cdot b\right) \cdot \left(\left(b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right) \cdot b\right)}{\color{blue}{b \cdot 1 - b \cdot \left(b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}}\right)} \]
                              6. Applied rewrites40.3%

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

                              if 1.0199999999999999e103 < b

                              1. Initial program 98.9%

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

                                \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                              3. Step-by-step derivation
                                1. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot \color{blue}{b}\right)\right)\right)} \]
                                  4. Applied rewrites55.7%

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

                                Alternative 7: 60.5% accurate, 3.1× speedup?

                                \[\begin{array}{l} t_0 := \left(0.16666666666666666 \cdot b - -0.5\right) \cdot b\\ \mathbf{if}\;b \leq -9.8 \cdot 10^{-6}:\\ \;\;\;\;0.5\\ \mathbf{elif}\;b \leq 2 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \frac{t\_0 \cdot t\_0 - 1 \cdot 1}{t\_0 - 1}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + 0.5 \cdot b\right)\right)}\\ \end{array} \]
                                (FPCore (a b)
                                  :precision binary64
                                  (let* ((t_0 (* (- (* 0.16666666666666666 b) -0.5) b)))
                                  (if (<= b -9.8e-6)
                                    0.5
                                    (if (<= b 2e+154)
                                      (/
                                       1.0
                                       (+
                                        1.0
                                        (+ 1.0 (* b (/ (- (* t_0 t_0) (* 1.0 1.0)) (- t_0 1.0))))))
                                      (/ 1.0 (+ 1.0 (+ 1.0 (* b (+ 1.0 (* 0.5 b))))))))))
                                double code(double a, double b) {
                                	double t_0 = ((0.16666666666666666 * b) - -0.5) * b;
                                	double tmp;
                                	if (b <= -9.8e-6) {
                                		tmp = 0.5;
                                	} else if (b <= 2e+154) {
                                		tmp = 1.0 / (1.0 + (1.0 + (b * (((t_0 * t_0) - (1.0 * 1.0)) / (t_0 - 1.0)))));
                                	} else {
                                		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (0.5 * b)))));
                                	}
                                	return tmp;
                                }
                                
                                module fmin_fmax_functions
                                    implicit none
                                    private
                                    public fmax
                                    public fmin
                                
                                    interface fmax
                                        module procedure fmax88
                                        module procedure fmax44
                                        module procedure fmax84
                                        module procedure fmax48
                                    end interface
                                    interface fmin
                                        module procedure fmin88
                                        module procedure fmin44
                                        module procedure fmin84
                                        module procedure fmin48
                                    end interface
                                contains
                                    real(8) function fmax88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmax44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmax84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmax48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmin44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmin48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                    end function
                                end module
                                
                                real(8) function code(a, b)
                                use fmin_fmax_functions
                                    real(8), intent (in) :: a
                                    real(8), intent (in) :: b
                                    real(8) :: t_0
                                    real(8) :: tmp
                                    t_0 = ((0.16666666666666666d0 * b) - (-0.5d0)) * b
                                    if (b <= (-9.8d-6)) then
                                        tmp = 0.5d0
                                    else if (b <= 2d+154) then
                                        tmp = 1.0d0 / (1.0d0 + (1.0d0 + (b * (((t_0 * t_0) - (1.0d0 * 1.0d0)) / (t_0 - 1.0d0)))))
                                    else
                                        tmp = 1.0d0 / (1.0d0 + (1.0d0 + (b * (1.0d0 + (0.5d0 * b)))))
                                    end if
                                    code = tmp
                                end function
                                
                                public static double code(double a, double b) {
                                	double t_0 = ((0.16666666666666666 * b) - -0.5) * b;
                                	double tmp;
                                	if (b <= -9.8e-6) {
                                		tmp = 0.5;
                                	} else if (b <= 2e+154) {
                                		tmp = 1.0 / (1.0 + (1.0 + (b * (((t_0 * t_0) - (1.0 * 1.0)) / (t_0 - 1.0)))));
                                	} else {
                                		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (0.5 * b)))));
                                	}
                                	return tmp;
                                }
                                
                                def code(a, b):
                                	t_0 = ((0.16666666666666666 * b) - -0.5) * b
                                	tmp = 0
                                	if b <= -9.8e-6:
                                		tmp = 0.5
                                	elif b <= 2e+154:
                                		tmp = 1.0 / (1.0 + (1.0 + (b * (((t_0 * t_0) - (1.0 * 1.0)) / (t_0 - 1.0)))))
                                	else:
                                		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (0.5 * b)))))
                                	return tmp
                                
                                function code(a, b)
                                	t_0 = Float64(Float64(Float64(0.16666666666666666 * b) - -0.5) * b)
                                	tmp = 0.0
                                	if (b <= -9.8e-6)
                                		tmp = 0.5;
                                	elseif (b <= 2e+154)
                                		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(b * Float64(Float64(Float64(t_0 * t_0) - Float64(1.0 * 1.0)) / Float64(t_0 - 1.0))))));
                                	else
                                		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(b * Float64(1.0 + Float64(0.5 * b))))));
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(a, b)
                                	t_0 = ((0.16666666666666666 * b) - -0.5) * b;
                                	tmp = 0.0;
                                	if (b <= -9.8e-6)
                                		tmp = 0.5;
                                	elseif (b <= 2e+154)
                                		tmp = 1.0 / (1.0 + (1.0 + (b * (((t_0 * t_0) - (1.0 * 1.0)) / (t_0 - 1.0)))));
                                	else
                                		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (0.5 * b)))));
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[a_, b_] := Block[{t$95$0 = N[(N[(N[(0.16666666666666666 * b), $MachinePrecision] - -0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -9.8e-6], 0.5, If[LessEqual[b, 2e+154], N[(1.0 / N[(1.0 + N[(1.0 + N[(b * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[(1.0 + N[(b * N[(1.0 + N[(0.5 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
                                
                                \begin{array}{l}
                                t_0 := \left(0.16666666666666666 \cdot b - -0.5\right) \cdot b\\
                                \mathbf{if}\;b \leq -9.8 \cdot 10^{-6}:\\
                                \;\;\;\;0.5\\
                                
                                \mathbf{elif}\;b \leq 2 \cdot 10^{+154}:\\
                                \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \frac{t\_0 \cdot t\_0 - 1 \cdot 1}{t\_0 - 1}\right)}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + 0.5 \cdot b\right)\right)}\\
                                
                                
                                \end{array}
                                
                                Derivation
                                1. Split input into 3 regimes
                                2. if b < -9.7999999999999993e-6

                                  1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
                                    12. lower-exp.f6464.0%

                                      \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}} \]
                                  4. Applied rewrites64.0%

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

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

                                      \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{b} \]
                                    2. lower-*.f6437.4%

                                      \[\leadsto 0.5 + -0.25 \cdot b \]
                                  7. Applied rewrites37.4%

                                    \[\leadsto 0.5 + \color{blue}{-0.25 \cdot b} \]
                                  8. Taylor expanded in b around 0

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

                                      \[\leadsto 0.5 \]

                                    if -9.7999999999999993e-6 < b < 2.0000000000000001e154

                                    1. Initial program 98.9%

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

                                      \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot \color{blue}{b}\right)\right)\right)} \]
                                        4. Applied rewrites55.7%

                                          \[\leadsto \frac{1}{1 + \color{blue}{\left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}} \]
                                        5. Step-by-step derivation
                                          1. lift-+.f64N/A

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

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

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

                                            \[\leadsto \frac{1}{1 + \left(1 + b \cdot \frac{\left(b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right) \cdot \left(b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right) - 1 \cdot 1}{\color{blue}{b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right) - 1}}\right)} \]
                                        6. Applied rewrites43.2%

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

                                        if 2.0000000000000001e154 < b

                                        1. Initial program 98.9%

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

                                          \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites80.6%

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

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

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

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

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

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

                                                \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + \color{blue}{\frac{1}{2} \cdot b}\right)\right)} \]
                                              4. lower-*.f6451.5%

                                                \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + 0.5 \cdot \color{blue}{b}\right)\right)} \]
                                            4. Applied rewrites51.5%

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

                                          Alternative 8: 60.5% accurate, 3.6× speedup?

                                          \[\begin{array}{l} t_0 := \left(b \cdot 0.5\right) \cdot b\\ \mathbf{if}\;b \leq -9.8 \cdot 10^{-6}:\\ \;\;\;\;0.5\\ \mathbf{elif}\;b \leq 10^{+103}:\\ \;\;\;\;\frac{1}{1 + \left(1 + \frac{b \cdot b - t\_0 \cdot t\_0}{b - t\_0}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\ \end{array} \]
                                          (FPCore (a b)
                                            :precision binary64
                                            (let* ((t_0 (* (* b 0.5) b)))
                                            (if (<= b -9.8e-6)
                                              0.5
                                              (if (<= b 1e+103)
                                                (/ 1.0 (+ 1.0 (+ 1.0 (/ (- (* b b) (* t_0 t_0)) (- b t_0)))))
                                                (/
                                                 1.0
                                                 (+
                                                  1.0
                                                  (+
                                                   1.0
                                                   (* b (+ 1.0 (* b (+ 0.5 (* 0.16666666666666666 b))))))))))))
                                          double code(double a, double b) {
                                          	double t_0 = (b * 0.5) * b;
                                          	double tmp;
                                          	if (b <= -9.8e-6) {
                                          		tmp = 0.5;
                                          	} else if (b <= 1e+103) {
                                          		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
                                          	} else {
                                          		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          module fmin_fmax_functions
                                              implicit none
                                              private
                                              public fmax
                                              public fmin
                                          
                                              interface fmax
                                                  module procedure fmax88
                                                  module procedure fmax44
                                                  module procedure fmax84
                                                  module procedure fmax48
                                              end interface
                                              interface fmin
                                                  module procedure fmin88
                                                  module procedure fmin44
                                                  module procedure fmin84
                                                  module procedure fmin48
                                              end interface
                                          contains
                                              real(8) function fmax88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmax44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmax84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmax48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmin44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmin48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                              end function
                                          end module
                                          
                                          real(8) function code(a, b)
                                          use fmin_fmax_functions
                                              real(8), intent (in) :: a
                                              real(8), intent (in) :: b
                                              real(8) :: t_0
                                              real(8) :: tmp
                                              t_0 = (b * 0.5d0) * b
                                              if (b <= (-9.8d-6)) then
                                                  tmp = 0.5d0
                                              else if (b <= 1d+103) then
                                                  tmp = 1.0d0 / (1.0d0 + (1.0d0 + (((b * b) - (t_0 * t_0)) / (b - t_0))))
                                              else
                                                  tmp = 1.0d0 / (1.0d0 + (1.0d0 + (b * (1.0d0 + (b * (0.5d0 + (0.16666666666666666d0 * b)))))))
                                              end if
                                              code = tmp
                                          end function
                                          
                                          public static double code(double a, double b) {
                                          	double t_0 = (b * 0.5) * b;
                                          	double tmp;
                                          	if (b <= -9.8e-6) {
                                          		tmp = 0.5;
                                          	} else if (b <= 1e+103) {
                                          		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
                                          	} else {
                                          		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          def code(a, b):
                                          	t_0 = (b * 0.5) * b
                                          	tmp = 0
                                          	if b <= -9.8e-6:
                                          		tmp = 0.5
                                          	elif b <= 1e+103:
                                          		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))))
                                          	else:
                                          		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))))
                                          	return tmp
                                          
                                          function code(a, b)
                                          	t_0 = Float64(Float64(b * 0.5) * b)
                                          	tmp = 0.0
                                          	if (b <= -9.8e-6)
                                          		tmp = 0.5;
                                          	elseif (b <= 1e+103)
                                          		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(Float64(Float64(b * b) - Float64(t_0 * t_0)) / Float64(b - t_0)))));
                                          	else
                                          		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(0.16666666666666666 * b))))))));
                                          	end
                                          	return tmp
                                          end
                                          
                                          function tmp_2 = code(a, b)
                                          	t_0 = (b * 0.5) * b;
                                          	tmp = 0.0;
                                          	if (b <= -9.8e-6)
                                          		tmp = 0.5;
                                          	elseif (b <= 1e+103)
                                          		tmp = 1.0 / (1.0 + (1.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))));
                                          	else
                                          		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                          	end
                                          	tmp_2 = tmp;
                                          end
                                          
                                          code[a_, b_] := Block[{t$95$0 = N[(N[(b * 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -9.8e-6], 0.5, If[LessEqual[b, 1e+103], N[(1.0 / N[(1.0 + N[(1.0 + N[(N[(N[(b * b), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[(1.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(0.16666666666666666 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
                                          
                                          \begin{array}{l}
                                          t_0 := \left(b \cdot 0.5\right) \cdot b\\
                                          \mathbf{if}\;b \leq -9.8 \cdot 10^{-6}:\\
                                          \;\;\;\;0.5\\
                                          
                                          \mathbf{elif}\;b \leq 10^{+103}:\\
                                          \;\;\;\;\frac{1}{1 + \left(1 + \frac{b \cdot b - t\_0 \cdot t\_0}{b - t\_0}\right)}\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\
                                          
                                          
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 3 regimes
                                          2. if b < -9.7999999999999993e-6

                                            1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
                                              12. lower-exp.f6464.0%

                                                \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}} \]
                                            4. Applied rewrites64.0%

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

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

                                                \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{b} \]
                                              2. lower-*.f6437.4%

                                                \[\leadsto 0.5 + -0.25 \cdot b \]
                                            7. Applied rewrites37.4%

                                              \[\leadsto 0.5 + \color{blue}{-0.25 \cdot b} \]
                                            8. Taylor expanded in b around 0

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

                                                \[\leadsto 0.5 \]

                                              if -9.7999999999999993e-6 < b < 1e103

                                              1. Initial program 98.9%

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

                                                \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites80.6%

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

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

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

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

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

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

                                                      \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + \color{blue}{\frac{1}{2} \cdot b}\right)\right)} \]
                                                    4. lower-*.f6451.5%

                                                      \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + 0.5 \cdot \color{blue}{b}\right)\right)} \]
                                                  4. Applied rewrites51.5%

                                                    \[\leadsto \frac{1}{1 + \color{blue}{\left(1 + b \cdot \left(1 + 0.5 \cdot b\right)\right)}} \]
                                                  5. Step-by-step derivation
                                                    1. lift-*.f64N/A

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

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

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

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

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

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

                                                      \[\leadsto \frac{1}{1 + \left(1 + \frac{\left(1 \cdot b\right) \cdot \left(1 \cdot b\right) - \left(\left(\frac{1}{2} \cdot b\right) \cdot b\right) \cdot \left(\left(\frac{1}{2} \cdot b\right) \cdot b\right)}{\color{blue}{b \cdot 1 - b \cdot \left(\frac{1}{2} \cdot b\right)}}\right)} \]
                                                  6. Applied rewrites43.3%

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

                                                  if 1e103 < b

                                                  1. Initial program 98.9%

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

                                                    \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

                                                          \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot \color{blue}{b}\right)\right)\right)} \]
                                                      4. Applied rewrites55.7%

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

                                                    Alternative 9: 58.9% accurate, 0.9× speedup?

                                                    \[\begin{array}{l} \mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.9999930272201875:\\ \;\;\;\;\frac{1 + a}{\left(1 + a\right) + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
                                                    (FPCore (a b)
                                                      :precision binary64
                                                      (if (<= (/ (exp a) (+ (exp a) (exp b))) 0.9999930272201875)
                                                      (/
                                                       (+ 1.0 a)
                                                       (+
                                                        (+ 1.0 a)
                                                        (+ 1.0 (* b (+ 1.0 (* b (+ 0.5 (* 0.16666666666666666 b))))))))
                                                      0.5))
                                                    double code(double a, double b) {
                                                    	double tmp;
                                                    	if ((exp(a) / (exp(a) + exp(b))) <= 0.9999930272201875) {
                                                    		tmp = (1.0 + a) / ((1.0 + a) + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                                    	} else {
                                                    		tmp = 0.5;
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    module fmin_fmax_functions
                                                        implicit none
                                                        private
                                                        public fmax
                                                        public fmin
                                                    
                                                        interface fmax
                                                            module procedure fmax88
                                                            module procedure fmax44
                                                            module procedure fmax84
                                                            module procedure fmax48
                                                        end interface
                                                        interface fmin
                                                            module procedure fmin88
                                                            module procedure fmin44
                                                            module procedure fmin84
                                                            module procedure fmin48
                                                        end interface
                                                    contains
                                                        real(8) function fmax88(x, y) result (res)
                                                            real(8), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                        end function
                                                        real(4) function fmax44(x, y) result (res)
                                                            real(4), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmax84(x, y) result(res)
                                                            real(8), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmax48(x, y) result(res)
                                                            real(4), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin88(x, y) result (res)
                                                            real(8), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                        end function
                                                        real(4) function fmin44(x, y) result (res)
                                                            real(4), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin84(x, y) result(res)
                                                            real(8), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin48(x, y) result(res)
                                                            real(4), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                        end function
                                                    end module
                                                    
                                                    real(8) function code(a, b)
                                                    use fmin_fmax_functions
                                                        real(8), intent (in) :: a
                                                        real(8), intent (in) :: b
                                                        real(8) :: tmp
                                                        if ((exp(a) / (exp(a) + exp(b))) <= 0.9999930272201875d0) then
                                                            tmp = (1.0d0 + a) / ((1.0d0 + a) + (1.0d0 + (b * (1.0d0 + (b * (0.5d0 + (0.16666666666666666d0 * b)))))))
                                                        else
                                                            tmp = 0.5d0
                                                        end if
                                                        code = tmp
                                                    end function
                                                    
                                                    public static double code(double a, double b) {
                                                    	double tmp;
                                                    	if ((Math.exp(a) / (Math.exp(a) + Math.exp(b))) <= 0.9999930272201875) {
                                                    		tmp = (1.0 + a) / ((1.0 + a) + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                                    	} else {
                                                    		tmp = 0.5;
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    def code(a, b):
                                                    	tmp = 0
                                                    	if (math.exp(a) / (math.exp(a) + math.exp(b))) <= 0.9999930272201875:
                                                    		tmp = (1.0 + a) / ((1.0 + a) + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))))
                                                    	else:
                                                    		tmp = 0.5
                                                    	return tmp
                                                    
                                                    function code(a, b)
                                                    	tmp = 0.0
                                                    	if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.9999930272201875)
                                                    		tmp = Float64(Float64(1.0 + a) / Float64(Float64(1.0 + a) + Float64(1.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(0.16666666666666666 * b))))))));
                                                    	else
                                                    		tmp = 0.5;
                                                    	end
                                                    	return tmp
                                                    end
                                                    
                                                    function tmp_2 = code(a, b)
                                                    	tmp = 0.0;
                                                    	if ((exp(a) / (exp(a) + exp(b))) <= 0.9999930272201875)
                                                    		tmp = (1.0 + a) / ((1.0 + a) + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                                    	else
                                                    		tmp = 0.5;
                                                    	end
                                                    	tmp_2 = tmp;
                                                    end
                                                    
                                                    code[a_, b_] := If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.9999930272201875], N[(N[(1.0 + a), $MachinePrecision] / N[(N[(1.0 + a), $MachinePrecision] + N[(1.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(0.16666666666666666 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5]
                                                    
                                                    \begin{array}{l}
                                                    \mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.9999930272201875:\\
                                                    \;\;\;\;\frac{1 + a}{\left(1 + a\right) + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\
                                                    
                                                    \mathbf{else}:\\
                                                    \;\;\;\;0.5\\
                                                    
                                                    
                                                    \end{array}
                                                    
                                                    Derivation
                                                    1. Split input into 2 regimes
                                                    2. if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 0.99999302722018746

                                                      1. Initial program 98.9%

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

                                                        \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot \color{blue}{b}\right)\right)\right)} \]
                                                          4. Applied rewrites55.7%

                                                            \[\leadsto \frac{1}{1 + \color{blue}{\left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}} \]
                                                          5. Taylor expanded in a around 0

                                                            \[\leadsto \frac{\color{blue}{1 + a}}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)} \]
                                                          6. Step-by-step derivation
                                                            1. lower-+.f6455.5%

                                                              \[\leadsto \frac{1 + \color{blue}{a}}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)} \]
                                                          7. Applied rewrites55.5%

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

                                                            \[\leadsto \frac{1 + a}{\color{blue}{\left(1 + a\right)} + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)} \]
                                                          9. Step-by-step derivation
                                                            1. lower-+.f6456.1%

                                                              \[\leadsto \frac{1 + a}{\left(1 + \color{blue}{a}\right) + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)} \]
                                                          10. Applied rewrites56.1%

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

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

                                                          1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

                                                              \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
                                                            12. lower-exp.f6464.0%

                                                              \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}} \]
                                                          4. Applied rewrites64.0%

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

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

                                                              \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{b} \]
                                                            2. lower-*.f6437.4%

                                                              \[\leadsto 0.5 + -0.25 \cdot b \]
                                                          7. Applied rewrites37.4%

                                                            \[\leadsto 0.5 + \color{blue}{-0.25 \cdot b} \]
                                                          8. Taylor expanded in b around 0

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

                                                              \[\leadsto 0.5 \]
                                                          10. Recombined 2 regimes into one program.
                                                          11. Add Preprocessing

                                                          Alternative 10: 58.5% accurate, 0.9× speedup?

                                                          \[\begin{array}{l} \mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.50001:\\ \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
                                                          (FPCore (a b)
                                                            :precision binary64
                                                            (if (<= (/ (exp a) (+ (exp a) (exp b))) 0.50001)
                                                            (/
                                                             1.0
                                                             (+
                                                              1.0
                                                              (+ 1.0 (* b (+ 1.0 (* b (+ 0.5 (* 0.16666666666666666 b))))))))
                                                            0.5))
                                                          double code(double a, double b) {
                                                          	double tmp;
                                                          	if ((exp(a) / (exp(a) + exp(b))) <= 0.50001) {
                                                          		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                                          	} else {
                                                          		tmp = 0.5;
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          module fmin_fmax_functions
                                                              implicit none
                                                              private
                                                              public fmax
                                                              public fmin
                                                          
                                                              interface fmax
                                                                  module procedure fmax88
                                                                  module procedure fmax44
                                                                  module procedure fmax84
                                                                  module procedure fmax48
                                                              end interface
                                                              interface fmin
                                                                  module procedure fmin88
                                                                  module procedure fmin44
                                                                  module procedure fmin84
                                                                  module procedure fmin48
                                                              end interface
                                                          contains
                                                              real(8) function fmax88(x, y) result (res)
                                                                  real(8), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                              end function
                                                              real(4) function fmax44(x, y) result (res)
                                                                  real(4), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmax84(x, y) result(res)
                                                                  real(8), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmax48(x, y) result(res)
                                                                  real(4), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin88(x, y) result (res)
                                                                  real(8), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                              end function
                                                              real(4) function fmin44(x, y) result (res)
                                                                  real(4), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin84(x, y) result(res)
                                                                  real(8), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin48(x, y) result(res)
                                                                  real(4), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                              end function
                                                          end module
                                                          
                                                          real(8) function code(a, b)
                                                          use fmin_fmax_functions
                                                              real(8), intent (in) :: a
                                                              real(8), intent (in) :: b
                                                              real(8) :: tmp
                                                              if ((exp(a) / (exp(a) + exp(b))) <= 0.50001d0) then
                                                                  tmp = 1.0d0 / (1.0d0 + (1.0d0 + (b * (1.0d0 + (b * (0.5d0 + (0.16666666666666666d0 * b)))))))
                                                              else
                                                                  tmp = 0.5d0
                                                              end if
                                                              code = tmp
                                                          end function
                                                          
                                                          public static double code(double a, double b) {
                                                          	double tmp;
                                                          	if ((Math.exp(a) / (Math.exp(a) + Math.exp(b))) <= 0.50001) {
                                                          		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                                          	} else {
                                                          		tmp = 0.5;
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          def code(a, b):
                                                          	tmp = 0
                                                          	if (math.exp(a) / (math.exp(a) + math.exp(b))) <= 0.50001:
                                                          		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))))
                                                          	else:
                                                          		tmp = 0.5
                                                          	return tmp
                                                          
                                                          function code(a, b)
                                                          	tmp = 0.0
                                                          	if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.50001)
                                                          		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(0.16666666666666666 * b))))))));
                                                          	else
                                                          		tmp = 0.5;
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          function tmp_2 = code(a, b)
                                                          	tmp = 0.0;
                                                          	if ((exp(a) / (exp(a) + exp(b))) <= 0.50001)
                                                          		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))));
                                                          	else
                                                          		tmp = 0.5;
                                                          	end
                                                          	tmp_2 = tmp;
                                                          end
                                                          
                                                          code[a_, b_] := If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.50001], N[(1.0 / N[(1.0 + N[(1.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(0.16666666666666666 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5]
                                                          
                                                          \begin{array}{l}
                                                          \mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.50001:\\
                                                          \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot b\right)\right)\right)}\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;0.5\\
                                                          
                                                          
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 2 regimes
                                                          2. if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 0.50000999999999995

                                                            1. Initial program 98.9%

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

                                                              \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites80.6%

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

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

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

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

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

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

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

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

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

                                                                    \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + b \cdot \left(0.5 + 0.16666666666666666 \cdot \color{blue}{b}\right)\right)\right)} \]
                                                                4. Applied rewrites55.7%

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

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

                                                                1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                    \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
                                                                  12. lower-exp.f6464.0%

                                                                    \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}} \]
                                                                4. Applied rewrites64.0%

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

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

                                                                    \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{b} \]
                                                                  2. lower-*.f6437.4%

                                                                    \[\leadsto 0.5 + -0.25 \cdot b \]
                                                                7. Applied rewrites37.4%

                                                                  \[\leadsto 0.5 + \color{blue}{-0.25 \cdot b} \]
                                                                8. Taylor expanded in b around 0

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

                                                                    \[\leadsto 0.5 \]
                                                                10. Recombined 2 regimes into one program.
                                                                11. Add Preprocessing

                                                                Alternative 11: 54.1% accurate, 0.9× speedup?

                                                                \[\begin{array}{l} \mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.50001:\\ \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + 0.5 \cdot b\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
                                                                (FPCore (a b)
                                                                  :precision binary64
                                                                  (if (<= (/ (exp a) (+ (exp a) (exp b))) 0.50001)
                                                                  (/ 1.0 (+ 1.0 (+ 1.0 (* b (+ 1.0 (* 0.5 b))))))
                                                                  0.5))
                                                                double code(double a, double b) {
                                                                	double tmp;
                                                                	if ((exp(a) / (exp(a) + exp(b))) <= 0.50001) {
                                                                		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (0.5 * b)))));
                                                                	} else {
                                                                		tmp = 0.5;
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                module fmin_fmax_functions
                                                                    implicit none
                                                                    private
                                                                    public fmax
                                                                    public fmin
                                                                
                                                                    interface fmax
                                                                        module procedure fmax88
                                                                        module procedure fmax44
                                                                        module procedure fmax84
                                                                        module procedure fmax48
                                                                    end interface
                                                                    interface fmin
                                                                        module procedure fmin88
                                                                        module procedure fmin44
                                                                        module procedure fmin84
                                                                        module procedure fmin48
                                                                    end interface
                                                                contains
                                                                    real(8) function fmax88(x, y) result (res)
                                                                        real(8), intent (in) :: x
                                                                        real(8), intent (in) :: y
                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                    end function
                                                                    real(4) function fmax44(x, y) result (res)
                                                                        real(4), intent (in) :: x
                                                                        real(4), intent (in) :: y
                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmax84(x, y) result(res)
                                                                        real(8), intent (in) :: x
                                                                        real(4), intent (in) :: y
                                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmax48(x, y) result(res)
                                                                        real(4), intent (in) :: x
                                                                        real(8), intent (in) :: y
                                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmin88(x, y) result (res)
                                                                        real(8), intent (in) :: x
                                                                        real(8), intent (in) :: y
                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                    end function
                                                                    real(4) function fmin44(x, y) result (res)
                                                                        real(4), intent (in) :: x
                                                                        real(4), intent (in) :: y
                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmin84(x, y) result(res)
                                                                        real(8), intent (in) :: x
                                                                        real(4), intent (in) :: y
                                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmin48(x, y) result(res)
                                                                        real(4), intent (in) :: x
                                                                        real(8), intent (in) :: y
                                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                    end function
                                                                end module
                                                                
                                                                real(8) function code(a, b)
                                                                use fmin_fmax_functions
                                                                    real(8), intent (in) :: a
                                                                    real(8), intent (in) :: b
                                                                    real(8) :: tmp
                                                                    if ((exp(a) / (exp(a) + exp(b))) <= 0.50001d0) then
                                                                        tmp = 1.0d0 / (1.0d0 + (1.0d0 + (b * (1.0d0 + (0.5d0 * b)))))
                                                                    else
                                                                        tmp = 0.5d0
                                                                    end if
                                                                    code = tmp
                                                                end function
                                                                
                                                                public static double code(double a, double b) {
                                                                	double tmp;
                                                                	if ((Math.exp(a) / (Math.exp(a) + Math.exp(b))) <= 0.50001) {
                                                                		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (0.5 * b)))));
                                                                	} else {
                                                                		tmp = 0.5;
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                def code(a, b):
                                                                	tmp = 0
                                                                	if (math.exp(a) / (math.exp(a) + math.exp(b))) <= 0.50001:
                                                                		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (0.5 * b)))))
                                                                	else:
                                                                		tmp = 0.5
                                                                	return tmp
                                                                
                                                                function code(a, b)
                                                                	tmp = 0.0
                                                                	if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.50001)
                                                                		tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 + Float64(b * Float64(1.0 + Float64(0.5 * b))))));
                                                                	else
                                                                		tmp = 0.5;
                                                                	end
                                                                	return tmp
                                                                end
                                                                
                                                                function tmp_2 = code(a, b)
                                                                	tmp = 0.0;
                                                                	if ((exp(a) / (exp(a) + exp(b))) <= 0.50001)
                                                                		tmp = 1.0 / (1.0 + (1.0 + (b * (1.0 + (0.5 * b)))));
                                                                	else
                                                                		tmp = 0.5;
                                                                	end
                                                                	tmp_2 = tmp;
                                                                end
                                                                
                                                                code[a_, b_] := If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.50001], N[(1.0 / N[(1.0 + N[(1.0 + N[(b * N[(1.0 + N[(0.5 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5]
                                                                
                                                                \begin{array}{l}
                                                                \mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.50001:\\
                                                                \;\;\;\;\frac{1}{1 + \left(1 + b \cdot \left(1 + 0.5 \cdot b\right)\right)}\\
                                                                
                                                                \mathbf{else}:\\
                                                                \;\;\;\;0.5\\
                                                                
                                                                
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Split input into 2 regimes
                                                                2. if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 0.50000999999999995

                                                                  1. Initial program 98.9%

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

                                                                    \[\leadsto \frac{\color{blue}{1}}{e^{a} + e^{b}} \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites80.6%

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

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

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

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

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

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

                                                                          \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + \color{blue}{\frac{1}{2} \cdot b}\right)\right)} \]
                                                                        4. lower-*.f6451.5%

                                                                          \[\leadsto \frac{1}{1 + \left(1 + b \cdot \left(1 + 0.5 \cdot \color{blue}{b}\right)\right)} \]
                                                                      4. Applied rewrites51.5%

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

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

                                                                      1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                          \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
                                                                        12. lower-exp.f6464.0%

                                                                          \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}} \]
                                                                      4. Applied rewrites64.0%

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

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

                                                                          \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{b} \]
                                                                        2. lower-*.f6437.4%

                                                                          \[\leadsto 0.5 + -0.25 \cdot b \]
                                                                      7. Applied rewrites37.4%

                                                                        \[\leadsto 0.5 + \color{blue}{-0.25 \cdot b} \]
                                                                      8. Taylor expanded in b around 0

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

                                                                          \[\leadsto 0.5 \]
                                                                      10. Recombined 2 regimes into one program.
                                                                      11. Add Preprocessing

                                                                      Alternative 12: 39.6% accurate, 315.0× speedup?

                                                                      \[0.5 \]
                                                                      (FPCore (a b)
                                                                        :precision binary64
                                                                        0.5)
                                                                      double code(double a, double b) {
                                                                      	return 0.5;
                                                                      }
                                                                      
                                                                      module fmin_fmax_functions
                                                                          implicit none
                                                                          private
                                                                          public fmax
                                                                          public fmin
                                                                      
                                                                          interface fmax
                                                                              module procedure fmax88
                                                                              module procedure fmax44
                                                                              module procedure fmax84
                                                                              module procedure fmax48
                                                                          end interface
                                                                          interface fmin
                                                                              module procedure fmin88
                                                                              module procedure fmin44
                                                                              module procedure fmin84
                                                                              module procedure fmin48
                                                                          end interface
                                                                      contains
                                                                          real(8) function fmax88(x, y) result (res)
                                                                              real(8), intent (in) :: x
                                                                              real(8), intent (in) :: y
                                                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                          end function
                                                                          real(4) function fmax44(x, y) result (res)
                                                                              real(4), intent (in) :: x
                                                                              real(4), intent (in) :: y
                                                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmax84(x, y) result(res)
                                                                              real(8), intent (in) :: x
                                                                              real(4), intent (in) :: y
                                                                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmax48(x, y) result(res)
                                                                              real(4), intent (in) :: x
                                                                              real(8), intent (in) :: y
                                                                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmin88(x, y) result (res)
                                                                              real(8), intent (in) :: x
                                                                              real(8), intent (in) :: y
                                                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                          end function
                                                                          real(4) function fmin44(x, y) result (res)
                                                                              real(4), intent (in) :: x
                                                                              real(4), intent (in) :: y
                                                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmin84(x, y) result(res)
                                                                              real(8), intent (in) :: x
                                                                              real(4), intent (in) :: y
                                                                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmin48(x, y) result(res)
                                                                              real(4), intent (in) :: x
                                                                              real(8), intent (in) :: y
                                                                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                          end function
                                                                      end module
                                                                      
                                                                      real(8) function code(a, b)
                                                                      use fmin_fmax_functions
                                                                          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
                                                                      
                                                                      0.5
                                                                      
                                                                      Derivation
                                                                      1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                          \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + \color{blue}{e^{a}}} \]
                                                                        12. lower-exp.f6464.0%

                                                                          \[\leadsto -1 \cdot \frac{b \cdot e^{a}}{{\left(1 + e^{a}\right)}^{2}} + \frac{e^{a}}{1 + e^{a}} \]
                                                                      4. Applied rewrites64.0%

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

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

                                                                          \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{b} \]
                                                                        2. lower-*.f6437.4%

                                                                          \[\leadsto 0.5 + -0.25 \cdot b \]
                                                                      7. Applied rewrites37.4%

                                                                        \[\leadsto 0.5 + \color{blue}{-0.25 \cdot b} \]
                                                                      8. Taylor expanded in b around 0

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

                                                                          \[\leadsto 0.5 \]
                                                                        2. Add Preprocessing

                                                                        Reproduce

                                                                        ?
                                                                        herbie shell --seed 2025258 
                                                                        (FPCore (a b)
                                                                          :name "Quotient of sum of exps"
                                                                          :precision binary64
                                                                          (/ (exp a) (+ (exp a) (exp b))))