Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A

Percentage Accurate: 68.8% → 88.6%
Time: 3.1s
Alternatives: 8
Speedup: 1.4×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \end{array} \]
(FPCore (x y)
 :precision binary64
 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 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(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y):
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y)
	return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0)))
end
function tmp = code(x, y)
	tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\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 8 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: 68.8% accurate, 1.0× speedup?

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

\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}

Alternative 1: 88.6% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{y}{x}}{x}\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\ \;\;\;\;\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(2, y, x\right), x, y \cdot y\right)} \cdot x\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\ \;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
 :precision binary64
 (if (<= x -9e+102)
   (/ (/ y x) x)
   (if (<= x -5.8e-160)
     (* (/ y (* (+ (+ y x) 1.0) (fma (fma 2.0 y x) x (* y y)))) x)
     (if (<= x -2.3e-218)
       (/ y (* (+ 1.0 x) x))
       (if (<= x 7.5e+22) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))))
assert(x < y);
double code(double x, double y) {
	double tmp;
	if (x <= -9e+102) {
		tmp = (y / x) / x;
	} else if (x <= -5.8e-160) {
		tmp = (y / (((y + x) + 1.0) * fma(fma(2.0, y, x), x, (y * y)))) * x;
	} else if (x <= -2.3e-218) {
		tmp = y / ((1.0 + x) * x);
	} else if (x <= 7.5e+22) {
		tmp = x / ((1.0 + y) * y);
	} else {
		tmp = (x / y) / y;
	}
	return tmp;
}
x, y = sort([x, y])
function code(x, y)
	tmp = 0.0
	if (x <= -9e+102)
		tmp = Float64(Float64(y / x) / x);
	elseif (x <= -5.8e-160)
		tmp = Float64(Float64(y / Float64(Float64(Float64(y + x) + 1.0) * fma(fma(2.0, y, x), x, Float64(y * y)))) * x);
	elseif (x <= -2.3e-218)
		tmp = Float64(y / Float64(Float64(1.0 + x) * x));
	elseif (x <= 7.5e+22)
		tmp = Float64(x / Float64(Float64(1.0 + y) * y));
	else
		tmp = Float64(Float64(x / y) / y);
	end
	return tmp
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := If[LessEqual[x, -9e+102], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -5.8e-160], N[(N[(y / N[(N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(2.0 * y + x), $MachinePrecision] * x + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, -2.3e-218], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+22], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+102}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\

\mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\
\;\;\;\;\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(2, y, x\right), x, y \cdot y\right)} \cdot x\\

\mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -9.00000000000000042e102

    1. Initial program 58.1%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{y}{\color{blue}{{x}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      3. lower-*.f6481.9

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
    4. Applied rewrites81.9%

      \[\leadsto \color{blue}{\frac{y}{x \cdot x}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{y}{\color{blue}{x \cdot x}} \]
      3. associate-/r*N/A

        \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
      5. lower-/.f6489.3

        \[\leadsto \frac{\frac{y}{x}}{x} \]
    6. Applied rewrites89.3%

      \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]

    if -9.00000000000000042e102 < x < -5.7999999999999998e-160

    1. Initial program 82.6%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}} \]
      4. lift-*.f64N/A

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

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

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

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

        \[\leadsto \frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \color{blue}{\left(\left(x + y\right) + 1\right)}} \]
      9. associate-/l*N/A

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

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}} \]
      12. *-commutativeN/A

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

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

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(x + y\right) + 1\right)} \cdot \left(\left(x + y\right) \cdot \left(x + y\right)\right)} \]
      15. +-commutativeN/A

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

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

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x + y\right)\right)}} \]
      18. +-commutativeN/A

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

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\color{blue}{\left(y + x\right)} \cdot \left(x + y\right)\right)} \]
      20. +-commutativeN/A

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \color{blue}{\left(y + x\right)}\right)} \]
      21. lower-+.f6491.0

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \color{blue}{\left(y + x\right)}\right)} \]
    3. Applied rewrites91.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \color{blue}{\left(y + x\right)}\right)} \]
      9. *-commutativeN/A

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

        \[\leadsto \color{blue}{\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x} \]
    5. Applied rewrites91.0%

      \[\leadsto \color{blue}{\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x} \]
    6. Taylor expanded in x around 0

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

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

        \[\leadsto \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \mathsf{fma}\left(x + 2 \cdot y, \color{blue}{x}, {y}^{2}\right)} \cdot x \]
      3. +-commutativeN/A

        \[\leadsto \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \mathsf{fma}\left(2 \cdot y + x, x, {y}^{2}\right)} \cdot x \]
      4. lower-fma.f64N/A

        \[\leadsto \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(2, y, x\right), x, {y}^{2}\right)} \cdot x \]
      5. pow2N/A

        \[\leadsto \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(2, y, x\right), x, y \cdot y\right)} \cdot x \]
      6. lift-*.f6490.9

        \[\leadsto \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(2, y, x\right), x, y \cdot y\right)} \cdot x \]
    8. Applied rewrites90.9%

      \[\leadsto \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(2, y, x\right), x, y \cdot y\right)}} \cdot x \]

    if -5.7999999999999998e-160 < x < -2.29999999999999995e-218

    1. Initial program 57.8%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in y around 0

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

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

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

        \[\leadsto \frac{y}{\left(1 + x\right) \cdot \color{blue}{x}} \]
      4. lower-+.f6435.3

        \[\leadsto \frac{y}{\left(1 + x\right) \cdot x} \]
    4. Applied rewrites35.3%

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

    if -2.29999999999999995e-218 < x < 7.5000000000000002e22

    1. Initial program 74.9%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in x around 0

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

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

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

        \[\leadsto \frac{x}{\left(1 + y\right) \cdot \color{blue}{y}} \]
      4. lower-+.f6494.4

        \[\leadsto \frac{x}{\left(1 + y\right) \cdot y} \]
    4. Applied rewrites94.4%

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

    if 7.5000000000000002e22 < x

    1. Initial program 24.3%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{x}{\color{blue}{{y}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      3. lower-*.f6475.2

        \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
    4. Applied rewrites75.2%

      \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{x}{\color{blue}{y \cdot y}} \]
      3. associate-/r*N/A

        \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
      5. lower-/.f6495.3

        \[\leadsto \frac{\frac{x}{y}}{y} \]
    6. Applied rewrites95.3%

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

Alternative 2: 88.6% accurate, 0.8× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{y}{x}}{x}\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\ \;\;\;\;\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\ \;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
 :precision binary64
 (if (<= x -9e+102)
   (/ (/ y x) x)
   (if (<= x -5.8e-160)
     (* (/ y (* (+ (+ y x) 1.0) (* (+ y x) (+ y x)))) x)
     (if (<= x -2.3e-218)
       (/ y (* (+ 1.0 x) x))
       (if (<= x 7.5e+22) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))))
