Octave 3.8, jcobi/4

Percentage Accurate: 15.6% → 83.5%
Time: 3.8s
Alternatives: 4
Speedup: 75.4×

Specification

?
\[\left(\alpha > -1 \land \beta > -1\right) \land i > 1\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := i \cdot \left(\left(\alpha + \beta\right) + i\right)\\ t_1 := \left(\alpha + \beta\right) + 2 \cdot i\\ t_2 := t\_1 \cdot t\_1\\ \frac{\frac{t\_0 \cdot \left(\beta \cdot \alpha + t\_0\right)}{t\_2}}{t\_2 - 1} \end{array} \end{array} \]
(FPCore (alpha beta i)
 :precision binary64
 (let* ((t_0 (* i (+ (+ alpha beta) i)))
        (t_1 (+ (+ alpha beta) (* 2.0 i)))
        (t_2 (* t_1 t_1)))
   (/ (/ (* t_0 (+ (* beta alpha) t_0)) t_2) (- t_2 1.0))))
double code(double alpha, double beta, double i) {
	double t_0 = i * ((alpha + beta) + i);
	double t_1 = (alpha + beta) + (2.0 * i);
	double t_2 = t_1 * t_1;
	return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 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, i)
use fmin_fmax_functions
    real(8), intent (in) :: alpha
    real(8), intent (in) :: beta
    real(8), intent (in) :: i
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    t_0 = i * ((alpha + beta) + i)
    t_1 = (alpha + beta) + (2.0d0 * i)
    t_2 = t_1 * t_1
    code = ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0d0)
end function
public static double code(double alpha, double beta, double i) {
	double t_0 = i * ((alpha + beta) + i);
	double t_1 = (alpha + beta) + (2.0 * i);
	double t_2 = t_1 * t_1;
	return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0);
}
def code(alpha, beta, i):
	t_0 = i * ((alpha + beta) + i)
	t_1 = (alpha + beta) + (2.0 * i)
	t_2 = t_1 * t_1
	return ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0)
function code(alpha, beta, i)
	t_0 = Float64(i * Float64(Float64(alpha + beta) + i))
	t_1 = Float64(Float64(alpha + beta) + Float64(2.0 * i))
	t_2 = Float64(t_1 * t_1)
	return Float64(Float64(Float64(t_0 * Float64(Float64(beta * alpha) + t_0)) / t_2) / Float64(t_2 - 1.0))
end
function tmp = code(alpha, beta, i)
	t_0 = i * ((alpha + beta) + i);
	t_1 = (alpha + beta) + (2.0 * i);
	t_2 = t_1 * t_1;
	tmp = ((t_0 * ((beta * alpha) + t_0)) / t_2) / (t_2 - 1.0);
