Octave 3.8, jcobi/1

Percentage Accurate: 74.2% → 99.8%
Time: 3.0s
Alternatives: 12
Speedup: 0.7×

Specification

?
\[\alpha > -1 \land \beta > -1\]
\[\begin{array}{l} \\ \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))
double code(double alpha, double beta) {
	return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.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(alpha, beta)
use fmin_fmax_functions
    real(8), intent (in) :: alpha
    real(8), intent (in) :: beta
    code = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
end function
public static double code(double alpha, double beta) {
	return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
}
def code(alpha, beta):
	return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
function code(alpha, beta)
	return Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0)
end
function tmp = code(alpha, beta)
	tmp = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
end
code[alpha_, beta_] := N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}
\end{array}

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: 74.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))
double code(double alpha, double beta) {
	return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.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(alpha, beta)
use fmin_fmax_functions
    real(8), intent (in) :: alpha
    real(8), intent (in) :: beta
    code = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
end function
public static double code(double alpha, double beta) {
	return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
}
def code(alpha, beta):
	return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
function code(alpha, beta)
	return Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0)
end
function tmp = code(alpha, beta)
	tmp = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
end
code[alpha_, beta_] := N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}
\end{array}

Alternative 1: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-2 - \alpha\right) - \beta\\ \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0:\\ \;\;\;\;\frac{1}{\alpha} + \frac{\beta}{\alpha}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0 - \left(\beta - \alpha\right)}{t\_0 \cdot 2}\\ \end{array} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (let* ((t_0 (- (- -2.0 alpha) beta)))
   (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.0)
     (+ (/ 1.0 alpha) (/ beta alpha))
     (/ (- t_0 (- beta alpha)) (* t_0 2.0)))))
double code(double alpha, double beta) {
	double t_0 = (-2.0 - alpha) - beta;
	double tmp;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.0) {
		tmp = (1.0 / alpha) + (beta / alpha);
	} else {
		tmp = (t_0 - (beta - alpha)) / (t_0 * 2.0);
	}
	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(alpha, beta)