assert(x < y);
double code(double x, double y) {
	double tmp;
	if (x <= -9e+102) {
		tmp = (y / x) / x;
	} else if (x <= -5.8e-160) {
		tmp = (y / (((y + x) + 1.0) * ((y + x) * (y + x)))) * x;
	} else if (x <= -2.3e-218) {
		tmp = y / ((1.0 + x) * x);
	} else if (x <= 7.5e+22) {
		tmp = x / ((1.0 + y) * y);
	} else {
		tmp = (x / y) / y;
	}
	return tmp;
}
NOTE: x and y 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(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-9d+102)) then
        tmp = (y / x) / x
    else if (x <= (-5.8d-160)) then
        tmp = (y / (((y + x) + 1.0d0) * ((y + x) * (y + x)))) * x
    else if (x <= (-2.3d-218)) then
        tmp = y / ((1.0d0 + x) * x)
    else if (x <= 7.5d+22) then
        tmp = x / ((1.0d0 + y) * y)
    else
        tmp = (x / y) / y
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y) {
	double tmp;
	if (x <= -9e+102) {
		tmp = (y / x) / x;
	} else if (x <= -5.8e-160) {
		tmp = (y / (((y + x) + 1.0) * ((y + x) * (y + x)))) * x;
	} else if (x <= -2.3e-218) {
		tmp = y / ((1.0 + x) * x);
	} else if (x <= 7.5e+22) {
		tmp = x / ((1.0 + y) * y);
	} else {
		tmp = (x / y) / y;
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y):
	tmp = 0
	if x <= -9e+102:
		tmp = (y / x) / x
	elif x <= -5.8e-160:
		tmp = (y / (((y + x) + 1.0) * ((y + x) * (y + x)))) * x
	elif x <= -2.3e-218:
		tmp = y / ((1.0 + x) * x)
	elif x <= 7.5e+22:
		tmp = x / ((1.0 + y) * y)
	else:
		tmp = (x / y) / y
	return tmp
x, y = sort([x, y])
function code(x, y)
	tmp = 0.0
	if (x <= -9e+102)
		tmp = Float64(Float64(y / x) / x);
	elseif (x <= -5.8e-160)
		tmp = Float64(Float64(y / Float64(Float64(Float64(y + x) + 1.0) * Float64(Float64(y + x) * Float64(y + x)))) * x);
	elseif (x <= -2.3e-218)
		tmp = Float64(y / Float64(Float64(1.0 + x) * x));
	elseif (x <= 7.5e+22)
		tmp = Float64(x / Float64(Float64(1.0 + y) * y));
	else
		tmp = Float64(Float64(x / y) / y);
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -9e+102)
		tmp = (y / x) / x;
	elseif (x <= -5.8e-160)
		tmp = (y / (((y + x) + 1.0) * ((y + x) * (y + x)))) * x;
	elseif (x <= -2.3e-218)
		tmp = y / ((1.0 + x) * x);
	elseif (x <= 7.5e+22)
		tmp = x / ((1.0 + y) * y);
	else
		tmp = (x / y) / y;
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := If[LessEqual[x, -9e+102], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -5.8e-160], N[(N[(y / N[(N[(N[(y + x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, -2.3e-218], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+22], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+102}:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\

\mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\
\;\;\;\;\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x\\

\mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -9.00000000000000042e102

    1. Initial program 58.1%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{y}{\color{blue}{{x}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      3. lower-*.f6481.9

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
    4. Applied rewrites81.9%

      \[\leadsto \color{blue}{\frac{y}{x \cdot x}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{y}{\color{blue}{x \cdot x}} \]
      3. associate-/r*N/A

        \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
      5. lower-/.f6489.3

        \[\leadsto \frac{\frac{y}{x}}{x} \]
    6. Applied rewrites89.3%

      \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]

    if -9.00000000000000042e102 < x < -5.7999999999999998e-160

    1. Initial program 82.6%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}} \]
      4. lift-*.f64N/A

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

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

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

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

        \[\leadsto \frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \color{blue}{\left(\left(x + y\right) + 1\right)}} \]
      9. associate-/l*N/A

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

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}} \]
      12. *-commutativeN/A

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

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

        \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\left(x + y\right) + 1\right)} \cdot \left(\left(x + y\right) \cdot \left(x + y\right)\right)} \]
      15. +-commutativeN/A

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

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

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x + y\right)\right)}} \]
      18. +-commutativeN/A

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

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\color{blue}{\left(y + x\right)} \cdot \left(x + y\right)\right)} \]
      20. +-commutativeN/A

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \color{blue}{\left(y + x\right)}\right)} \]
      21. lower-+.f6491.0

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \color{blue}{\left(y + x\right)}\right)} \]
    3. Applied rewrites91.0%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \color{blue}{\left(y + x\right)}\right)} \]
      9. *-commutativeN/A

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

        \[\leadsto \color{blue}{\frac{y}{\left(\left(y + x\right) + 1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)} \cdot x} \]
    5. Applied rewrites91.0%

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

    if -5.7999999999999998e-160 < x < -2.29999999999999995e-218

    1. Initial program 57.8%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in y around 0

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

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

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

        \[\leadsto \frac{y}{\left(1 + x\right) \cdot \color{blue}{x}} \]
      4. lower-+.f6435.3

        \[\leadsto \frac{y}{\left(1 + x\right) \cdot x} \]
    4. Applied rewrites35.3%

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

    if -2.29999999999999995e-218 < x < 7.5000000000000002e22

    1. Initial program 74.9%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in x around 0

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

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

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

        \[\leadsto \frac{x}{\left(1 + y\right) \cdot \color{blue}{y}} \]
      4. lower-+.f6494.4

        \[\leadsto \frac{x}{\left(1 + y\right) \cdot y} \]
    4. Applied rewrites94.4%

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

    if 7.5000000000000002e22 < x

    1. Initial program 24.3%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{x}{\color{blue}{{y}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      3. lower-*.f6475.2

        \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
    4. Applied rewrites75.2%

      \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{x}{\color{blue}{y \cdot y}} \]
      3. associate-/r*N/A

        \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
      5. lower-/.f6495.3

        \[\leadsto \frac{\frac{x}{y}}{y} \]
    6. Applied rewrites95.3%

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

Alternative 3: 83.2% accurate, 0.8× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -1820:\\ \;\;\;\;\frac{\frac{y}{x}}{x}\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\ \;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(y + 1\right)}\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\ \;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
 :precision binary64
 (if (<= x -1820.0)
   (/ (/ y x) x)
   (if (<= x -5.8e-160)
     (/ (* x y) (* (* (+ x y) (+ x y)) (+ y 1.0)))
     (if (<= x -2.3e-218)
       (/ y (* (+ 1.0 x) x))
       (if (<= x 7.5e+22) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))))