end
code[alpha_, beta_, i_] := Block[{t$95$0 = N[(i * N[(N[(alpha + beta), $MachinePrecision] + i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$1), $MachinePrecision]}, N[(N[(N[(t$95$0 * N[(N[(beta * alpha), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] / N[(t$95$2 - 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := i \cdot \left(\left(\alpha + \beta\right) + i\right)\\
t_1 := \left(\alpha + \beta\right) + 2 \cdot i\\
t_2 := t\_1 \cdot t\_1\\
\frac{\frac{t\_0 \cdot \left(\beta \cdot \alpha + t\_0\right)}{t\_2}}{t\_2 - 1}
\end{array}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 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: 15.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := i \cdot \left(\left(\alpha + \beta\right) + i\right)\\
t_1 := \left(\alpha + \beta\right) + 2 \cdot i\\
t_2 := t\_1 \cdot t\_1\\
\frac{\frac{t\_0 \cdot \left(\beta \cdot \alpha + t\_0\right)}{t\_2}}{t\_2 - 1}
\end{array}
\end{array}

Alternative 1: 83.5% accurate, 0.6× speedup?

\[\begin{array}{l} [alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\ \\ \begin{array}{l} t_0 := \left(\alpha + \beta\right) \cdot \left(\alpha + \beta\right)\\ t_1 := \mathsf{fma}\left(0.0625, 2 \cdot \left(\alpha + \beta\right), -0.125 \cdot \left(\alpha + \beta\right)\right)\\ \mathbf{if}\;\beta \leq 8.8 \cdot 10^{+151}:\\ \;\;\;\;0.0625 + \left(-\frac{\left(\left(-t\_1\right) - -0.0625 \cdot \frac{\left(-\alpha \cdot \beta\right) + \left(-t\_0\right)}{i}\right) - \mathsf{fma}\left(-2, \frac{\left(\alpha + \beta\right) \cdot t\_1}{i}, -0.00390625 \cdot \frac{\mathsf{fma}\left(4, t\_0 - 1, t\_0 \cdot 20\right)}{i}\right)}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{i}{\beta} \cdot \frac{i}{\beta}\\ \end{array} \end{array} \]
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
(FPCore (alpha beta i)
 :precision binary64
 (let* ((t_0 (* (+ alpha beta) (+ alpha beta)))
        (t_1 (fma 0.0625 (* 2.0 (+ alpha beta)) (* -0.125 (+ alpha beta)))))
   (if (<= beta 8.8e+151)
     (+
      0.0625
      (-
       (/
        (-
         (- (- t_1) (* -0.0625 (/ (+ (- (* alpha beta)) (- t_0)) i)))
         (fma
          -2.0
          (/ (* (+ alpha beta) t_1) i)
          (* -0.00390625 (/ (fma 4.0 (- t_0 1.0) (* t_0 20.0)) i))))
        i)))
     (* (/ i beta) (/ i beta)))))
assert(alpha < beta && beta < i);
double code(double alpha, double beta, double i) {
	double t_0 = (alpha + beta) * (alpha + beta);
	double t_1 = fma(0.0625, (2.0 * (alpha + beta)), (-0.125 * (alpha + beta)));
	double tmp;
	if (beta <= 8.8e+151) {
		tmp = 0.0625 + -(((-t_1 - (-0.0625 * ((-(alpha * beta) + -t_0) / i))) - fma(-2.0, (((alpha + beta) * t_1) / i), (-0.00390625 * (fma(4.0, (t_0 - 1.0), (t_0 * 20.0)) / i)))) / i);
	} else {
		tmp = (i / beta) * (i / beta);
	}
	return tmp;
}
alpha, beta, i = sort([alpha, beta, i])
function code(alpha, beta, i)
	t_0 = Float64(Float64(alpha + beta) * Float64(alpha + beta))
	t_1 = fma(0.0625, Float64(2.0 * Float64(alpha + beta)), Float64(-0.125 * Float64(alpha + beta)))
	tmp = 0.0
	if (beta <= 8.8e+151)
		tmp = Float64(0.0625 + Float64(-Float64(Float64(Float64(Float64(-t_1) - Float64(-0.0625 * Float64(Float64(Float64(-Float64(alpha * beta)) + Float64(-t_0)) / i))) - fma(-2.0, Float64(Float64(Float64(alpha + beta) * t_1) / i), Float64(-0.00390625 * Float64(fma(4.0, Float64(t_0 - 1.0), Float64(t_0 * 20.0)) / i)))) / i)));
	else
		tmp = Float64(Float64(i / beta) * Float64(i / beta));
	end
	return tmp
end
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
code[alpha_, beta_, i_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] * N[(alpha + beta), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.0625 * N[(2.0 * N[(alpha + beta), $MachinePrecision]), $MachinePrecision] + N[(-0.125 * N[(alpha + beta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[beta, 8.8e+151], N[(0.0625 + (-N[(N[(N[((-t$95$1) - N[(-0.0625 * N[(N[((-N[(alpha * beta), $MachinePrecision]) + (-t$95$0)), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-2.0 * N[(N[(N[(alpha + beta), $MachinePrecision] * t$95$1), $MachinePrecision] / i), $MachinePrecision] + N[(-0.00390625 * N[(N[(4.0 * N[(t$95$0 - 1.0), $MachinePrecision] + N[(t$95$0 * 20.0), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision])), $MachinePrecision], N[(N[(i / beta), $MachinePrecision] * N[(i / beta), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
\\
\begin{array}{l}
t_0 := \left(\alpha + \beta\right) \cdot \left(\alpha + \beta\right)\\
t_1 := \mathsf{fma}\left(0.0625, 2 \cdot \left(\alpha + \beta\right), -0.125 \cdot \left(\alpha + \beta\right)\right)\\
\mathbf{if}\;\beta \leq 8.8 \cdot 10^{+151}:\\
\;\;\;\;0.0625 + \left(-\frac{\left(\left(-t\_1\right) - -0.0625 \cdot \frac{\left(-\alpha \cdot \beta\right) + \left(-t\_0\right)}{i}\right) - \mathsf{fma}\left(-2, \frac{\left(\alpha + \beta\right) \cdot t\_1}{i}, -0.00390625 \cdot \frac{\mathsf{fma}\left(4, t\_0 - 1, t\_0 \cdot 20\right)}{i}\right)}{i}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{i}{\beta} \cdot \frac{i}{\beta}\\


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

    1. Initial program 22.2%

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

      \[\leadsto \color{blue}{\frac{1}{16} + -1 \cdot \frac{\left(-1 \cdot \left(\frac{1}{16} \cdot \left(2 \cdot \alpha + 2 \cdot \beta\right) - \frac{1}{8} \cdot \left(\alpha + \beta\right)\right) + \frac{1}{16} \cdot \frac{-1 \cdot \left(\alpha \cdot \beta\right) + -1 \cdot {\left(\alpha + \beta\right)}^{2}}{i}\right) - \left(-2 \cdot \frac{\left(\alpha + \beta\right) \cdot \left(\frac{1}{16} \cdot \left(2 \cdot \alpha + 2 \cdot \beta\right) - \frac{1}{8} \cdot \left(\alpha + \beta\right)\right)}{i} + \frac{-1}{256} \cdot \frac{4 \cdot \left({\left(\alpha + \beta\right)}^{2} - 1\right) + \left(4 \cdot {\left(\alpha + \beta\right)}^{2} + 16 \cdot {\left(\alpha + \beta\right)}^{2}\right)}{i}\right)}{i}} \]
    3. Applied rewrites90.7%

      \[\leadsto \color{blue}{0.0625 + \left(-\frac{\left(\left(-\mathsf{fma}\left(0.0625, 2 \cdot \left(\alpha + \beta\right), -0.125 \cdot \left(\alpha + \beta\right)\right)\right) - -0.0625 \cdot \frac{\left(-\alpha \cdot \beta\right) + \left(-\left(\alpha + \beta\right) \cdot \left(\alpha + \beta\right)\right)}{i}\right) - \mathsf{fma}\left(-2, \frac{\left(\alpha + \beta\right) \cdot \mathsf{fma}\left(0.0625, 2 \cdot \left(\alpha + \beta\right), -0.125 \cdot \left(\alpha + \beta\right)\right)}{i}, -0.00390625 \cdot \frac{\mathsf{fma}\left(4, \left(\alpha + \beta\right) \cdot \left(\alpha + \beta\right) - 1, \left(\left(\alpha + \beta\right) \cdot \left(\alpha + \beta\right)\right) \cdot 20\right)}{i}\right)}{i}\right)} \]

    if 8.80000000000000027e151 < beta

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(i \cdot i\right) \cdot \left(\left(\beta + i\right) \cdot \left(\beta + i\right)\right)}{{\left(\beta + 2 \cdot i\right)}^{2} \cdot \left({\left(\beta + 2 \cdot i\right)}^{2} - 1\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\left(i \cdot i\right) \cdot \left(\left(\beta + i\right) \cdot \left(\beta + i\right)\right)}{{\left(\beta + 2 \cdot i\right)}^{2} \cdot \color{blue}{\left({\left(\beta + 2 \cdot i\right)}^{2} - 1\right)}} \]
    4. Applied rewrites0.0%

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

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

        \[\leadsto \frac{{i}^{2}}{{\beta}^{\color{blue}{2}}} \]
      2. pow2N/A

        \[\leadsto \frac{i \cdot i}{{\beta}^{2}} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{i \cdot i}{{\beta}^{2}} \]
      4. pow2N/A

        \[\leadsto \frac{i \cdot i}{\beta \cdot \beta} \]
      5. lift-*.f6422.4

        \[\leadsto \frac{i \cdot i}{\beta \cdot \beta} \]
    7. Applied rewrites22.4%

      \[\leadsto \frac{i \cdot i}{\color{blue}{\beta \cdot \beta}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \frac{i \cdot i}{\beta \cdot \beta} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{i \cdot i}{\beta \cdot \color{blue}{\beta}} \]
      4. times-fracN/A

        \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\color{blue}{\beta}} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\color{blue}{\beta}} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\beta} \]
      7. lower-/.f6466.7

        \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\beta} \]
    9. Applied rewrites66.7%

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

Alternative 2: 83.5% accurate, 5.2× speedup?

\[\begin{array}{l} [alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\ \\ \begin{array}{l} \mathbf{if}\;\beta \leq 8.8 \cdot 10^{+151}:\\ \;\;\;\;0.0625\\ \mathbf{else}:\\ \;\;\;\;\frac{i}{\beta} \cdot \frac{i}{\beta}\\ \end{array} \end{array} \]
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
(FPCore (alpha beta i)
 :precision binary64
 (if (<= beta 8.8e+151) 0.0625 (* (/ i beta) (/ i beta))))
assert(alpha < beta && beta < i);
double code(double alpha, double beta, double i) {
	double tmp;
	if (beta <= 8.8e+151) {
		tmp = 0.0625;
	} else {
		tmp = (i / beta) * (i / beta);
	}
	return tmp;
}
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
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, i)
use fmin_fmax_functions
    real(8), intent (in) :: alpha
    real(8), intent (in) :: beta
    real(8), intent (in) :: i
    real(8) :: tmp
    if (beta <= 8.8d+151) then
        tmp = 0.0625d0
    else
        tmp = (i / beta) * (i / beta)
    end if
    code = tmp
end function
assert alpha < beta && beta < i;
public static double code(double alpha, double beta, double i) {
	double tmp;
	if (beta <= 8.8e+151) {
		tmp = 0.0625;
	} else {
		tmp = (i / beta) * (i / beta);
	}
	return tmp;
}
[alpha, beta, i] = sort([alpha, beta, i])
def code(alpha, beta, i):
	tmp = 0
	if beta <= 8.8e+151:
		tmp = 0.0625
	else:
		tmp = (i / beta) * (i / beta)
	return tmp
alpha, beta, i = sort([alpha, beta, i])
function code(alpha, beta, i)
	tmp = 0.0
	if (beta <= 8.8e+151)
		tmp = 0.0625;
	else
		tmp = Float64(Float64(i / beta) * Float64(i / beta));
	end
	return tmp
end
alpha, beta, i = num2cell(sort([alpha, beta, i])){:}
function tmp_2 = code(alpha, beta, i)
	tmp = 0.0;
	if (beta <= 8.8e+151)
		tmp = 0.0625;
	else
		tmp = (i / beta) * (i / beta);
	end
	tmp_2 = tmp;
end
NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
code[alpha_, beta_, i_] := If[LessEqual[beta, 8.8e+151], 0.0625, N[(N[(i / beta), $MachinePrecision] * N[(i / beta), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 8.8 \cdot 10^{+151}:\\
\;\;\;\;0.0625\\

\mathbf{else}:\\
\;\;\;\;\frac{i}{\beta} \cdot \frac{i}{\beta}\\


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

    1. Initial program 22.2%

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

      \[\leadsto \color{blue}{\frac{1}{16}} \]
    3. Step-by-step derivation
      1. Applied rewrites90.7%

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

      if 8.80000000000000027e151 < beta

      1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\left(i \cdot i\right) \cdot \left(\left(\beta + i\right) \cdot \left(\beta + i\right)\right)}{{\left(\beta + 2 \cdot i\right)}^{2} \cdot \left({\left(\beta + 2 \cdot i\right)}^{2} - 1\right)} \]
        9. lower-*.f64N/A

          \[\leadsto \frac{\left(i \cdot i\right) \cdot \left(\left(\beta + i\right) \cdot \left(\beta + i\right)\right)}{{\left(\beta + 2 \cdot i\right)}^{2} \cdot \color{blue}{\left({\left(\beta + 2 \cdot i\right)}^{2} - 1\right)}} \]
      4. Applied rewrites0.0%

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

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

          \[\leadsto \frac{{i}^{2}}{{\beta}^{\color{blue}{2}}} \]
        2. pow2N/A

          \[\leadsto \frac{i \cdot i}{{\beta}^{2}} \]
        3. lift-*.f64N/A

          \[\leadsto \frac{i \cdot i}{{\beta}^{2}} \]
        4. pow2N/A

          \[\leadsto \frac{i \cdot i}{\beta \cdot \beta} \]
        5. lift-*.f6422.4

          \[\leadsto \frac{i \cdot i}{\beta \cdot \beta} \]
      7. Applied rewrites22.4%

        \[\leadsto \frac{i \cdot i}{\color{blue}{\beta \cdot \beta}} \]
      8. Step-by-step derivation
        1. lift-*.f64N/A

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

          \[\leadsto \frac{i \cdot i}{\beta \cdot \beta} \]
        3. lift-/.f64N/A

          \[\leadsto \frac{i \cdot i}{\beta \cdot \color{blue}{\beta}} \]
        4. times-fracN/A

          \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\color{blue}{\beta}} \]
        5. lower-*.f64N/A

          \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\color{blue}{\beta}} \]
        6. lower-/.f64N/A

          \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\beta} \]
        7. lower-/.f6466.7

          \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\beta} \]
      9. Applied rewrites66.7%

        \[\leadsto \frac{i}{\beta} \cdot \frac{i}{\color{blue}{\beta}} \]
    4. Recombined 2 regimes into one program.
    5. Add Preprocessing

    Alternative 3: 74.2% accurate, 0.9× speedup?

    \[\begin{array}{l} [alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\ \\ \begin{array}{l} t_0 := \left(\alpha + \beta\right) + 2 \cdot i\\ t_1 := t\_0 \cdot t\_0\\ t_2 := i \cdot \left(\left(\alpha + \beta\right) + i\right)\\ \mathbf{if}\;\frac{\frac{t\_2 \cdot \left(\beta \cdot \alpha + t\_2\right)}{t\_1}}{t\_1 - 1} \leq 2 \cdot 10^{-7}:\\ \;\;\;\;\frac{i \cdot i}{\beta \cdot \beta}\\ \mathbf{else}:\\ \;\;\;\;0.0625\\ \end{array} \end{array} \]
    NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
    (FPCore (alpha beta i)
     :precision binary64
     (let* ((t_0 (+ (+ alpha beta) (* 2.0 i)))
            (t_1 (* t_0 t_0))
            (t_2 (* i (+ (+ alpha beta) i))))
       (if (<= (/ (/ (* t_2 (+ (* beta alpha) t_2)) t_1) (- t_1 1.0)) 2e-7)
         (/ (* i i) (* beta beta))
         0.0625)))
    assert(alpha < beta && beta < i);
    double code(double alpha, double beta, double i) {
    	double t_0 = (alpha + beta) + (2.0 * i);
    	double t_1 = t_0 * t_0;
    	double t_2 = i * ((alpha + beta) + i);
    	double tmp;
    	if ((((t_2 * ((beta * alpha) + t_2)) / t_1) / (t_1 - 1.0)) <= 2e-7) {
    		tmp = (i * i) / (beta * beta);
    	} else {
    		tmp = 0.0625;
    	}
    	return tmp;
    }
    
    NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
    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, i)
    use fmin_fmax_functions
        real(8), intent (in) :: alpha
        real(8), intent (in) :: beta
        real(8), intent (in) :: i
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: t_2
        real(8) :: tmp
        t_0 = (alpha + beta) + (2.0d0 * i)
        t_1 = t_0 * t_0
        t_2 = i * ((alpha + beta) + i)
        if ((((t_2 * ((beta * alpha) + t_2)) / t_1) / (t_1 - 1.0d0)) <= 2d-7) then
            tmp = (i * i) / (beta * beta)
        else
            tmp = 0.0625d0
        end if
        code = tmp
    end function
    
    assert alpha < beta && beta < i;
    public static double code(double alpha, double beta, double i) {
    	double t_0 = (alpha + beta) + (2.0 * i);
    	double t_1 = t_0 * t_0;
    	double t_2 = i * ((alpha + beta) + i);
    	double tmp;
    	if ((((t_2 * ((beta * alpha) + t_2)) / t_1) / (t_1 - 1.0)) <= 2e-7) {
    		tmp = (i * i) / (beta * beta);
    	} else {
    		tmp = 0.0625;
    	}
    	return tmp;
    }
    
    [alpha, beta, i] = sort([alpha, beta, i])
    def code(alpha, beta, i):
    	t_0 = (alpha + beta) + (2.0 * i)
    	t_1 = t_0 * t_0
    	t_2 = i * ((alpha + beta) + i)
    	tmp = 0
    	if (((t_2 * ((beta * alpha) + t_2)) / t_1) / (t_1 - 1.0)) <= 2e-7:
    		tmp = (i * i) / (beta * beta)
    	else:
    		tmp = 0.0625
    	return tmp
    
    alpha, beta, i = sort([alpha, beta, i])
    function code(alpha, beta, i)
    	t_0 = Float64(Float64(alpha + beta) + Float64(2.0 * i))
    	t_1 = Float64(t_0 * t_0)
    	t_2 = Float64(i * Float64(Float64(alpha + beta) + i))
    	tmp = 0.0
    	if (Float64(Float64(Float64(t_2 * Float64(Float64(beta * alpha) + t_2)) / t_1) / Float64(t_1 - 1.0)) <= 2e-7)
    		tmp = Float64(Float64(i * i) / Float64(beta * beta));
    	else
    		tmp = 0.0625;
    	end
    	return tmp
    end
    
    alpha, beta, i = num2cell(sort([alpha, beta, i])){:}
    function tmp_2 = code(alpha, beta, i)
    	t_0 = (alpha + beta) + (2.0 * i);
    	t_1 = t_0 * t_0;
    	t_2 = i * ((alpha + beta) + i);
    	tmp = 0.0;
    	if ((((t_2 * ((beta * alpha) + t_2)) / t_1) / (t_1 - 1.0)) <= 2e-7)
    		tmp = (i * i) / (beta * beta);
    	else
    		tmp = 0.0625;
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
    code[alpha_, beta_, i_] := Block[{t$95$0 = N[(N[(alpha + beta), $MachinePrecision] + N[(2.0 * i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(i * N[(N[(alpha + beta), $MachinePrecision] + i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(t$95$2 * N[(N[(beta * alpha), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] / N[(t$95$1 - 1.0), $MachinePrecision]), $MachinePrecision], 2e-7], N[(N[(i * i), $MachinePrecision] / N[(beta * beta), $MachinePrecision]), $MachinePrecision], 0.0625]]]]
    
    \begin{array}{l}
    [alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
    \\
    \begin{array}{l}
    t_0 := \left(\alpha + \beta\right) + 2 \cdot i\\
    t_1 := t\_0 \cdot t\_0\\
    t_2 := i \cdot \left(\left(\alpha + \beta\right) + i\right)\\
    \mathbf{if}\;\frac{\frac{t\_2 \cdot \left(\beta \cdot \alpha + t\_2\right)}{t\_1}}{t\_1 - 1} \leq 2 \cdot 10^{-7}:\\
    \;\;\;\;\frac{i \cdot i}{\beta \cdot \beta}\\
    
    \mathbf{else}:\\
    \;\;\;\;0.0625\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (/.f64 (*.f64 (*.f64 i (+.f64 (+.f64 alpha beta) i)) (+.f64 (*.f64 beta alpha) (*.f64 i (+.f64 (+.f64 alpha beta) i)))) (*.f64 (+.f64 (+.f64 alpha beta) (*.f64 #s(literal 2 binary64) i)) (+.f64 (+.f64 alpha beta) (*.f64 #s(literal 2 binary64) i)))) (-.f64 (*.f64 (+.f64 (+.f64 alpha beta) (*.f64 #s(literal 2 binary64) i)) (+.f64 (+.f64 alpha beta) (*.f64 #s(literal 2 binary64) i))) #s(literal 1 binary64))) < 1.9999999999999999e-7

      1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\left(i \cdot i\right) \cdot \left(\left(\beta + i\right) \cdot \left(\beta + i\right)\right)}{{\left(\beta + 2 \cdot i\right)}^{2} \cdot \left({\left(\beta + 2 \cdot i\right)}^{2} - 1\right)} \]
        9. lower-*.f64N/A

          \[\leadsto \frac{\left(i \cdot i\right) \cdot \left(\left(\beta + i\right) \cdot \left(\beta + i\right)\right)}{{\left(\beta + 2 \cdot i\right)}^{2} \cdot \color{blue}{\left({\left(\beta + 2 \cdot i\right)}^{2} - 1\right)}} \]
      4. Applied rewrites46.0%

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

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

          \[\leadsto \frac{{i}^{2}}{{\beta}^{\color{blue}{2}}} \]
        2. pow2N/A

          \[\leadsto \frac{i \cdot i}{{\beta}^{2}} \]
        3. lift-*.f64N/A

          \[\leadsto \frac{i \cdot i}{{\beta}^{2}} \]
        4. pow2N/A

          \[\leadsto \frac{i \cdot i}{\beta \cdot \beta} \]
        5. lift-*.f6489.1

          \[\leadsto \frac{i \cdot i}{\beta \cdot \beta} \]
      7. Applied rewrites89.1%

        \[\leadsto \frac{i \cdot i}{\color{blue}{\beta \cdot \beta}} \]

      if 1.9999999999999999e-7 < (/.f64 (/.f64 (*.f64 (*.f64 i (+.f64 (+.f64 alpha beta) i)) (+.f64 (*.f64 beta alpha) (*.f64 i (+.f64 (+.f64 alpha beta) i)))) (*.f64 (+.f64 (+.f64 alpha beta) (*.f64 #s(literal 2 binary64) i)) (+.f64 (+.f64 alpha beta) (*.f64 #s(literal 2 binary64) i)))) (-.f64 (*.f64 (+.f64 (+.f64 alpha beta) (*.f64 #s(literal 2 binary64) i)) (+.f64 (+.f64 alpha beta) (*.f64 #s(literal 2 binary64) i))) #s(literal 1 binary64)))

      1. Initial program 13.0%

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

        \[\leadsto \color{blue}{\frac{1}{16}} \]
      3. Step-by-step derivation
        1. Applied rewrites73.8%

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

      Alternative 4: 71.7% accurate, 75.4× speedup?

      \[\begin{array}{l} [alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\ \\ 0.0625 \end{array} \]
      NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
      (FPCore (alpha beta i) :precision binary64 0.0625)
      assert(alpha < beta && beta < i);
      double code(double alpha, double beta, double i) {
      	return 0.0625;
      }
      
      NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
      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, i)
      use fmin_fmax_functions
          real(8), intent (in) :: alpha
          real(8), intent (in) :: beta
          real(8), intent (in) :: i
          code = 0.0625d0
      end function
      
      assert alpha < beta && beta < i;
      public static double code(double alpha, double beta, double i) {
      	return 0.0625;
      }
      
      [alpha, beta, i] = sort([alpha, beta, i])
      def code(alpha, beta, i):
      	return 0.0625
      
      alpha, beta, i = sort([alpha, beta, i])
      function code(alpha, beta, i)
      	return 0.0625
      end
      
      alpha, beta, i = num2cell(sort([alpha, beta, i])){:}
      function tmp = code(alpha, beta, i)
      	tmp = 0.0625;
      end
      
      NOTE: alpha, beta, and i should be sorted in increasing order before calling this function.
      code[alpha_, beta_, i_] := 0.0625
      
      \begin{array}{l}
      [alpha, beta, i] = \mathsf{sort}([alpha, beta, i])\\
      \\
      0.0625
      \end{array}
      
      Derivation
      1. Initial program 15.6%

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

        \[\leadsto \color{blue}{\frac{1}{16}} \]
      3. Step-by-step derivation
        1. Applied rewrites71.7%

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

        Reproduce

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