use fmin_fmax_functions
    real(8), intent (in) :: alpha
    real(8), intent (in) :: beta
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((-2.0d0) - alpha) - beta
    if (((((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0) <= 0.0d0) then
        tmp = (1.0d0 / alpha) + (beta / alpha)
    else
        tmp = (t_0 - (beta - alpha)) / (t_0 * 2.0d0)
    end if
    code = tmp
end function
public static double code(double alpha, double beta) {
	double t_0 = (-2.0 - alpha) - beta;
	double tmp;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.0) {
		tmp = (1.0 / alpha) + (beta / alpha);
	} else {
		tmp = (t_0 - (beta - alpha)) / (t_0 * 2.0);
	}
	return tmp;
}
def code(alpha, beta):
	t_0 = (-2.0 - alpha) - beta
	tmp = 0
	if ((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.0:
		tmp = (1.0 / alpha) + (beta / alpha)
	else:
		tmp = (t_0 - (beta - alpha)) / (t_0 * 2.0)
	return tmp
function code(alpha, beta)
	t_0 = Float64(Float64(-2.0 - alpha) - beta)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.0)
		tmp = Float64(Float64(1.0 / alpha) + Float64(beta / alpha));
	else
		tmp = Float64(Float64(t_0 - Float64(beta - alpha)) / Float64(t_0 * 2.0));
	end
	return tmp
end
function tmp_2 = code(alpha, beta)
	t_0 = (-2.0 - alpha) - beta;
	tmp = 0.0;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.0)
		tmp = (1.0 / alpha) + (beta / alpha);
	else
		tmp = (t_0 - (beta - alpha)) / (t_0 * 2.0);
	end
	tmp_2 = tmp;
end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(-2.0 - alpha), $MachinePrecision] - beta), $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], 0.0], N[(N[(1.0 / alpha), $MachinePrecision] + N[(beta / alpha), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - N[(beta - alpha), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(-2 - \alpha\right) - \beta\\
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0:\\
\;\;\;\;\frac{1}{\alpha} + \frac{\beta}{\alpha}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \left(\beta - \alpha\right)}{t\_0 \cdot 2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.0

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)}{\mathsf{neg}\left(2\right)}} \]
      3. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)}} \]
      4. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{1 + \frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      8. frac-2negN/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\mathsf{neg}\left(\left(\beta - \alpha\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      9. add-to-fractionN/A

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      10. remove-double-negN/A

        \[\leadsto \frac{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}{\color{blue}{2}} \]
      11. associate-/l/N/A

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

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) \cdot 2}} \]
    3. Applied rewrites74.5%

      \[\leadsto \color{blue}{\frac{\left(\left(-2 - \alpha\right) - \beta\right) - \left(\beta - \alpha\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}} \]
    4. Taylor expanded in alpha around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\alpha}} \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{2 + 2 \cdot \beta}{\alpha}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\color{blue}{\alpha}} \]
      3. lower-+.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\alpha} \]
      4. lower-*.f6429.7

        \[\leadsto 0.5 \cdot \frac{2 + 2 \cdot \beta}{\alpha} \]
    6. Applied rewrites29.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{2 + 2 \cdot \beta}{\alpha}} \]
    7. Taylor expanded in beta around 0

      \[\leadsto \frac{1}{\alpha} + \color{blue}{\frac{\beta}{\alpha}} \]
    8. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\color{blue}{\alpha}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\alpha} \]
      3. lower-/.f6429.7

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\alpha} \]
    9. Applied rewrites29.7%

      \[\leadsto \frac{1}{\alpha} + \color{blue}{\frac{\beta}{\alpha}} \]

    if 0.0 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)}{\mathsf{neg}\left(2\right)}} \]
      3. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)}} \]
      4. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{1 + \frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      8. frac-2negN/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\mathsf{neg}\left(\left(\beta - \alpha\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      9. add-to-fractionN/A

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      10. remove-double-negN/A

        \[\leadsto \frac{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}{\color{blue}{2}} \]
      11. associate-/l/N/A

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

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) \cdot 2}} \]
    3. Applied rewrites74.5%

      \[\leadsto \color{blue}{\frac{\left(\left(-2 - \alpha\right) - \beta\right) - \left(\beta - \alpha\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 99.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(\frac{2}{\beta}, -\beta, 2 \cdot \left(-\beta\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (/
  (fma (/ 2.0 beta) (- beta) (* 2.0 (- beta)))
  (* (- (- -2.0 alpha) beta) 2.0)))
double code(double alpha, double beta) {
	return fma((2.0 / beta), -beta, (2.0 * -beta)) / (((-2.0 - alpha) - beta) * 2.0);
}
function code(alpha, beta)
	return Float64(fma(Float64(2.0 / beta), Float64(-beta), Float64(2.0 * Float64(-beta))) / Float64(Float64(Float64(-2.0 - alpha) - beta) * 2.0))
end
code[alpha_, beta_] := N[(N[(N[(2.0 / beta), $MachinePrecision] * (-beta) + N[(2.0 * (-beta)), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(-2.0 - alpha), $MachinePrecision] - beta), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left(\frac{2}{\beta}, -\beta, 2 \cdot \left(-\beta\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}
\end{array}
Derivation
  1. Initial program 74.2%

    \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}} \]
    2. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)}{\mathsf{neg}\left(2\right)}} \]
    3. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)}} \]
    4. remove-double-negN/A

      \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
    5. lift-+.f64N/A

      \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
    6. +-commutativeN/A

      \[\leadsto \frac{\color{blue}{1 + \frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
    7. lift-/.f64N/A

      \[\leadsto \frac{1 + \color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
    8. frac-2negN/A

      \[\leadsto \frac{1 + \color{blue}{\frac{\mathsf{neg}\left(\left(\beta - \alpha\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
    9. add-to-fractionN/A

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
    10. remove-double-negN/A

      \[\leadsto \frac{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}{\color{blue}{2}} \]
    11. associate-/l/N/A

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

      \[\leadsto \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) \cdot 2}} \]
  3. Applied rewrites74.5%

    \[\leadsto \color{blue}{\frac{\left(\left(-2 - \alpha\right) - \beta\right) - \left(\beta - \alpha\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}} \]
  4. Taylor expanded in beta around inf

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

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

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

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

      \[\leadsto \frac{-1 \cdot \left(\beta \cdot \left(2 + 2 \cdot \color{blue}{\frac{1}{\beta}}\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    5. lower-/.f6499.8

      \[\leadsto \frac{-1 \cdot \left(\beta \cdot \left(2 + 2 \cdot \frac{1}{\color{blue}{\beta}}\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
  6. Applied rewrites99.8%

    \[\leadsto \frac{\color{blue}{-1 \cdot \left(\beta \cdot \left(2 + 2 \cdot \frac{1}{\beta}\right)\right)}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
  7. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

      \[\leadsto \frac{\left(2 \cdot \frac{1}{\beta}\right) \cdot \left(-1 \cdot \beta\right) + \color{blue}{2 \cdot \left(-1 \cdot \beta\right)}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    7. mul-1-negN/A

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

      \[\leadsto \frac{\mathsf{fma}\left(2 \cdot \frac{1}{\beta}, \color{blue}{\mathsf{neg}\left(\beta\right)}, 2 \cdot \left(-1 \cdot \beta\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(2 \cdot \frac{1}{\beta}, \mathsf{neg}\left(\color{blue}{\beta}\right), 2 \cdot \left(-1 \cdot \beta\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    10. lift-/.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(2 \cdot \frac{1}{\beta}, \mathsf{neg}\left(\beta\right), 2 \cdot \left(-1 \cdot \beta\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    11. mult-flip-revN/A

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

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

      \[\leadsto \frac{\mathsf{fma}\left(\frac{2}{\beta}, -\beta, 2 \cdot \left(-1 \cdot \beta\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    14. mul-1-negN/A

      \[\leadsto \frac{\mathsf{fma}\left(\frac{2}{\beta}, -\beta, 2 \cdot \left(\mathsf{neg}\left(\beta\right)\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    15. lower-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(\frac{2}{\beta}, -\beta, 2 \cdot \left(\mathsf{neg}\left(\beta\right)\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    16. lower-neg.f6499.8

      \[\leadsto \frac{\mathsf{fma}\left(\frac{2}{\beta}, -\beta, 2 \cdot \left(-\beta\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
  8. Applied rewrites99.8%

    \[\leadsto \frac{\mathsf{fma}\left(\frac{2}{\beta}, \color{blue}{-\beta}, 2 \cdot \left(-\beta\right)\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
  9. Add Preprocessing

Alternative 3: 99.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 10^{-10}:\\ \;\;\;\;\frac{1}{\alpha} + \frac{\beta}{\alpha}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
   (if (<= t_0 1e-10) (+ (/ 1.0 alpha) (/ beta alpha)) t_0)))
double code(double alpha, double beta) {
	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
	double tmp;
	if (t_0 <= 1e-10) {
		tmp = (1.0 / alpha) + (beta / alpha);
	} else {
		tmp = t_0;
	}
	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(alpha, beta)
use fmin_fmax_functions
    real(8), intent (in) :: alpha
    real(8), intent (in) :: beta
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
    if (t_0 <= 1d-10) then
        tmp = (1.0d0 / alpha) + (beta / alpha)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double alpha, double beta) {
	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
	double tmp;
	if (t_0 <= 1e-10) {
		tmp = (1.0 / alpha) + (beta / alpha);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(alpha, beta):
	t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
	tmp = 0
	if t_0 <= 1e-10:
		tmp = (1.0 / alpha) + (beta / alpha)
	else:
		tmp = t_0
	return tmp
function code(alpha, beta)
	t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0)
	tmp = 0.0
	if (t_0 <= 1e-10)
		tmp = Float64(Float64(1.0 / alpha) + Float64(beta / alpha));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(alpha, beta)
	t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
	tmp = 0.0;
	if (t_0 <= 1e-10)
		tmp = (1.0 / alpha) + (beta / alpha);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-10], N[(N[(1.0 / alpha), $MachinePrecision] + N[(beta / alpha), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 10^{-10}:\\
\;\;\;\;\frac{1}{\alpha} + \frac{\beta}{\alpha}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 1.00000000000000004e-10

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)}{\mathsf{neg}\left(2\right)}} \]
      3. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)}} \]
      4. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{1 + \frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      8. frac-2negN/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\mathsf{neg}\left(\left(\beta - \alpha\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      9. add-to-fractionN/A

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      10. remove-double-negN/A

        \[\leadsto \frac{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}{\color{blue}{2}} \]
      11. associate-/l/N/A

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

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) \cdot 2}} \]
    3. Applied rewrites74.5%

      \[\leadsto \color{blue}{\frac{\left(\left(-2 - \alpha\right) - \beta\right) - \left(\beta - \alpha\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}} \]
    4. Taylor expanded in alpha around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\alpha}} \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{2 + 2 \cdot \beta}{\alpha}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\color{blue}{\alpha}} \]
      3. lower-+.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\alpha} \]
      4. lower-*.f6429.7

        \[\leadsto 0.5 \cdot \frac{2 + 2 \cdot \beta}{\alpha} \]
    6. Applied rewrites29.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{2 + 2 \cdot \beta}{\alpha}} \]
    7. Taylor expanded in beta around 0

      \[\leadsto \frac{1}{\alpha} + \color{blue}{\frac{\beta}{\alpha}} \]
    8. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\color{blue}{\alpha}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\alpha} \]
      3. lower-/.f6429.7

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\alpha} \]
    9. Applied rewrites29.7%

      \[\leadsto \frac{1}{\alpha} + \color{blue}{\frac{\beta}{\alpha}} \]

    if 1.00000000000000004e-10 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 98.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\frac{1}{\alpha} + \frac{\beta}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.6:\\ \;\;\;\;\frac{1}{2 + \alpha}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1}{\beta}\\ \end{array} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
   (if (<= t_0 0.0)
     (+ (/ 1.0 alpha) (/ beta alpha))
     (if (<= t_0 0.6) (/ 1.0 (+ 2.0 alpha)) (- 1.0 (/ 1.0 beta))))))
double code(double alpha, double beta) {
	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
	double tmp;
	if (t_0 <= 0.0) {
		tmp = (1.0 / alpha) + (beta / alpha);
	} else if (t_0 <= 0.6) {
		tmp = 1.0 / (2.0 + alpha);
	} else {
		tmp = 1.0 - (1.0 / beta);
	}
	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(alpha, beta)
use fmin_fmax_functions
    real(8), intent (in) :: alpha
    real(8), intent (in) :: beta
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
    if (t_0 <= 0.0d0) then
        tmp = (1.0d0 / alpha) + (beta / alpha)
    else if (t_0 <= 0.6d0) then
        tmp = 1.0d0 / (2.0d0 + alpha)
    else
        tmp = 1.0d0 - (1.0d0 / beta)
    end if
    code = tmp
end function
public static double code(double alpha, double beta) {
	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
	double tmp;
	if (t_0 <= 0.0) {
		tmp = (1.0 / alpha) + (beta / alpha);
	} else if (t_0 <= 0.6) {
		tmp = 1.0 / (2.0 + alpha);
	} else {
		tmp = 1.0 - (1.0 / beta);
	}
	return tmp;
}
def code(alpha, beta):
	t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
	tmp = 0
	if t_0 <= 0.0:
		tmp = (1.0 / alpha) + (beta / alpha)
	elif t_0 <= 0.6:
		tmp = 1.0 / (2.0 + alpha)
	else:
		tmp = 1.0 - (1.0 / beta)
	return tmp
function code(alpha, beta)
	t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0)
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(Float64(1.0 / alpha) + Float64(beta / alpha));
	elseif (t_0 <= 0.6)
		tmp = Float64(1.0 / Float64(2.0 + alpha));
	else
		tmp = Float64(1.0 - Float64(1.0 / beta));
	end
	return tmp
end
function tmp_2 = code(alpha, beta)
	t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = (1.0 / alpha) + (beta / alpha);
	elseif (t_0 <= 0.6)
		tmp = 1.0 / (2.0 + alpha);
	else
		tmp = 1.0 - (1.0 / beta);
	end
	tmp_2 = tmp;
end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(1.0 / alpha), $MachinePrecision] + N[(beta / alpha), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(1.0 / N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(1.0 / beta), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{1}{\alpha} + \frac{\beta}{\alpha}\\

\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\frac{1}{2 + \alpha}\\

\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{\beta}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.0

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)}{\mathsf{neg}\left(2\right)}} \]
      3. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)}} \]
      4. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{1 + \frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      8. frac-2negN/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\mathsf{neg}\left(\left(\beta - \alpha\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      9. add-to-fractionN/A

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      10. remove-double-negN/A

        \[\leadsto \frac{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}{\color{blue}{2}} \]
      11. associate-/l/N/A

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

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) \cdot 2}} \]
    3. Applied rewrites74.5%

      \[\leadsto \color{blue}{\frac{\left(\left(-2 - \alpha\right) - \beta\right) - \left(\beta - \alpha\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}} \]
    4. Taylor expanded in alpha around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\alpha}} \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{2 + 2 \cdot \beta}{\alpha}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\color{blue}{\alpha}} \]
      3. lower-+.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\alpha} \]
      4. lower-*.f6429.7

        \[\leadsto 0.5 \cdot \frac{2 + 2 \cdot \beta}{\alpha} \]
    6. Applied rewrites29.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{2 + 2 \cdot \beta}{\alpha}} \]
    7. Taylor expanded in beta around 0

      \[\leadsto \frac{1}{\alpha} + \color{blue}{\frac{\beta}{\alpha}} \]
    8. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\color{blue}{\alpha}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\alpha} \]
      3. lower-/.f6429.7

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\alpha} \]
    9. Applied rewrites29.7%

      \[\leadsto \frac{1}{\alpha} + \color{blue}{\frac{\beta}{\alpha}} \]

    if 0.0 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)}{\mathsf{neg}\left(2\right)}} \]
      3. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)}} \]
      4. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{1 + \frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      8. frac-2negN/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\mathsf{neg}\left(\left(\beta - \alpha\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      9. add-to-fractionN/A

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      10. remove-double-negN/A

        \[\leadsto \frac{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}{\color{blue}{2}} \]
      11. associate-/l/N/A

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

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) \cdot 2}} \]
    3. Applied rewrites74.5%

      \[\leadsto \color{blue}{\frac{\left(\left(-2 - \alpha\right) - \beta\right) - \left(\beta - \alpha\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}} \]
    4. Taylor expanded in beta around 0

      \[\leadsto \color{blue}{\frac{1}{2 + \alpha}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{2 + \alpha}} \]
      2. lower-+.f6470.0

        \[\leadsto \frac{1}{2 + \color{blue}{\alpha}} \]
    6. Applied rewrites70.0%

      \[\leadsto \color{blue}{\frac{1}{2 + \alpha}} \]

    if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in alpha around 0

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(1 + \frac{\beta}{\color{blue}{2 + \beta}}\right) \]
      4. lower-+.f6472.4

        \[\leadsto 0.5 \cdot \left(1 + \frac{\beta}{2 + \color{blue}{\beta}}\right) \]
    4. Applied rewrites72.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + \frac{\beta}{2 + \beta}\right)} \]
    5. Taylor expanded in beta around inf

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

        \[\leadsto 1 - \frac{1}{\color{blue}{\beta}} \]
      2. lower-/.f6429.8

        \[\leadsto 1 - \frac{1}{\beta} \]
    7. Applied rewrites29.8%

      \[\leadsto 1 - \color{blue}{\frac{1}{\beta}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 98.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.05:\\ \;\;\;\;\frac{1}{\alpha} + \frac{\beta}{\alpha}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\beta, \frac{-0.5}{-2 - \beta}, 0.5\right)\\ \end{array} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.05)
   (+ (/ 1.0 alpha) (/ beta alpha))
   (fma beta (/ -0.5 (- -2.0 beta)) 0.5)))