assert(x < y);
double code(double x, double y) {
	double tmp;
	if (x <= -1820.0) {
		tmp = (y / x) / x;
	} else if (x <= -5.8e-160) {
		tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
	} else if (x <= -2.3e-218) {
		tmp = y / ((1.0 + x) * x);
	} else if (x <= 7.5e+22) {
		tmp = x / ((1.0 + y) * y);
	} else {
		tmp = (x / y) / y;
	}
	return tmp;
}
NOTE: x and y 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(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-1820.0d0)) then
        tmp = (y / x) / x
    else if (x <= (-5.8d-160)) then
        tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0d0))
    else if (x <= (-2.3d-218)) then
        tmp = y / ((1.0d0 + x) * x)
    else if (x <= 7.5d+22) then
        tmp = x / ((1.0d0 + y) * y)
    else
        tmp = (x / y) / y
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y) {
	double tmp;
	if (x <= -1820.0) {
		tmp = (y / x) / x;
	} else if (x <= -5.8e-160) {
		tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
	} else if (x <= -2.3e-218) {
		tmp = y / ((1.0 + x) * x);
	} else if (x <= 7.5e+22) {
		tmp = x / ((1.0 + y) * y);
	} else {
		tmp = (x / y) / y;
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y):
	tmp = 0
	if x <= -1820.0:
		tmp = (y / x) / x
	elif x <= -5.8e-160:
		tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0))
	elif x <= -2.3e-218:
		tmp = y / ((1.0 + x) * x)
	elif x <= 7.5e+22:
		tmp = x / ((1.0 + y) * y)
	else:
		tmp = (x / y) / y
	return tmp
