Octave 3.8, jcobi/1

Percentage Accurate: 75.3% → 99.9%
Time: 3.4s
Alternatives: 13
Speedup: 1.1×

Specification

?
\[\alpha > -1 \land \beta > -1\]
\[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
(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]
\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}

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

\[\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \]
(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]
\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}

Alternative 1: 99.9% accurate, 1.1× speedup?

\[\frac{\mathsf{fma}\left(\beta, -2, -2\right)}{\left(-2 - \alpha\right) - \beta} \cdot 0.5 \]
(FPCore (alpha beta)
 :precision binary64
 (* (/ (fma beta -2.0 -2.0) (- (- -2.0 alpha) beta)) 0.5))
double code(double alpha, double beta) {
	return (fma(beta, -2.0, -2.0) / ((-2.0 - alpha) - beta)) * 0.5;
}
function code(alpha, beta)
	return Float64(Float64(fma(beta, -2.0, -2.0) / Float64(Float64(-2.0 - alpha) - beta)) * 0.5)
end
code[alpha_, beta_] := N[(N[(N[(beta * -2.0 + -2.0), $MachinePrecision] / N[(N[(-2.0 - alpha), $MachinePrecision] - beta), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\frac{\mathsf{fma}\left(\beta, -2, -2\right)}{\left(-2 - \alpha\right) - \beta} \cdot 0.5
Derivation
  1. Initial program 75.3%

    \[\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 rewrites75.6%

    \[\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 \frac{\color{blue}{-2 \cdot \beta - 2}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
  5. Step-by-step derivation
    1. lower--.f64N/A

      \[\leadsto \frac{-2 \cdot \beta - \color{blue}{2}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    2. lower-*.f6499.9%

      \[\leadsto \frac{-2 \cdot \beta - 2}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
  6. Applied rewrites99.9%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{-2 \cdot \beta - 2}{\left(-2 - \alpha\right) - \beta}}{2}} \]
    4. mult-flipN/A

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

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

      \[\leadsto \color{blue}{\frac{-2 \cdot \beta - 2}{\left(-2 - \alpha\right) - \beta} \cdot \frac{1}{2}} \]
    7. lower-/.f6499.9%

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

      \[\leadsto \frac{-2 \cdot \beta - \color{blue}{2}}{\left(-2 - \alpha\right) - \beta} \cdot \frac{1}{2} \]
    9. sub-flipN/A

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

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

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

      \[\leadsto \frac{\beta \cdot -2 + -2}{\left(-2 - \alpha\right) - \beta} \cdot \frac{1}{2} \]
    13. lower-fma.f6499.9%

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

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

Alternative 2: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\frac{-2 \cdot \beta - 2}{-2 \cdot \left(2 + \alpha\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\beta - \alpha}{\alpha - \left(-2 - \beta\right)}, 0.5, 0.5\right)\\ \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 2e-5)
   (/ (- (* -2.0 beta) 2.0) (* -2.0 (+ 2.0 alpha)))
   (fma (/ (- beta alpha) (- alpha (- -2.0 beta))) 0.5 0.5)))
double code(double alpha, double beta) {
	double tmp;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 2e-5) {
		tmp = ((-2.0 * beta) - 2.0) / (-2.0 * (2.0 + alpha));
	} else {
		tmp = fma(((beta - alpha) / (alpha - (-2.0 - beta))), 0.5, 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) <= 2e-5)
		tmp = Float64(Float64(Float64(-2.0 * beta) - 2.0) / Float64(-2.0 * Float64(2.0 + alpha)));
	else
		tmp = fma(Float64(Float64(beta - alpha) / Float64(alpha - Float64(-2.0 - beta))), 0.5, 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], 2e-5], N[(N[(N[(-2.0 * beta), $MachinePrecision] - 2.0), $MachinePrecision] / N[(-2.0 * N[(2.0 + alpha), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(beta - alpha), $MachinePrecision] / N[(alpha - N[(-2.0 - beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{-2 \cdot \beta - 2}{-2 \cdot \left(2 + \alpha\right)}\\

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


\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)) < 2.0000000000000002e-5

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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 \frac{\color{blue}{-2 \cdot \beta - 2}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    5. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto \frac{-2 \cdot \beta - \color{blue}{2}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
      2. lower-*.f6499.9%

        \[\leadsto \frac{-2 \cdot \beta - 2}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    6. Applied rewrites99.9%

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

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

        \[\leadsto \frac{-2 \cdot \beta - 2}{-2 \cdot \color{blue}{\left(2 + \alpha\right)}} \]
      2. lower-+.f6471.7%

        \[\leadsto \frac{-2 \cdot \beta - 2}{-2 \cdot \left(2 + \color{blue}{\alpha}\right)} \]
    9. Applied rewrites71.7%

      \[\leadsto \frac{-2 \cdot \beta - 2}{\color{blue}{-2 \cdot \left(2 + \alpha\right)}} \]

    if 2.0000000000000002e-5 < (/.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 75.3%

      \[\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. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\beta - \alpha}{\alpha - \left(-2 - \beta\right)}, \color{blue}{\frac{1}{2}}, \frac{1}{2}\right) \]
      18. metadata-eval75.3%

        \[\leadsto \mathsf{fma}\left(\frac{\beta - \alpha}{\alpha - \left(-2 - \beta\right)}, 0.5, \color{blue}{0.5}\right) \]
    3. Applied rewrites75.3%

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

Alternative 3: 98.3% accurate, 1.0× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if beta < 1.75e9

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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 \frac{\color{blue}{-2 \cdot \beta - 2}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    5. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto \frac{-2 \cdot \beta - \color{blue}{2}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
      2. lower-*.f6499.9%

        \[\leadsto \frac{-2 \cdot \beta - 2}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    6. Applied rewrites99.9%

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

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

        \[\leadsto \frac{-2 \cdot \beta - 2}{-2 \cdot \color{blue}{\left(2 + \alpha\right)}} \]
      2. lower-+.f6471.7%

        \[\leadsto \frac{-2 \cdot \beta - 2}{-2 \cdot \left(2 + \color{blue}{\alpha}\right)} \]
    9. Applied rewrites71.7%

      \[\leadsto \frac{-2 \cdot \beta - 2}{\color{blue}{-2 \cdot \left(2 + \alpha\right)}} \]

    if 1.75e9 < beta

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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}{-2 \cdot \beta}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    5. Step-by-step derivation
      1. lower-*.f6436.1%

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

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

Alternative 4: 98.1% accurate, 1.0× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if beta < 52000

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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-+.f6469.8%

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

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

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

        \[\leadsto \frac{1}{\alpha + \color{blue}{2}} \]
      3. add-flip-revN/A

        \[\leadsto \frac{1}{\alpha - \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}} \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\alpha - -2} \]
      5. lower--.f6469.8%

        \[\leadsto \frac{1}{\alpha - \color{blue}{-2}} \]
    8. Applied rewrites69.8%

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

    if 52000 < beta

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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}{-2 \cdot \beta}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    5. Step-by-step derivation
      1. lower-*.f6436.1%

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

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

Alternative 5: 97.9% accurate, 0.6× speedup?

\[\begin{array}{l} \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.2:\\ \;\;\;\;\frac{\mathsf{fma}\left(\beta, -2, -2\right)}{\alpha \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\beta}{\beta - -2}, 0.5, 0.5\right)\\ \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.2)
   (/ (fma beta -2.0 -2.0) (* alpha -2.0))
   (fma (/ beta (- beta -2.0)) 0.5 0.5)))
double code(double alpha, double beta) {
	double tmp;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.2) {
		tmp = fma(beta, -2.0, -2.0) / (alpha * -2.0);
	} else {
		tmp = fma((beta / (beta - -2.0)), 0.5, 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.2)
		tmp = Float64(fma(beta, -2.0, -2.0) / Float64(alpha * -2.0));
	else
		tmp = fma(Float64(beta / Float64(beta - -2.0)), 0.5, 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.2], N[(N[(beta * -2.0 + -2.0), $MachinePrecision] / N[(alpha * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(beta / N[(beta - -2.0), $MachinePrecision]), $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.2:\\
\;\;\;\;\frac{\mathsf{fma}\left(\beta, -2, -2\right)}{\alpha \cdot -2}\\

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


\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.20000000000000001

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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 \frac{\color{blue}{-2 \cdot \beta - 2}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    5. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto \frac{-2 \cdot \beta - \color{blue}{2}}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
      2. lower-*.f6499.9%

        \[\leadsto \frac{-2 \cdot \beta - 2}{\left(\left(-2 - \alpha\right) - \beta\right) \cdot 2} \]
    6. Applied rewrites99.9%

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

      \[\leadsto \frac{-2 \cdot \beta - 2}{\color{blue}{-2 \cdot \alpha}} \]
    8. Step-by-step derivation
      1. lower-*.f6428.7%

        \[\leadsto \frac{-2 \cdot \beta - 2}{-2 \cdot \color{blue}{\alpha}} \]
    9. Applied rewrites28.7%

      \[\leadsto \frac{-2 \cdot \beta - 2}{\color{blue}{-2 \cdot \alpha}} \]
    10. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \frac{-2 \cdot \beta - 2}{-2 \cdot \alpha} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\beta \cdot -2 - 2}{-2 \cdot \alpha} \]
      4. metadata-evalN/A

        \[\leadsto \frac{\beta \cdot -2 - \left(\mathsf{neg}\left(-2\right)\right)}{-2 \cdot \alpha} \]
      5. add-flipN/A

        \[\leadsto \frac{\beta \cdot -2 + \color{blue}{-2}}{-2 \cdot \alpha} \]
      6. lift-fma.f6428.7%

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

        \[\leadsto \frac{\mathsf{fma}\left(\beta, \color{blue}{-2}, -2\right)}{\mathsf{Rewrite=>}\left(lift-*.f64, \left(-2 \cdot \alpha\right)\right)} \]
      8. lift-fma.f64N/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\beta, \color{blue}{-2}, -2\right)}{\mathsf{Rewrite=>}\left(lower-*.f64, \left(\alpha \cdot -2\right)\right)} \]
    11. Applied rewrites28.7%

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

    if 0.20000000000000001 < (/.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 75.3%

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

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

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

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

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

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

Alternative 6: 93.3% accurate, 0.6× speedup?

\[\begin{array}{l} \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.6:\\ \;\;\;\;\frac{1}{\alpha - -2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\alpha + \alpha}{\beta}, -0.5, 1\right)\\ \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.6)
   (/ 1.0 (- alpha -2.0))
   (fma (/ (+ alpha alpha) beta) -0.5 1.0)))
double code(double alpha, double beta) {
	double tmp;
	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.6) {
		tmp = 1.0 / (alpha - -2.0);
	} else {
		tmp = fma(((alpha + alpha) / beta), -0.5, 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.6)
		tmp = Float64(1.0 / Float64(alpha - -2.0));
	else
		tmp = fma(Float64(Float64(alpha + alpha) / beta), -0.5, 1.0);
	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.6], N[(1.0 / N[(alpha - -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(alpha + alpha), $MachinePrecision] / beta), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.6:\\
\;\;\;\;\frac{1}{\alpha - -2}\\

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


\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.59999999999999998

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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-+.f6469.8%

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

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

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

        \[\leadsto \frac{1}{\alpha + \color{blue}{2}} \]
      3. add-flip-revN/A

        \[\leadsto \frac{1}{\alpha - \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}} \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\alpha - -2} \]
      5. lower--.f6469.8%

        \[\leadsto \frac{1}{\alpha - \color{blue}{-2}} \]
    8. Applied rewrites69.8%

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

    if 0.59999999999999998 < (/.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 75.3%

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

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

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

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

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

        \[\leadsto 1 + \frac{-1}{2} \cdot \frac{2 + 2 \cdot \alpha}{\beta} \]
      5. lower-*.f6430.3%

        \[\leadsto 1 + -0.5 \cdot \frac{2 + 2 \cdot \alpha}{\beta} \]
    4. Applied rewrites30.3%

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

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

        \[\leadsto 1 + \frac{-1}{2} \cdot \left(2 \cdot \frac{\alpha}{\color{blue}{\beta}}\right) \]
      2. lower-/.f6433.7%

        \[\leadsto 1 + -0.5 \cdot \left(2 \cdot \frac{\alpha}{\beta}\right) \]
    7. Applied rewrites33.7%

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

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

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

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

        \[\leadsto \left(2 \cdot \frac{\alpha}{\beta}\right) \cdot \frac{-1}{2} + 1 \]
      5. lower-fma.f6433.7%

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

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

        \[\leadsto \mathsf{fma}\left(2 \cdot \frac{\alpha}{\beta}, \frac{-1}{2}, 1\right) \]
      8. associate-*r/N/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\alpha + \alpha}{\beta}, \frac{-1}{2}, 1\right) \]
      11. lower-+.f6433.7%

        \[\leadsto \mathsf{fma}\left(\frac{\alpha + \alpha}{\beta}, -0.5, 1\right) \]
    9. Applied rewrites33.7%

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

Alternative 7: 93.2% accurate, 0.7× speedup?

\[\begin{array}{l} \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.6:\\ \;\;\;\;\frac{1}{\alpha - -2}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1}{\beta}\\ \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.6)
   (/ 1.0 (- alpha -2.0))
   (- 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 / (alpha - -2.0);
	} 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 / (alpha - (-2.0d0))
    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 / (alpha - -2.0);
	} 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 / (alpha - -2.0)
	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(alpha - -2.0));
	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 / (alpha - -2.0);
	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[(alpha - -2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(1.0 / beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.6:\\
\;\;\;\;\frac{1}{\alpha - -2}\\

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


\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.59999999999999998

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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-+.f6469.8%

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

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

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

        \[\leadsto \frac{1}{\alpha + \color{blue}{2}} \]
      3. add-flip-revN/A

        \[\leadsto \frac{1}{\alpha - \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}} \]
      4. metadata-evalN/A

        \[\leadsto \frac{1}{\alpha - -2} \]
      5. lower--.f6469.8%

        \[\leadsto \frac{1}{\alpha - \color{blue}{-2}} \]
    8. Applied rewrites69.8%

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

    if 0.59999999999999998 < (/.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 75.3%

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

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

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

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

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

        \[\leadsto 1 + \frac{-1}{2} \cdot \frac{2 + 2 \cdot \alpha}{\beta} \]
      5. lower-*.f6430.3%

        \[\leadsto 1 + -0.5 \cdot \frac{2 + 2 \cdot \alpha}{\beta} \]
    4. Applied rewrites30.3%

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

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

        \[\leadsto 1 - \frac{1}{\beta} \]
    7. Applied rewrites30.5%

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

Alternative 8: 92.5% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 0.2:\\ \;\;\;\;\frac{1}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.6:\\ \;\;\;\;0.5 + -0.25 \cdot \alpha\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1}{\beta}\\ \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
   (if (<= t_0 0.2)
     (/ 1.0 alpha)
     (if (<= t_0 0.6) (+ 0.5 (* -0.25 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.2) {
		tmp = 1.0 / alpha;
	} else if (t_0 <= 0.6) {
		tmp = 0.5 + (-0.25 * 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.2d0) then
        tmp = 1.0d0 / alpha
    else if (t_0 <= 0.6d0) then
        tmp = 0.5d0 + ((-0.25d0) * 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.2) {
		tmp = 1.0 / alpha;
	} else if (t_0 <= 0.6) {
		tmp = 0.5 + (-0.25 * 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.2:
		tmp = 1.0 / alpha
	elif t_0 <= 0.6:
		tmp = 0.5 + (-0.25 * 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.2)
		tmp = Float64(1.0 / alpha);
	elseif (t_0 <= 0.6)
		tmp = Float64(0.5 + Float64(-0.25 * 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.2)
		tmp = 1.0 / alpha;
	elseif (t_0 <= 0.6)
		tmp = 0.5 + (-0.25 * 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.2], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(0.5 + N[(-0.25 * alpha), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(1.0 / beta), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 0.2:\\
\;\;\;\;\frac{1}{\alpha}\\

\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;0.5 + -0.25 \cdot \alpha\\

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


\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.20000000000000001

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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-+.f6469.8%

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

      \[\leadsto \color{blue}{\frac{1}{2 + \alpha}} \]
    7. Taylor expanded in alpha around inf

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

        \[\leadsto \frac{1}{\alpha} \]
    9. Applied rewrites24.0%

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

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

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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-+.f6469.8%

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

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

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

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

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

      \[\leadsto 0.5 + \color{blue}{-0.25 \cdot \alpha} \]

    if 0.59999999999999998 < (/.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 75.3%

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

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

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

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

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

        \[\leadsto 1 + \frac{-1}{2} \cdot \frac{2 + 2 \cdot \alpha}{\beta} \]
      5. lower-*.f6430.3%

        \[\leadsto 1 + -0.5 \cdot \frac{2 + 2 \cdot \alpha}{\beta} \]
    4. Applied rewrites30.3%

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

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

        \[\leadsto 1 - \frac{1}{\beta} \]
    7. Applied rewrites30.5%

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

Alternative 9: 92.3% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 0.2:\\ \;\;\;\;\frac{1}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.6:\\ \;\;\;\;0.5 + -0.25 \cdot \alpha\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
(FPCore (alpha beta)
 :precision binary64
 (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
   (if (<= t_0 0.2)
     (/ 1.0 alpha)
     (if (<= t_0 0.6) (+ 0.5 (* -0.25 alpha)) 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.2) {
		tmp = 1.0 / alpha;
	} else if (t_0 <= 0.6) {
		tmp = 0.5 + (-0.25 * alpha);
	} 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.2d0) then
        tmp = 1.0d0 / alpha
    else if (t_0 <= 0.6d0) then
        tmp = 0.5d0 + ((-0.25d0) * alpha)
    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.2) {
		tmp = 1.0 / alpha;
	} else if (t_0 <= 0.6) {
		tmp = 0.5 + (-0.25 * alpha);
	} 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.2:
		tmp = 1.0 / alpha
	elif t_0 <= 0.6:
		tmp = 0.5 + (-0.25 * alpha)
	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.2)
		tmp = Float64(1.0 / alpha);
	elseif (t_0 <= 0.6)
		tmp = Float64(0.5 + Float64(-0.25 * alpha));
	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.2)
		tmp = 1.0 / alpha;
	elseif (t_0 <= 0.6)
		tmp = 0.5 + (-0.25 * alpha);
	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.2], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(0.5 + N[(-0.25 * alpha), $MachinePrecision]), $MachinePrecision], 1.0]]]
\begin{array}{l}
t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
\mathbf{if}\;t\_0 \leq 0.2:\\
\;\;\;\;\frac{1}{\alpha}\\

\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;0.5 + -0.25 \cdot \alpha\\

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


\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.20000000000000001

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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-+.f6469.8%

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

      \[\leadsto \color{blue}{\frac{1}{2 + \alpha}} \]
    7. Taylor expanded in alpha around inf

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

        \[\leadsto \frac{1}{\alpha} \]
    9. Applied rewrites24.0%

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

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

    1. Initial program 75.3%

      \[\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 rewrites75.6%

      \[\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-+.f6469.8%

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

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

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

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

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

      \[\leadsto 0.5 + \color{blue}{-0.25 \cdot \alpha} \]

    if 0.59999999999999998 < (/.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 75.3%

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

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

    Alternative 10: 92.3% accurate, 0.4× speedup?

    \[\begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 0.2:\\ \;\;\;\;\frac{1}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.6:\\ \;\;\;\;0.5 + 0.25 \cdot \beta\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
    (FPCore (alpha beta)
     :precision binary64
     (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
       (if (<= t_0 0.2)
         (/ 1.0 alpha)
         (if (<= t_0 0.6) (+ 0.5 (* 0.25 beta)) 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.2) {
    		tmp = 1.0 / alpha;
    	} else if (t_0 <= 0.6) {
    		tmp = 0.5 + (0.25 * beta);
    	} 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.2d0) then
            tmp = 1.0d0 / alpha
        else if (t_0 <= 0.6d0) then
            tmp = 0.5d0 + (0.25d0 * beta)
        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.2) {
    		tmp = 1.0 / alpha;
    	} else if (t_0 <= 0.6) {
    		tmp = 0.5 + (0.25 * beta);
    	} 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.2:
    		tmp = 1.0 / alpha
    	elif t_0 <= 0.6:
    		tmp = 0.5 + (0.25 * beta)
    	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.2)
    		tmp = Float64(1.0 / alpha);
    	elseif (t_0 <= 0.6)
    		tmp = Float64(0.5 + Float64(0.25 * beta));
    	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.2)
    		tmp = 1.0 / alpha;
    	elseif (t_0 <= 0.6)
    		tmp = 0.5 + (0.25 * beta);
    	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.2], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(0.5 + N[(0.25 * beta), $MachinePrecision]), $MachinePrecision], 1.0]]]
    
    \begin{array}{l}
    t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
    \mathbf{if}\;t\_0 \leq 0.2:\\
    \;\;\;\;\frac{1}{\alpha}\\
    
    \mathbf{elif}\;t\_0 \leq 0.6:\\
    \;\;\;\;0.5 + 0.25 \cdot \beta\\
    
    \mathbf{else}:\\
    \;\;\;\;1\\
    
    
    \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.20000000000000001

      1. Initial program 75.3%

        \[\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 rewrites75.6%

        \[\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-+.f6469.8%

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

        \[\leadsto \color{blue}{\frac{1}{2 + \alpha}} \]
      7. Taylor expanded in alpha around inf

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

          \[\leadsto \frac{1}{\alpha} \]
      9. Applied rewrites24.0%

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

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

      1. Initial program 75.3%

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

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

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

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

        \[\leadsto 0.5 + \color{blue}{0.25 \cdot \beta} \]

      if 0.59999999999999998 < (/.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 75.3%

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

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

      Alternative 11: 91.8% accurate, 0.4× speedup?

      \[\begin{array}{l} t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\ \mathbf{if}\;t\_0 \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\frac{1}{\alpha}\\ \mathbf{elif}\;t\_0 \leq 0.8:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
      (FPCore (alpha beta)
       :precision binary64
       (let* ((t_0 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0)))
         (if (<= t_0 2e-5) (/ 1.0 alpha) (if (<= t_0 0.8) 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 <= 2e-5) {
      		tmp = 1.0 / alpha;
      	} else if (t_0 <= 0.8) {
      		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 <= 2d-5) then
              tmp = 1.0d0 / alpha
          else if (t_0 <= 0.8d0) 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 <= 2e-5) {
      		tmp = 1.0 / alpha;
      	} else if (t_0 <= 0.8) {
      		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 <= 2e-5:
      		tmp = 1.0 / alpha
      	elif t_0 <= 0.8:
      		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 <= 2e-5)
      		tmp = Float64(1.0 / alpha);
      	elseif (t_0 <= 0.8)
      		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 <= 2e-5)
      		tmp = 1.0 / alpha;
      	elseif (t_0 <= 0.8)
      		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, 2e-5], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[t$95$0, 0.8], 0.5, 1.0]]]
      
      \begin{array}{l}
      t_0 := \frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}\\
      \mathbf{if}\;t\_0 \leq 2 \cdot 10^{-5}:\\
      \;\;\;\;\frac{1}{\alpha}\\
      
      \mathbf{elif}\;t\_0 \leq 0.8:\\
      \;\;\;\;0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;1\\
      
      
      \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)) < 2.0000000000000002e-5

        1. Initial program 75.3%

          \[\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 rewrites75.6%

          \[\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-+.f6469.8%

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

          \[\leadsto \color{blue}{\frac{1}{2 + \alpha}} \]
        7. Taylor expanded in alpha around inf

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

            \[\leadsto \frac{1}{\alpha} \]
        9. Applied rewrites24.0%

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

        if 2.0000000000000002e-5 < (/.f64 (+.f64 (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) #s(literal 2 binary64))) #s(literal 1 binary64)) #s(literal 2 binary64)) < 0.80000000000000004

        1. Initial program 75.3%

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

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

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

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

            \[\leadsto 0.5 \]

          if 0.80000000000000004 < (/.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 75.3%

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

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

          Alternative 12: 71.9% accurate, 0.8× speedup?

          \[\begin{array}{l} \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.85:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
          (FPCore (alpha beta)
           :precision binary64
           (if (<= (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0) 0.85)
             0.5
             1.0))
          double code(double alpha, double beta) {
          	double tmp;
          	if (((((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0) <= 0.85) {
          		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.85d0) 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.85) {
          		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.85:
          		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.85)
          		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.85)
          		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.85], 0.5, 1.0]
          
          \begin{array}{l}
          \mathbf{if}\;\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2} \leq 0.85:\\
          \;\;\;\;0.5\\
          
          \mathbf{else}:\\
          \;\;\;\;1\\
          
          
          \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.84999999999999998

            1. Initial program 75.3%

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

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

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

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

                \[\leadsto 0.5 \]

              if 0.84999999999999998 < (/.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 75.3%

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

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

              Alternative 13: 37.8% accurate, 18.5× speedup?

              \[1 \]
              (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
              
              1
              
              Derivation
              1. Initial program 75.3%

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

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

                Reproduce

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