double code(double alpha, double beta) {
	double tmp;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.05) {
		tmp = (1.0 / alpha) + (beta / alpha);
	} else {
		tmp = fma(beta, (-0.5 / (-2.0 - beta)), 0.5);
	}
	return tmp;
}
function code(alpha, beta)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.05)
		tmp = Float64(Float64(1.0 / alpha) + Float64(beta / alpha));
	else
		tmp = fma(beta, Float64(-0.5 / Float64(-2.0 - beta)), 0.5);
	end
	return tmp
end
code[alpha_, beta_] := If[LessEqual[N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], 0.05], N[(N[(1.0 / alpha), $MachinePrecision] + N[(beta / alpha), $MachinePrecision]), $MachinePrecision], N[(beta * N[(-0.5 / N[(-2.0 - beta), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.05:\\
\;\;\;\;\frac{1}{\alpha} + \frac{\beta}{\alpha}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\beta, \frac{-0.5}{-2 - \beta}, 0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.050000000000000003

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)}{\mathsf{neg}\left(2\right)}} \]
      3. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)}} \]
      4. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{1 + \frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      8. frac-2negN/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\mathsf{neg}\left(\left(\beta - \alpha\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      9. add-to-fractionN/A

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      10. remove-double-negN/A

        \[\leadsto \frac{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}{\color{blue}{2}} \]
      11. associate-/l/N/A

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

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) \cdot 2}} \]
    3. Applied rewrites74.5%

      \[\leadsto \color{blue}{\frac{\left(\left(-2 - \alpha\right) - \beta\right) - \left(\beta - \alpha\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}} \]
    4. Taylor expanded in alpha around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\alpha}} \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{2 + 2 \cdot \beta}{\alpha}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\color{blue}{\alpha}} \]
      3. lower-+.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{2 + 2 \cdot \beta}{\alpha} \]
      4. lower-*.f6429.7

        \[\leadsto 0.5 \cdot \frac{2 + 2 \cdot \beta}{\alpha} \]
    6. Applied rewrites29.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{2 + 2 \cdot \beta}{\alpha}} \]
    7. Taylor expanded in beta around 0

      \[\leadsto \frac{1}{\alpha} + \color{blue}{\frac{\beta}{\alpha}} \]
    8. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\color{blue}{\alpha}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\alpha} \]
      3. lower-/.f6429.7

        \[\leadsto \frac{1}{\alpha} + \frac{\beta}{\alpha} \]
    9. Applied rewrites29.7%

      \[\leadsto \frac{1}{\alpha} + \color{blue}{\frac{\beta}{\alpha}} \]

    if 0.050000000000000003 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in alpha around 0

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(1 + \frac{\beta}{\color{blue}{2 + \beta}}\right) \]
      4. lower-+.f6472.4

        \[\leadsto 0.5 \cdot \left(1 + \frac{\beta}{2 + \color{blue}{\beta}}\right) \]
    4. Applied rewrites72.4%

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

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

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

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

        \[\leadsto \frac{\beta}{2 + \beta} \cdot \frac{1}{2} + \color{blue}{1 \cdot \frac{1}{2}} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\beta}{2 + \beta} \cdot \frac{1}{2} + \frac{1}{2} \]
      6. lower-fma.f6472.4

        \[\leadsto \mathsf{fma}\left(\frac{\beta}{2 + \beta}, \color{blue}{0.5}, 0.5\right) \]
      7. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\beta}{2 + \beta}, \frac{1}{2}, \frac{1}{2}\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{\beta}{\beta + 2}, \frac{1}{2}, \frac{1}{2}\right) \]
      9. add-flipN/A

        \[\leadsto \mathsf{fma}\left(\frac{\beta}{\beta - \left(\mathsf{neg}\left(2\right)\right)}, \frac{1}{2}, \frac{1}{2}\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\beta}{\beta - -2}, \frac{1}{2}, \frac{1}{2}\right) \]
      11. lower--.f6472.4

        \[\leadsto \mathsf{fma}\left(\frac{\beta}{\beta - -2}, 0.5, 0.5\right) \]
    6. Applied rewrites72.4%

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

        \[\leadsto \frac{\beta}{\beta - -2} \cdot \frac{1}{2} + \color{blue}{\frac{1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{\beta}{\beta - -2} \cdot \frac{1}{2} + \frac{1}{2} \]
      3. mult-flipN/A

        \[\leadsto \left(\beta \cdot \frac{1}{\beta - -2}\right) \cdot \frac{1}{2} + \frac{1}{2} \]
      4. associate-*l*N/A

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

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

        \[\leadsto \mathsf{fma}\left(\beta, \frac{1}{\beta - -2} \cdot \frac{\frac{1}{2}}{\color{blue}{1}}, \frac{1}{2}\right) \]
      7. frac-timesN/A

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

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

        \[\leadsto \mathsf{fma}\left(\beta, \frac{\frac{1}{2}}{\color{blue}{1} \cdot \left(\beta - -2\right)}, \frac{1}{2}\right) \]
      10. *-lft-identityN/A

        \[\leadsto \mathsf{fma}\left(\beta, \frac{\frac{1}{2}}{\beta - \color{blue}{-2}}, \frac{1}{2}\right) \]
      11. frac-2negN/A

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

        \[\leadsto \mathsf{fma}\left(\beta, \frac{\mathsf{neg}\left(\frac{1}{2}\right)}{\color{blue}{\mathsf{neg}\left(\left(\beta - -2\right)\right)}}, \frac{1}{2}\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\beta, \frac{\frac{-1}{2}}{\mathsf{neg}\left(\color{blue}{\left(\beta - -2\right)}\right)}, \frac{1}{2}\right) \]
      14. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\beta, \frac{\frac{-1}{2}}{\mathsf{neg}\left(\left(\beta - -2\right)\right)}, \frac{1}{2}\right) \]
      15. sub-negate-revN/A

        \[\leadsto \mathsf{fma}\left(\beta, \frac{\frac{-1}{2}}{-2 - \color{blue}{\beta}}, \frac{1}{2}\right) \]
      16. lower--.f6472.4

        \[\leadsto \mathsf{fma}\left(\beta, \frac{-0.5}{-2 - \color{blue}{\beta}}, 0.5\right) \]
    8. Applied rewrites72.4%

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