x, y = sort([x, y])
function code(x, y)
	tmp = 0.0
	if (x <= -1820.0)
		tmp = Float64(Float64(y / x) / x);
	elseif (x <= -5.8e-160)
		tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(y + 1.0)));
	elseif (x <= -2.3e-218)
		tmp = Float64(y / Float64(Float64(1.0 + x) * x));
	elseif (x <= 7.5e+22)
		tmp = Float64(x / Float64(Float64(1.0 + y) * y));
	else
		tmp = Float64(Float64(x / y) / y);
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1820.0)
		tmp = (y / x) / x;
	elseif (x <= -5.8e-160)
		tmp = (x * y) / (((x + y) * (x + y)) * (y + 1.0));
	elseif (x <= -2.3e-218)
		tmp = y / ((1.0 + x) * x);
	elseif (x <= 7.5e+22)
		tmp = x / ((1.0 + y) * y);
	else
		tmp = (x / y) / y;
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := If[LessEqual[x, -1820.0], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, -5.8e-160], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.3e-218], N[(y / N[(N[(1.0 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+22], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1820:\\
\;\;\;\;\frac{\frac{y}{x}}{x}\\

\mathbf{elif}\;x \leq -5.8 \cdot 10^{-160}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(y + 1\right)}\\

\mathbf{elif}\;x \leq -2.3 \cdot 10^{-218}:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot x}\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -1820

    1. Initial program 65.8%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{y}{\color{blue}{{x}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      3. lower-*.f6478.4

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
    4. Applied rewrites78.4%

      \[\leadsto \color{blue}{\frac{y}{x \cdot x}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{y}{\color{blue}{x \cdot x}} \]
      3. associate-/r*N/A

        \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
      5. lower-/.f6483.6

        \[\leadsto \frac{\frac{y}{x}}{x} \]
    6. Applied rewrites83.6%

      \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]

    if -1820 < x < -5.7999999999999998e-160

    1. Initial program 81.6%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in x around 0

      \[\leadsto \frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\color{blue}{y} + 1\right)} \]
    3. Step-by-step derivation
      1. Applied rewrites77.5%

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

      if -5.7999999999999998e-160 < x < -2.29999999999999995e-218

      1. Initial program 57.8%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in y around 0

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

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

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

          \[\leadsto \frac{y}{\left(1 + x\right) \cdot \color{blue}{x}} \]
        4. lower-+.f6435.3

          \[\leadsto \frac{y}{\left(1 + x\right) \cdot x} \]
      4. Applied rewrites35.3%

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

      if -2.29999999999999995e-218 < x < 7.5000000000000002e22

      1. Initial program 74.9%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in x around 0

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

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

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

          \[\leadsto \frac{x}{\left(1 + y\right) \cdot \color{blue}{y}} \]
        4. lower-+.f6494.4

          \[\leadsto \frac{x}{\left(1 + y\right) \cdot y} \]
      4. Applied rewrites94.4%

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

      if 7.5000000000000002e22 < x

      1. Initial program 24.3%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in y around inf

        \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{{y}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        3. lower-*.f6475.2

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      4. Applied rewrites75.2%

        \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{y \cdot y}} \]
        3. associate-/r*N/A

          \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
        4. lower-/.f64N/A

          \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
        5. lower-/.f6495.3

          \[\leadsto \frac{\frac{x}{y}}{y} \]
      6. Applied rewrites95.3%

        \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
    4. Recombined 5 regimes into one program.
    5. Add Preprocessing

    Alternative 4: 78.6% accurate, 1.4× speedup?

    \[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -0.00165:\\ \;\;\;\;\frac{\frac{y}{x}}{x}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \end{array} \]
    NOTE: x and y should be sorted in increasing order before calling this function.
    (FPCore (x y)
     :precision binary64
     (if (<= x -0.00165)
       (/ (/ y x) x)
       (if (<= x 7.5e+22) (/ x (* (+ 1.0 y) y)) (/ (/ x y) y))))
    assert(x < y);
    double code(double x, double y) {
    	double tmp;
    	if (x <= -0.00165) {
    		tmp = (y / x) / x;
    	} else if (x <= 7.5e+22) {
    		tmp = x / ((1.0 + y) * y);
    	} else {
    		tmp = (x / y) / y;
    	}
    	return tmp;
    }
    
    NOTE: x and y 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(x, y)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: tmp
        if (x <= (-0.00165d0)) then
            tmp = (y / x) / x
        else if (x <= 7.5d+22) then
            tmp = x / ((1.0d0 + y) * y)
        else
            tmp = (x / y) / y
        end if
        code = tmp
    end function
    
    assert x < y;
    public static double code(double x, double y) {
    	double tmp;
    	if (x <= -0.00165) {
    		tmp = (y / x) / x;
    	} else if (x <= 7.5e+22) {
    		tmp = x / ((1.0 + y) * y);
    	} else {
    		tmp = (x / y) / y;
    	}
    	return tmp;
    }
    
    [x, y] = sort([x, y])
    def code(x, y):
    	tmp = 0
    	if x <= -0.00165:
    		tmp = (y / x) / x
    	elif x <= 7.5e+22:
    		tmp = x / ((1.0 + y) * y)
    	else:
    		tmp = (x / y) / y
    	return tmp
    
    x, y = sort([x, y])
    function code(x, y)
    	tmp = 0.0
    	if (x <= -0.00165)
    		tmp = Float64(Float64(y / x) / x);
    	elseif (x <= 7.5e+22)
    		tmp = Float64(x / Float64(Float64(1.0 + y) * y));
    	else
    		tmp = Float64(Float64(x / y) / y);
    	end
    	return tmp
    end
    
    x, y = num2cell(sort([x, y])){:}
    function tmp_2 = code(x, y)
    	tmp = 0.0;
    	if (x <= -0.00165)
    		tmp = (y / x) / x;
    	elseif (x <= 7.5e+22)
    		tmp = x / ((1.0 + y) * y);
    	else
    		tmp = (x / y) / y;
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: x and y should be sorted in increasing order before calling this function.
    code[x_, y_] := If[LessEqual[x, -0.00165], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 7.5e+22], N[(x / N[(N[(1.0 + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]
    
    \begin{array}{l}
    [x, y] = \mathsf{sort}([x, y])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -0.00165:\\
    \;\;\;\;\frac{\frac{y}{x}}{x}\\
    
    \mathbf{elif}\;x \leq 7.5 \cdot 10^{+22}:\\
    \;\;\;\;\frac{x}{\left(1 + y\right) \cdot y}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\frac{x}{y}}{y}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if x < -0.00165

      1. Initial program 66.2%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{y}{\color{blue}{{x}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
        3. lower-*.f6477.1

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      4. Applied rewrites77.1%

        \[\leadsto \color{blue}{\frac{y}{x \cdot x}} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{y}{\color{blue}{x \cdot x}} \]
        3. associate-/r*N/A

          \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
        4. lower-/.f64N/A

          \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
        5. lower-/.f6482.2

          \[\leadsto \frac{\frac{y}{x}}{x} \]
      6. Applied rewrites82.2%

        \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]

      if -0.00165 < x < 7.5000000000000002e22

      1. Initial program 75.5%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in x around 0

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

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

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

          \[\leadsto \frac{x}{\left(1 + y\right) \cdot \color{blue}{y}} \]
        4. lower-+.f6473.8

          \[\leadsto \frac{x}{\left(1 + y\right) \cdot y} \]
      4. Applied rewrites73.8%

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

      if 7.5000000000000002e22 < x

      1. Initial program 24.3%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in y around inf

        \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{{y}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        3. lower-*.f6475.2

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      4. Applied rewrites75.2%

        \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{y \cdot y}} \]
        3. associate-/r*N/A

          \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
        4. lower-/.f64N/A

          \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
        5. lower-/.f6495.3

          \[\leadsto \frac{\frac{x}{y}}{y} \]
      6. Applied rewrites95.3%

        \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
    3. Recombined 3 regimes into one program.
    4. Add Preprocessing

    Alternative 5: 66.9% accurate, 2.1× speedup?

    \[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -0.00165:\\ \;\;\;\;\frac{\frac{y}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \end{array} \]
    NOTE: x and y should be sorted in increasing order before calling this function.
    (FPCore (x y)
     :precision binary64
     (if (<= x -0.00165) (/ (/ y x) x) (/ (/ x y) y)))
    assert(x < y);
    double code(double x, double y) {
    	double tmp;
    	if (x <= -0.00165) {
    		tmp = (y / x) / x;
    	} else {
    		tmp = (x / y) / y;
    	}
    	return tmp;
    }
    
    NOTE: x and y 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(x, y)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: tmp
        if (x <= (-0.00165d0)) then
            tmp = (y / x) / x
        else
            tmp = (x / y) / y
        end if
        code = tmp
    end function
    
    assert x < y;
    public static double code(double x, double y) {
    	double tmp;
    	if (x <= -0.00165) {
    		tmp = (y / x) / x;
    	} else {
    		tmp = (x / y) / y;
    	}
    	return tmp;
    }
    
    [x, y] = sort([x, y])
    def code(x, y):
    	tmp = 0
    	if x <= -0.00165:
    		tmp = (y / x) / x
    	else:
    		tmp = (x / y) / y
    	return tmp
    
    x, y = sort([x, y])
    function code(x, y)
    	tmp = 0.0
    	if (x <= -0.00165)
    		tmp = Float64(Float64(y / x) / x);
    	else
    		tmp = Float64(Float64(x / y) / y);
    	end
    	return tmp
    end
    
    x, y = num2cell(sort([x, y])){:}
    function tmp_2 = code(x, y)
    	tmp = 0.0;
    	if (x <= -0.00165)
    		tmp = (y / x) / x;
    	else
    		tmp = (x / y) / y;
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: x and y should be sorted in increasing order before calling this function.
    code[x_, y_] := If[LessEqual[x, -0.00165], N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]
    
    \begin{array}{l}
    [x, y] = \mathsf{sort}([x, y])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -0.00165:\\
    \;\;\;\;\frac{\frac{y}{x}}{x}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\frac{x}{y}}{y}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -0.00165

      1. Initial program 66.2%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{y}{\color{blue}{{x}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
        3. lower-*.f6477.1

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      4. Applied rewrites77.1%

        \[\leadsto \color{blue}{\frac{y}{x \cdot x}} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{y}{\color{blue}{x \cdot x}} \]
        3. associate-/r*N/A

          \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
        4. lower-/.f64N/A

          \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]
        5. lower-/.f6482.2

          \[\leadsto \frac{\frac{y}{x}}{x} \]
      6. Applied rewrites82.2%

        \[\leadsto \frac{\frac{y}{x}}{\color{blue}{x}} \]

      if -0.00165 < x

      1. Initial program 70.7%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in y around inf

        \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{{y}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        3. lower-*.f6452.9

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      4. Applied rewrites52.9%

        \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{y \cdot y}} \]
        3. associate-/r*N/A

          \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
        4. lower-/.f64N/A

          \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
        5. lower-/.f6454.8

          \[\leadsto \frac{\frac{x}{y}}{y} \]
      6. Applied rewrites54.8%

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

    Alternative 6: 64.7% accurate, 2.1× speedup?

    \[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -0.00165:\\ \;\;\;\;\frac{y}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{y}\\ \end{array} \end{array} \]
    NOTE: x and y should be sorted in increasing order before calling this function.
    (FPCore (x y)
     :precision binary64
     (if (<= x -0.00165) (/ y (* x x)) (/ (/ x y) y)))
    assert(x < y);
    double code(double x, double y) {
    	double tmp;
    	if (x <= -0.00165) {
    		tmp = y / (x * x);
    	} else {
    		tmp = (x / y) / y;
    	}
    	return tmp;
    }
    
    NOTE: x and y 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(x, y)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: tmp
        if (x <= (-0.00165d0)) then
            tmp = y / (x * x)
        else
            tmp = (x / y) / y
        end if
        code = tmp
    end function
    
    assert x < y;
    public static double code(double x, double y) {
    	double tmp;
    	if (x <= -0.00165) {
    		tmp = y / (x * x);
    	} else {
    		tmp = (x / y) / y;
    	}
    	return tmp;
    }
    
    [x, y] = sort([x, y])
    def code(x, y):
    	tmp = 0
    	if x <= -0.00165:
    		tmp = y / (x * x)
    	else:
    		tmp = (x / y) / y
    	return tmp
    
    x, y = sort([x, y])
    function code(x, y)
    	tmp = 0.0
    	if (x <= -0.00165)
    		tmp = Float64(y / Float64(x * x));
    	else
    		tmp = Float64(Float64(x / y) / y);
    	end
    	return tmp
    end
    
    x, y = num2cell(sort([x, y])){:}
    function tmp_2 = code(x, y)
    	tmp = 0.0;
    	if (x <= -0.00165)
    		tmp = y / (x * x);
    	else
    		tmp = (x / y) / y;
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: x and y should be sorted in increasing order before calling this function.
    code[x_, y_] := If[LessEqual[x, -0.00165], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]
    
    \begin{array}{l}
    [x, y] = \mathsf{sort}([x, y])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -0.00165:\\
    \;\;\;\;\frac{y}{x \cdot x}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\frac{x}{y}}{y}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -0.00165

      1. Initial program 66.2%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{y}{\color{blue}{{x}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
        3. lower-*.f6477.1

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      4. Applied rewrites77.1%

        \[\leadsto \color{blue}{\frac{y}{x \cdot x}} \]

      if -0.00165 < x

      1. Initial program 70.7%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in y around inf

        \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{{y}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        3. lower-*.f6452.9

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      4. Applied rewrites52.9%

        \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{y \cdot y}} \]
        3. associate-/r*N/A

          \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
        4. lower-/.f64N/A

          \[\leadsto \frac{\frac{x}{y}}{\color{blue}{y}} \]
        5. lower-/.f6454.8

          \[\leadsto \frac{\frac{x}{y}}{y} \]
      6. Applied rewrites54.8%

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

    Alternative 7: 63.6% accurate, 2.2× speedup?

    \[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -0.00165:\\ \;\;\;\;\frac{y}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot y}\\ \end{array} \end{array} \]
    NOTE: x and y should be sorted in increasing order before calling this function.
    (FPCore (x y)
     :precision binary64
     (if (<= x -0.00165) (/ y (* x x)) (/ x (* y y))))
    assert(x < y);
    double code(double x, double y) {
    	double tmp;
    	if (x <= -0.00165) {
    		tmp = y / (x * x);
    	} else {
    		tmp = x / (y * y);
    	}
    	return tmp;
    }
    
    NOTE: x and y 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(x, y)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: tmp
        if (x <= (-0.00165d0)) then
            tmp = y / (x * x)
        else
            tmp = x / (y * y)
        end if
        code = tmp
    end function
    
    assert x < y;
    public static double code(double x, double y) {
    	double tmp;
    	if (x <= -0.00165) {
    		tmp = y / (x * x);
    	} else {
    		tmp = x / (y * y);
    	}
    	return tmp;
    }
    
    [x, y] = sort([x, y])
    def code(x, y):
    	tmp = 0
    	if x <= -0.00165:
    		tmp = y / (x * x)
    	else:
    		tmp = x / (y * y)
    	return tmp
    
    x, y = sort([x, y])
    function code(x, y)
    	tmp = 0.0
    	if (x <= -0.00165)
    		tmp = Float64(y / Float64(x * x));
    	else
    		tmp = Float64(x / Float64(y * y));
    	end
    	return tmp
    end
    
    x, y = num2cell(sort([x, y])){:}
    function tmp_2 = code(x, y)
    	tmp = 0.0;
    	if (x <= -0.00165)
    		tmp = y / (x * x);
    	else
    		tmp = x / (y * y);
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: x and y should be sorted in increasing order before calling this function.
    code[x_, y_] := If[LessEqual[x, -0.00165], N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    [x, y] = \mathsf{sort}([x, y])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -0.00165:\\
    \;\;\;\;\frac{y}{x \cdot x}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{x}{y \cdot y}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -0.00165

      1. Initial program 66.2%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{y}{\color{blue}{{x}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
        3. lower-*.f6477.1

          \[\leadsto \frac{y}{x \cdot \color{blue}{x}} \]
      4. Applied rewrites77.1%

        \[\leadsto \color{blue}{\frac{y}{x \cdot x}} \]

      if -0.00165 < x

      1. Initial program 70.7%

        \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
      2. Taylor expanded in y around inf

        \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{x}{\color{blue}{{y}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
        3. lower-*.f6452.9

          \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      4. Applied rewrites52.9%

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

    Alternative 8: 36.9% accurate, 3.3× speedup?

    \[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \frac{x}{y \cdot y} \end{array} \]
    NOTE: x and y should be sorted in increasing order before calling this function.
    (FPCore (x y) :precision binary64 (/ x (* y y)))
    assert(x < y);
    double code(double x, double y) {
    	return x / (y * y);
    }
    
    NOTE: x and y 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(x, y)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        code = x / (y * y)
    end function
    
    assert x < y;
    public static double code(double x, double y) {
    	return x / (y * y);
    }
    
    [x, y] = sort([x, y])
    def code(x, y):
    	return x / (y * y)
    
    x, y = sort([x, y])
    function code(x, y)
    	return Float64(x / Float64(y * y))
    end
    
    x, y = num2cell(sort([x, y])){:}
    function tmp = code(x, y)
    	tmp = x / (y * y);
    end
    
    NOTE: x and y should be sorted in increasing order before calling this function.
    code[x_, y_] := N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    [x, y] = \mathsf{sort}([x, y])\\
    \\
    \frac{x}{y \cdot y}
    \end{array}
    
    Derivation
    1. Initial program 68.8%

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{\frac{x}{{y}^{2}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{x}{\color{blue}{{y}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
      3. lower-*.f6436.9

        \[\leadsto \frac{x}{y \cdot \color{blue}{y}} \]
    4. Applied rewrites36.9%

      \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \]
    5. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025106 
    (FPCore (x y)
      :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
      :precision binary64
      (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))