Alternative 6: 92.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.6:\\ \;\;\;\;\frac{1}{2 + \alpha}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1}{\beta}\\ \end{array} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.6)
   (/ 1.0 (+ 2.0 alpha))
   (- 1.0 (/ 1.0 beta))))
double code(double alpha, double beta) {
	double tmp;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.6) {
		tmp = 1.0 / (2.0 + alpha);
	} else {
		tmp = 1.0 - (1.0 / beta);
	}
	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(alpha, beta)
use fmin_fmax_functions
    real(8), intent (in) :: alpha
    real(8), intent (in) :: beta
    real(8) :: tmp
    if (((((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0) <= 0.6d0) then
        tmp = 1.0d0 / (2.0d0 + alpha)
    else
        tmp = 1.0d0 - (1.0d0 / beta)
    end if
    code = tmp
end function
public static double code(double alpha, double beta) {
	double tmp;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.6) {
		tmp = 1.0 / (2.0 + alpha);
	} else {
		tmp = 1.0 - (1.0 / beta);
	}
	return tmp;
}
def code(alpha, beta):
	tmp = 0
	if ((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.6:
		tmp = 1.0 / (2.0 + alpha)
	else:
		tmp = 1.0 - (1.0 / beta)
	return tmp
function code(alpha, beta)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.6)
		tmp = Float64(1.0 / Float64(2.0 + alpha));
	else
		tmp = Float64(1.0 - Float64(1.0 / beta));
	end
	return tmp
end
function tmp_2 = code(alpha, beta)
	tmp = 0.0;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.6)
		tmp = 1.0 / (2.0 + alpha);
	else
		tmp = 1.0 - (1.0 / beta);
	end
	tmp_2 = tmp;
end
code[alpha_, beta_] := If[LessEqual[N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], 0.6], N[(1.0 / N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(1.0 / beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.6:\\
\;\;\;\;\frac{1}{2 + \alpha}\\

\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{\beta}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)}{\mathsf{neg}\left(2\right)}} \]
      3. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1\right)\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)}} \]
      4. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{1 + \frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      8. frac-2negN/A

        \[\leadsto \frac{1 + \color{blue}{\frac{\mathsf{neg}\left(\left(\beta - \alpha\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      9. add-to-fractionN/A

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(2\right)\right)\right)} \]
      10. remove-double-negN/A

        \[\leadsto \frac{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)}}{\color{blue}{2}} \]
      11. associate-/l/N/A

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

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) + \left(\mathsf{neg}\left(\left(\beta - \alpha\right)\right)\right)}{\left(\mathsf{neg}\left(\left(\left(\alpha + \beta\right) + 2\right)\right)\right) \cdot 2}} \]
    3. Applied rewrites74.5%

      \[\leadsto \color{blue}{\frac{\left(\left(-2 - \alpha\right) - \beta\right) - \left(\beta - \alpha\right)}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2}} \]
    4. Taylor expanded in beta around 0

      \[\leadsto \color{blue}{\frac{1}{2 + \alpha}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{2 + \alpha}} \]
      2. lower-+.f6470.0

        \[\leadsto \frac{1}{2 + \color{blue}{\alpha}} \]
    6. Applied rewrites70.0%

      \[\leadsto \color{blue}{\frac{1}{2 + \alpha}} \]

    if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in alpha around 0

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(1 + \frac{\beta}{\color{blue}{2 + \beta}}\right) \]
      4. lower-+.f6472.4

        \[\leadsto 0.5 \cdot \left(1 + \frac{\beta}{2 + \color{blue}{\beta}}\right) \]
    4. Applied rewrites72.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + \frac{\beta}{2 + \beta}\right)} \]
    5. Taylor expanded in beta around inf

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

        \[\leadsto 1 - \frac{1}{\color{blue}{\beta}} \]
      2. lower-/.f6429.8

        \[\leadsto 1 - \frac{1}{\beta} \]
    7. Applied rewrites29.8%

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

Alternative 7: 92.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 0.05:\\ \;\;\;\;\frac{1}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.6:\\ \;\;\;\;\mathsf{fma}\left(\alpha, -0.25, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1}{\beta}\\ \end{array} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
   (if (<= t_0 0.05)
     (/ 1.0 alpha)
     (if (<= t_0 0.6) (fma alpha -0.25 0.5) (- 1.0 (/ 1.0 beta))))))
double code(double alpha, double beta) {
	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
	double tmp;
	if (t_0 <= 0.05) {
		tmp = 1.0 / alpha;
	} else if (t_0 <= 0.6) {
		tmp = fma(alpha, -0.25, 0.5);
	} else {
		tmp = 1.0 - (1.0 / beta);
	}
	return tmp;
}
function code(alpha, beta)
	t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0)
	tmp = 0.0
	if (t_0 <= 0.05)
		tmp = Float64(1.0 / alpha);
	elseif (t_0 <= 0.6)
		tmp = fma(alpha, -0.25, 0.5);
	else
		tmp = Float64(1.0 - Float64(1.0 / beta));
	end
	return tmp
end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(alpha * -0.25 + 0.5), $MachinePrecision], N[(1.0 - N[(1.0 / beta), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 0.05:\\
\;\;\;\;\frac{1}{\alpha}\\

\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(\alpha, -0.25, 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{\beta}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.050000000000000003

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in beta around 0

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(1 - \frac{\alpha}{\color{blue}{2 + \alpha}}\right) \]
      4. lower-+.f6449.8

        \[\leadsto 0.5 \cdot \left(1 - \frac{\alpha}{2 + \color{blue}{\alpha}}\right) \]
    4. Applied rewrites49.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(1 - \frac{\alpha}{2 + \alpha}\right)} \]
    5. Taylor expanded in alpha around inf

      \[\leadsto \frac{1}{\color{blue}{\alpha}} \]
    6. Step-by-step derivation
      1. lower-/.f6424.2

        \[\leadsto \frac{1}{\alpha} \]
    7. Applied rewrites24.2%

      \[\leadsto \frac{1}{\color{blue}{\alpha}} \]

    if 0.050000000000000003 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in beta around 0

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(1 - \frac{\alpha}{\color{blue}{2 + \alpha}}\right) \]
      4. lower-+.f6449.8

        \[\leadsto 0.5 \cdot \left(1 - \frac{\alpha}{2 + \color{blue}{\alpha}}\right) \]
    4. Applied rewrites49.8%

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

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

        \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{\alpha} \]
      2. lower-*.f6447.7

        \[\leadsto 0.5 + -0.25 \cdot \alpha \]
    7. Applied rewrites47.7%

      \[\leadsto 0.5 + \color{blue}{-0.25 \cdot \alpha} \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{\alpha} \]
      2. +-commutativeN/A

        \[\leadsto \frac{-1}{4} \cdot \alpha + \frac{1}{2} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \alpha + \frac{1}{2} \]
      4. *-commutativeN/A

        \[\leadsto \alpha \cdot \frac{-1}{4} + \frac{1}{2} \]
      5. lower-fma.f6447.7

        \[\leadsto \mathsf{fma}\left(\alpha, -0.25, 0.5\right) \]
    9. Applied rewrites47.7%

      \[\leadsto \mathsf{fma}\left(\alpha, -0.25, 0.5\right) \]

    if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in alpha around 0

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(1 + \frac{\beta}{\color{blue}{2 + \beta}}\right) \]
      4. lower-+.f6472.4

        \[\leadsto 0.5 \cdot \left(1 + \frac{\beta}{2 + \color{blue}{\beta}}\right) \]
    4. Applied rewrites72.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + \frac{\beta}{2 + \beta}\right)} \]
    5. Taylor expanded in beta around inf

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

        \[\leadsto 1 - \frac{1}{\color{blue}{\beta}} \]
      2. lower-/.f6429.8

        \[\leadsto 1 - \frac{1}{\beta} \]
    7. Applied rewrites29.8%

      \[\leadsto 1 - \color{blue}{\frac{1}{\beta}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 91.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 0.05:\\ \;\;\;\;\frac{1}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.6:\\ \;\;\;\;\mathsf{fma}\left(\alpha, -0.25, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
   (if (<= t_0 0.05)
     (/ 1.0 alpha)
     (if (<= t_0 0.6) (fma alpha -0.25 0.5) 1.0))))
double code(double alpha, double beta) {
	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
	double tmp;
	if (t_0 <= 0.05) {
		tmp = 1.0 / alpha;
	} else if (t_0 <= 0.6) {
		tmp = fma(alpha, -0.25, 0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(alpha, beta)
	t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0)
	tmp = 0.0
	if (t_0 <= 0.05)
		tmp = Float64(1.0 / alpha);
	elseif (t_0 <= 0.6)
		tmp = fma(alpha, -0.25, 0.5);
	else
		tmp = 1.0;
	end
	return tmp
end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(alpha * -0.25 + 0.5), $MachinePrecision], 1.0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 0.05:\\
\;\;\;\;\frac{1}{\alpha}\\

\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(\alpha, -0.25, 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.050000000000000003

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in beta around 0

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(1 - \frac{\alpha}{\color{blue}{2 + \alpha}}\right) \]
      4. lower-+.f6449.8

        \[\leadsto 0.5 \cdot \left(1 - \frac{\alpha}{2 + \color{blue}{\alpha}}\right) \]
    4. Applied rewrites49.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(1 - \frac{\alpha}{2 + \alpha}\right)} \]
    5. Taylor expanded in alpha around inf

      \[\leadsto \frac{1}{\color{blue}{\alpha}} \]
    6. Step-by-step derivation
      1. lower-/.f6424.2

        \[\leadsto \frac{1}{\alpha} \]
    7. Applied rewrites24.2%

      \[\leadsto \frac{1}{\color{blue}{\alpha}} \]

    if 0.050000000000000003 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in beta around 0

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(1 - \frac{\alpha}{\color{blue}{2 + \alpha}}\right) \]
      4. lower-+.f6449.8

        \[\leadsto 0.5 \cdot \left(1 - \frac{\alpha}{2 + \color{blue}{\alpha}}\right) \]
    4. Applied rewrites49.8%

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

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

        \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{\alpha} \]
      2. lower-*.f6447.7

        \[\leadsto 0.5 + -0.25 \cdot \alpha \]
    7. Applied rewrites47.7%

      \[\leadsto 0.5 + \color{blue}{-0.25 \cdot \alpha} \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{1}{2} + \frac{-1}{4} \cdot \color{blue}{\alpha} \]
      2. +-commutativeN/A

        \[\leadsto \frac{-1}{4} \cdot \alpha + \frac{1}{2} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{-1}{4} \cdot \alpha + \frac{1}{2} \]
      4. *-commutativeN/A

        \[\leadsto \alpha \cdot \frac{-1}{4} + \frac{1}{2} \]
      5. lower-fma.f6447.7

        \[\leadsto \mathsf{fma}\left(\alpha, -0.25, 0.5\right) \]
    9. Applied rewrites47.7%

      \[\leadsto \mathsf{fma}\left(\alpha, -0.25, 0.5\right) \]

    if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

    1. Initial program 74.2%

      \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
    2. Taylor expanded in beta around inf

      \[\leadsto \color{blue}{1} \]
    3. Step-by-step derivation
      1. Applied rewrites37.0%

        \[\leadsto \color{blue}{1} \]
    4. Recombined 3 regimes into one program.
    5. Add Preprocessing

    Alternative 9: 91.8% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 0.05:\\ \;\;\;\;\frac{1}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.6:\\ \;\;\;\;\mathsf{fma}\left(\beta, 0.25, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
    (FPCore (alpha beta)
     :precision binary64
     (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
       (if (<= t_0 0.05) (/ 1.0 alpha) (if (<= t_0 0.6) (fma beta 0.25 0.5) 1.0))))
    double code(double alpha, double beta) {
    	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
    	double tmp;
    	if (t_0 <= 0.05) {
    		tmp = 1.0 / alpha;
    	} else if (t_0 <= 0.6) {
    		tmp = fma(beta, 0.25, 0.5);
    	} else {
    		tmp = 1.0;
    	}
    	return tmp;
    }
    
    function code(alpha, beta)
    	t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0)
    	tmp = 0.0
    	if (t_0 <= 0.05)
    		tmp = Float64(1.0 / alpha);
    	elseif (t_0 <= 0.6)
    		tmp = fma(beta, 0.25, 0.5);
    	else
    		tmp = 1.0;
    	end
    	return tmp
    end
    
    code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(beta * 0.25 + 0.5), $MachinePrecision], 1.0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
    \mathbf{if}\;t\_0 \leq 0.05:\\
    \;\;\;\;\frac{1}{\alpha}\\
    
    \mathbf{elif}\;t\_0 \leq 0.6:\\
    \;\;\;\;\mathsf{fma}\left(\beta, 0.25, 0.5\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.050000000000000003

      1. Initial program 74.2%

        \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
      2. Taylor expanded in beta around 0

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

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

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

          \[\leadsto \frac{1}{2} \cdot \left(1 - \frac{\alpha}{\color{blue}{2 + \alpha}}\right) \]
        4. lower-+.f6449.8

          \[\leadsto 0.5 \cdot \left(1 - \frac{\alpha}{2 + \color{blue}{\alpha}}\right) \]
      4. Applied rewrites49.8%

        \[\leadsto \color{blue}{0.5 \cdot \left(1 - \frac{\alpha}{2 + \alpha}\right)} \]
      5. Taylor expanded in alpha around inf

        \[\leadsto \frac{1}{\color{blue}{\alpha}} \]
      6. Step-by-step derivation
        1. lower-/.f6424.2

          \[\leadsto \frac{1}{\alpha} \]
      7. Applied rewrites24.2%

        \[\leadsto \frac{1}{\color{blue}{\alpha}} \]

      if 0.050000000000000003 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978

      1. Initial program 74.2%

        \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
      2. Taylor expanded in alpha around 0

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

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

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

          \[\leadsto \frac{1}{2} \cdot \left(1 + \frac{\beta}{\color{blue}{2 + \beta}}\right) \]
        4. lower-+.f6472.4

          \[\leadsto 0.5 \cdot \left(1 + \frac{\beta}{2 + \color{blue}{\beta}}\right) \]
      4. Applied rewrites72.4%

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

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

          \[\leadsto \frac{1}{2} + \frac{1}{4} \cdot \color{blue}{\beta} \]
        2. lower-*.f6445.8

          \[\leadsto 0.5 + 0.25 \cdot \beta \]
      7. Applied rewrites45.8%

        \[\leadsto 0.5 + \color{blue}{0.25 \cdot \beta} \]
      8. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \frac{1}{2} + \frac{1}{4} \cdot \color{blue}{\beta} \]
        2. +-commutativeN/A

          \[\leadsto \frac{1}{4} \cdot \beta + \frac{1}{2} \]
        3. lift-*.f64N/A

          \[\leadsto \frac{1}{4} \cdot \beta + \frac{1}{2} \]
        4. *-commutativeN/A

          \[\leadsto \beta \cdot \frac{1}{4} + \frac{1}{2} \]
        5. lower-fma.f6445.8

          \[\leadsto \mathsf{fma}\left(\beta, 0.25, 0.5\right) \]
      9. Applied rewrites45.8%

        \[\leadsto \mathsf{fma}\left(\beta, 0.25, 0.5\right) \]

      if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

      1. Initial program 74.2%

        \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
      2. Taylor expanded in beta around inf

        \[\leadsto \color{blue}{1} \]
      3. Step-by-step derivation
        1. Applied rewrites37.0%

          \[\leadsto \color{blue}{1} \]
      4. Recombined 3 regimes into one program.
      5. Add Preprocessing

      Alternative 10: 91.4% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 0.05:\\ \;\;\;\;\frac{1}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.6:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
      (FPCore (alpha beta)
       :precision binary64
       (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
         (if (<= t_0 0.05) (/ 1.0 alpha) (if (<= t_0 0.6) 0.5 1.0))))
      double code(double alpha, double beta) {
      	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
      	double tmp;
      	if (t_0 <= 0.05) {
      		tmp = 1.0 / alpha;
      	} else if (t_0 <= 0.6) {
      		tmp = 0.5;
      	} else {
      		tmp = 1.0;
      	}
      	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(alpha, beta)
      use fmin_fmax_functions
          real(8), intent (in) :: alpha
          real(8), intent (in) :: beta
          real(8) :: t_0
          real(8) :: tmp
          t_0 = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
          if (t_0 <= 0.05d0) then
              tmp = 1.0d0 / alpha
          else if (t_0 <= 0.6d0) then
              tmp = 0.5d0
          else
              tmp = 1.0d0
          end if
          code = tmp
      end function
      
      public static double code(double alpha, double beta) {
      	double t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
      	double tmp;
      	if (t_0 <= 0.05) {
      		tmp = 1.0 / alpha;
      	} else if (t_0 <= 0.6) {
      		tmp = 0.5;
      	} else {
      		tmp = 1.0;
      	}
      	return tmp;
      }
      
      def code(alpha, beta):
      	t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
      	tmp = 0
      	if t_0 <= 0.05:
      		tmp = 1.0 / alpha
      	elif t_0 <= 0.6:
      		tmp = 0.5
      	else:
      		tmp = 1.0
      	return tmp
      
      function code(alpha, beta)
      	t_0 = Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0)
      	tmp = 0.0
      	if (t_0 <= 0.05)
      		tmp = Float64(1.0 / alpha);
      	elseif (t_0 <= 0.6)
      		tmp = 0.5;
      	else
      		tmp = 1.0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(alpha, beta)
      	t_0 = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
      	tmp = 0.0;
      	if (t_0 <= 0.05)
      		tmp = 1.0 / alpha;
      	elseif (t_0 <= 0.6)
      		tmp = 0.5;
      	else
      		tmp = 1.0;
      	end
      	tmp_2 = tmp;
      end
      
      code[alpha_, beta_] := Block[{t$95$0 = N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], 0.5, 1.0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
      \mathbf{if}\;t\_0 \leq 0.05:\\
      \;\;\;\;\frac{1}{\alpha}\\
      
      \mathbf{elif}\;t\_0 \leq 0.6:\\
      \;\;\;\;0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.050000000000000003

        1. Initial program 74.2%

          \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
        2. Taylor expanded in beta around 0

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

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

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

            \[\leadsto \frac{1}{2} \cdot \left(1 - \frac{\alpha}{\color{blue}{2 + \alpha}}\right) \]
          4. lower-+.f6449.8

            \[\leadsto 0.5 \cdot \left(1 - \frac{\alpha}{2 + \color{blue}{\alpha}}\right) \]
        4. Applied rewrites49.8%

          \[\leadsto \color{blue}{0.5 \cdot \left(1 - \frac{\alpha}{2 + \alpha}\right)} \]
        5. Taylor expanded in alpha around inf

          \[\leadsto \frac{1}{\color{blue}{\alpha}} \]
        6. Step-by-step derivation
          1. lower-/.f6424.2

            \[\leadsto \frac{1}{\alpha} \]
        7. Applied rewrites24.2%

          \[\leadsto \frac{1}{\color{blue}{\alpha}} \]

        if 0.050000000000000003 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.599999999999999978

        1. Initial program 74.2%

          \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
        2. Taylor expanded in beta around 0

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

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

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

            \[\leadsto \frac{1}{2} \cdot \left(1 - \frac{\alpha}{\color{blue}{2 + \alpha}}\right) \]
          4. lower-+.f6449.8

            \[\leadsto 0.5 \cdot \left(1 - \frac{\alpha}{2 + \color{blue}{\alpha}}\right) \]
        4. Applied rewrites49.8%

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

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

            \[\leadsto 0.5 \]

          if 0.599999999999999978 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

          1. Initial program 74.2%

            \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
          2. Taylor expanded in beta around inf

            \[\leadsto \color{blue}{1} \]
          3. Step-by-step derivation
            1. Applied rewrites37.0%

              \[\leadsto \color{blue}{1} \]
          4. Recombined 3 regimes into one program.
          5. Add Preprocessing

          Alternative 11: 71.3% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.75:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
          (FPCore (alpha beta)
           :precision binary64
           (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.75)
             0.5
             1.0))
          double code(double alpha, double beta) {
          	double tmp;
          	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75) {
          		tmp = 0.5;
          	} else {
          		tmp = 1.0;
          	}
          	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(alpha, beta)
          use fmin_fmax_functions
              real(8), intent (in) :: alpha
              real(8), intent (in) :: beta
              real(8) :: tmp
              if (((((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0) <= 0.75d0) then
                  tmp = 0.5d0
              else
                  tmp = 1.0d0
              end if
              code = tmp
          end function
          
          public static double code(double alpha, double beta) {
          	double tmp;
          	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75) {
          		tmp = 0.5;
          	} else {
          		tmp = 1.0;
          	}
          	return tmp;
          }
          
          def code(alpha, beta):
          	tmp = 0
          	if ((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75:
          		tmp = 0.5
          	else:
          		tmp = 1.0
          	return tmp
          
          function code(alpha, beta)
          	tmp = 0.0
          	if (Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75)
          		tmp = 0.5;
          	else
          		tmp = 1.0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(alpha, beta)
          	tmp = 0.0;
          	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.75)
          		tmp = 0.5;
          	else
          		tmp = 1.0;
          	end
          	tmp_2 = tmp;
          end
          
          code[alpha_, beta_] := If[LessEqual[N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], 0.75], 0.5, 1.0]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.75:\\
          \;\;\;\;0.5\\
          
          \mathbf{else}:\\
          \;\;\;\;1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.75

            1. Initial program 74.2%

              \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
            2. Taylor expanded in beta around 0

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

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

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

                \[\leadsto \frac{1}{2} \cdot \left(1 - \frac{\alpha}{\color{blue}{2 + \alpha}}\right) \]
              4. lower-+.f6449.8

                \[\leadsto 0.5 \cdot \left(1 - \frac{\alpha}{2 + \color{blue}{\alpha}}\right) \]
            4. Applied rewrites49.8%

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

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

                \[\leadsto 0.5 \]

              if 0.75 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64))

              1. Initial program 74.2%

                \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
              2. Taylor expanded in beta around inf

                \[\leadsto \color{blue}{1} \]
              3. Step-by-step derivation
                1. Applied rewrites37.0%

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

              Alternative 12: 37.0% accurate, 18.5× speedup?

              \[\begin{array}{l} \\ 1 \end{array} \]
              (FPCore (alpha beta) :precision binary64 1.0)
              double code(double alpha, double beta) {
              	return 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(alpha, beta)
              use fmin_fmax_functions
                  real(8), intent (in) :: alpha
                  real(8), intent (in) :: beta
                  code = 1.0d0
              end function
              
              public static double code(double alpha, double beta) {
              	return 1.0;
              }
              
              def code(alpha, beta):
              	return 1.0
              
              function code(alpha, beta)
              	return 1.0
              end
              
              function tmp = code(alpha, beta)
              	tmp = 1.0;
              end
              
              code[alpha_, beta_] := 1.0
              
              \begin{array}{l}
              
              \\
              1
              \end{array}
              
              Derivation
              1. Initial program 74.2%

                \[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
              2. Taylor expanded in beta around inf

                \[\leadsto \color{blue}{1} \]
              3. Step-by-step derivation
                1. Applied rewrites37.0%

                  \[\leadsto \color{blue}{1} \]
                2. Add Preprocessing

                Reproduce

                ?
                herbie shell --seed 2025164 
                (FPCore (alpha beta)
                  :name "Octave 3.8, jcobi/1"
                  :precision binary64
                  :pre (and (> alpha -1.0) (> beta -1.0))
                  (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))