Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.2% → 99.9%
Time: 2.8s
Alternatives: 14
Speedup: 0.8×

Specification

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

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

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

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

Alternative 1: 99.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ t_1 := \frac{x}{1 + x} \cdot \frac{x}{y}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{+189}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 10^{+15}:\\ \;\;\;\;\frac{x \cdot \frac{y + x}{y}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
        (t_1 (* (/ x (+ 1.0 x)) (/ x y))))
   (if (<= t_0 -4e+189)
     t_1
     (if (<= t_0 1e+15) (/ (* x (/ (+ y x) y)) (+ x 1.0)) t_1))))
double code(double x, double y) {
	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
	double t_1 = (x / (1.0 + x)) * (x / y);
	double tmp;
	if (t_0 <= -4e+189) {
		tmp = t_1;
	} else if (t_0 <= 1e+15) {
		tmp = (x * ((y + x) / y)) / (x + 1.0);
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
    t_1 = (x / (1.0d0 + x)) * (x / y)
    if (t_0 <= (-4d+189)) then
        tmp = t_1
    else if (t_0 <= 1d+15) then
        tmp = (x * ((y + x) / y)) / (x + 1.0d0)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
	double t_1 = (x / (1.0 + x)) * (x / y);
	double tmp;
	if (t_0 <= -4e+189) {
		tmp = t_1;
	} else if (t_0 <= 1e+15) {
		tmp = (x * ((y + x) / y)) / (x + 1.0);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0)
	t_1 = (x / (1.0 + x)) * (x / y)
	tmp = 0
	if t_0 <= -4e+189:
		tmp = t_1
	elif t_0 <= 1e+15:
		tmp = (x * ((y + x) / y)) / (x + 1.0)
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
	t_1 = Float64(Float64(x / Float64(1.0 + x)) * Float64(x / y))
	tmp = 0.0
	if (t_0 <= -4e+189)
		tmp = t_1;
	elseif (t_0 <= 1e+15)
		tmp = Float64(Float64(x * Float64(Float64(y + x) / y)) / Float64(x + 1.0));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
	t_1 = (x / (1.0 + x)) * (x / y);
	tmp = 0.0;
	if (t_0 <= -4e+189)
		tmp = t_1;
	elseif (t_0 <= 1e+15)
		tmp = (x * ((y + x) / y)) / (x + 1.0);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e+189], t$95$1, If[LessEqual[t$95$0, 1e+15], N[(N[(x * N[(N[(y + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := \frac{x}{1 + x} \cdot \frac{x}{y}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+189}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 10^{+15}:\\
\;\;\;\;\frac{x \cdot \frac{y + x}{y}}{x + 1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -4.0000000000000001e189 or 1e15 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

    1. Initial program 65.4%

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y \cdot 1}} \]
      6. *-rgt-identityN/A

        \[\leadsto \frac{x \cdot x}{y \cdot x + y} \]
      7. lower-fma.f6470.1

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
    4. Applied rewrites70.1%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \]
      3. lift-fma.f64N/A

        \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y}} \]
      4. +-commutativeN/A

        \[\leadsto \frac{x \cdot x}{y + \color{blue}{y \cdot x}} \]
      5. *-commutativeN/A

        \[\leadsto \frac{x \cdot x}{y + x \cdot \color{blue}{y}} \]
      6. distribute-rgt1-inN/A

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

        \[\leadsto \frac{x \cdot x}{\left(1 + x\right) \cdot y} \]
      8. times-fracN/A

        \[\leadsto \frac{x}{1 + x} \cdot \color{blue}{\frac{x}{y}} \]
      9. lower-*.f64N/A

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

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

        \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{y} \]
      12. lift-/.f6499.9

        \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{\color{blue}{y}} \]
    6. Applied rewrites99.9%

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

    if -4.0000000000000001e189 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1e15

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\frac{x + y}{y}}}{x + 1} \]
      5. +-commutativeN/A

        \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
      6. *-lft-identityN/A

        \[\leadsto \frac{x \cdot \frac{\color{blue}{1 \cdot y} + x}{y}}{x + 1} \]
      7. *-rgt-identityN/A

        \[\leadsto \frac{x \cdot \frac{1 \cdot y + \color{blue}{x \cdot 1}}{y}}{x + 1} \]
      8. lower-/.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\frac{1 \cdot y + x \cdot 1}{y}}}{x + 1} \]
      9. *-lft-identityN/A

        \[\leadsto \frac{x \cdot \frac{\color{blue}{y} + x \cdot 1}{y}}{x + 1} \]
      10. *-rgt-identityN/A

        \[\leadsto \frac{x \cdot \frac{y + \color{blue}{x}}{y}}{x + 1} \]
      11. lower-+.f6499.9

        \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
    3. Applied rewrites99.9%

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

Alternative 2: 99.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{x - -1}\\ \mathsf{fma}\left(t\_0, \frac{x}{y}, t\_0\right) \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- x -1.0)))) (fma t_0 (/ x y) t_0)))
double code(double x, double y) {
	double t_0 = x / (x - -1.0);
	return fma(t_0, (x / y), t_0);
}
function code(x, y)
	t_0 = Float64(x / Float64(x - -1.0))
	return fma(t_0, Float64(x / y), t_0)
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(x / y), $MachinePrecision] + t$95$0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{x - -1}\\
\mathsf{fma}\left(t\_0, \frac{x}{y}, t\_0\right)
\end{array}
\end{array}
Derivation
  1. Initial program 88.2%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y} + x \cdot 1}}{x + 1} \]
    7. +-commutativeN/A

      \[\leadsto \frac{x \cdot \frac{x}{y} + x \cdot 1}{\color{blue}{1 + x}} \]
    8. div-addN/A

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

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{1 + x} + \frac{x \cdot 1}{1 + x} \]
    10. unpow2N/A

      \[\leadsto \frac{\frac{\color{blue}{{x}^{2}}}{y}}{1 + x} + \frac{x \cdot 1}{1 + x} \]
    11. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot \left(1 + x\right)}} + \frac{x \cdot 1}{1 + x} \]
    12. unpow2N/A

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

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

      \[\leadsto \color{blue}{\frac{x}{1 + x} \cdot \frac{x}{y}} + \frac{x \cdot 1}{1 + x} \]
    15. *-rgt-identityN/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{1 + x}, \frac{x}{y}, \frac{x}{1 + x}\right)} \]
  3. Applied rewrites99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{x - -1}, \frac{x}{y}, \frac{x}{x - -1}\right)} \]
  4. Add Preprocessing

Alternative 3: 99.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ t_1 := \frac{x}{1 + x} \cdot \frac{x}{y}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{+189}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
        (t_1 (* (/ x (+ 1.0 x)) (/ x y))))
   (if (<= t_0 -4e+189) t_1 (if (<= t_0 1e+15) t_0 t_1))))
double code(double x, double y) {
	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
	double t_1 = (x / (1.0 + x)) * (x / y);
	double tmp;
	if (t_0 <= -4e+189) {
		tmp = t_1;
	} else if (t_0 <= 1e+15) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
    t_1 = (x / (1.0d0 + x)) * (x / y)
    if (t_0 <= (-4d+189)) then
        tmp = t_1
    else if (t_0 <= 1d+15) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
	double t_1 = (x / (1.0 + x)) * (x / y);
	double tmp;
	if (t_0 <= -4e+189) {
		tmp = t_1;
	} else if (t_0 <= 1e+15) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0)
	t_1 = (x / (1.0 + x)) * (x / y)
	tmp = 0
	if t_0 <= -4e+189:
		tmp = t_1
	elif t_0 <= 1e+15:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
	t_1 = Float64(Float64(x / Float64(1.0 + x)) * Float64(x / y))
	tmp = 0.0
	if (t_0 <= -4e+189)
		tmp = t_1;
	elseif (t_0 <= 1e+15)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
	t_1 = (x / (1.0 + x)) * (x / y);
	tmp = 0.0;
	if (t_0 <= -4e+189)
		tmp = t_1;
	elseif (t_0 <= 1e+15)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e+189], t$95$1, If[LessEqual[t$95$0, 1e+15], t$95$0, t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := \frac{x}{1 + x} \cdot \frac{x}{y}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+189}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 10^{+15}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -4.0000000000000001e189 or 1e15 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

    1. Initial program 65.4%

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y \cdot 1}} \]
      6. *-rgt-identityN/A

        \[\leadsto \frac{x \cdot x}{y \cdot x + y} \]
      7. lower-fma.f6470.1

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
    4. Applied rewrites70.1%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \]
      3. lift-fma.f64N/A

        \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y}} \]
      4. +-commutativeN/A

        \[\leadsto \frac{x \cdot x}{y + \color{blue}{y \cdot x}} \]
      5. *-commutativeN/A

        \[\leadsto \frac{x \cdot x}{y + x \cdot \color{blue}{y}} \]
      6. distribute-rgt1-inN/A

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

        \[\leadsto \frac{x \cdot x}{\left(1 + x\right) \cdot y} \]
      8. times-fracN/A

        \[\leadsto \frac{x}{1 + x} \cdot \color{blue}{\frac{x}{y}} \]
      9. lower-*.f64N/A

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

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

        \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{y} \]
      12. lift-/.f6499.9

        \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{\color{blue}{y}} \]
    6. Applied rewrites99.9%

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

    if -4.0000000000000001e189 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1e15

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 98.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(\frac{x}{y} + 1\right)\\ t_1 := \frac{t\_0}{x + 1}\\ t_2 := \frac{x}{1 + x} \cdot \frac{x}{y}\\ \mathbf{if}\;t\_1 \leq -100000000000:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left({y}^{-1} - 1, x, 1\right) \cdot x\\ \mathbf{elif}\;t\_1 \leq 100:\\ \;\;\;\;\frac{t\_0}{x}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (+ (/ x y) 1.0)))
        (t_1 (/ t_0 (+ x 1.0)))
        (t_2 (* (/ x (+ 1.0 x)) (/ x y))))
   (if (<= t_1 -100000000000.0)
     t_2
     (if (<= t_1 5e-9)
       (* (fma (- (pow y -1.0) 1.0) x 1.0) x)
       (if (<= t_1 100.0) (/ t_0 x) t_2)))))
double code(double x, double y) {
	double t_0 = x * ((x / y) + 1.0);
	double t_1 = t_0 / (x + 1.0);
	double t_2 = (x / (1.0 + x)) * (x / y);
	double tmp;
	if (t_1 <= -100000000000.0) {
		tmp = t_2;
	} else if (t_1 <= 5e-9) {
		tmp = fma((pow(y, -1.0) - 1.0), x, 1.0) * x;
	} else if (t_1 <= 100.0) {
		tmp = t_0 / x;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(x * Float64(Float64(x / y) + 1.0))
	t_1 = Float64(t_0 / Float64(x + 1.0))
	t_2 = Float64(Float64(x / Float64(1.0 + x)) * Float64(x / y))
	tmp = 0.0
	if (t_1 <= -100000000000.0)
		tmp = t_2;
	elseif (t_1 <= 5e-9)
		tmp = Float64(fma(Float64((y ^ -1.0) - 1.0), x, 1.0) * x);
	elseif (t_1 <= 100.0)
		tmp = Float64(t_0 / x);
	else
		tmp = t_2;
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -100000000000.0], t$95$2, If[LessEqual[t$95$1, 5e-9], N[(N[(N[(N[Power[y, -1.0], $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$1, 100.0], N[(t$95$0 / x), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(\frac{x}{y} + 1\right)\\
t_1 := \frac{t\_0}{x + 1}\\
t_2 := \frac{x}{1 + x} \cdot \frac{x}{y}\\
\mathbf{if}\;t\_1 \leq -100000000000:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left({y}^{-1} - 1, x, 1\right) \cdot x\\

\mathbf{elif}\;t\_1 \leq 100:\\
\;\;\;\;\frac{t\_0}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e11 or 100 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

    1. Initial program 72.1%

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y \cdot 1}} \]
      6. *-rgt-identityN/A

        \[\leadsto \frac{x \cdot x}{y \cdot x + y} \]
      7. lower-fma.f6471.8

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
    4. Applied rewrites71.8%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \]
      3. lift-fma.f64N/A

        \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y}} \]
      4. +-commutativeN/A

        \[\leadsto \frac{x \cdot x}{y + \color{blue}{y \cdot x}} \]
      5. *-commutativeN/A

        \[\leadsto \frac{x \cdot x}{y + x \cdot \color{blue}{y}} \]
      6. distribute-rgt1-inN/A

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

        \[\leadsto \frac{x \cdot x}{\left(1 + x\right) \cdot y} \]
      8. times-fracN/A

        \[\leadsto \frac{x}{1 + x} \cdot \color{blue}{\frac{x}{y}} \]
      9. lower-*.f64N/A

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

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

        \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{y} \]
      12. lift-/.f6499.4

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

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

    if -1e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.0000000000000001e-9

    1. Initial program 99.9%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - 1, x, 1\right) \cdot x \]
      7. inv-powN/A

        \[\leadsto \mathsf{fma}\left({y}^{-1} - 1, x, 1\right) \cdot x \]
      8. lower-pow.f6498.6

        \[\leadsto \mathsf{fma}\left({y}^{-1} - 1, x, 1\right) \cdot x \]
    4. Applied rewrites98.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left({y}^{-1} - 1, x, 1\right) \cdot x} \]

    if 5.0000000000000001e-9 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 100

    1. Initial program 99.9%

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

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

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

    Alternative 5: 97.8% accurate, 0.2× speedup?

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

      1. Initial program 72.2%

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

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

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

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

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

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

          \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y \cdot 1}} \]
        6. *-rgt-identityN/A

          \[\leadsto \frac{x \cdot x}{y \cdot x + y} \]
        7. lower-fma.f6471.7

          \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
      4. Applied rewrites71.7%

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

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

          \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \]
        3. lift-fma.f64N/A

          \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y}} \]
        4. +-commutativeN/A

          \[\leadsto \frac{x \cdot x}{y + \color{blue}{y \cdot x}} \]
        5. *-commutativeN/A

          \[\leadsto \frac{x \cdot x}{y + x \cdot \color{blue}{y}} \]
        6. distribute-rgt1-inN/A

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

          \[\leadsto \frac{x \cdot x}{\left(1 + x\right) \cdot y} \]
        8. times-fracN/A

          \[\leadsto \frac{x}{1 + x} \cdot \color{blue}{\frac{x}{y}} \]
        9. lower-*.f64N/A

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

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

          \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{y} \]
        12. lift-/.f6499.3

          \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{\color{blue}{y}} \]
      6. Applied rewrites99.3%

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

      if -1e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.00000000000000007e-37

      1. Initial program 99.9%

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

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

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

          \[\leadsto \frac{x \cdot \color{blue}{\frac{x + y}{y}}}{1} \]
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \frac{x \cdot \frac{y + x}{y}}{1} \]
          2. lower-/.f64N/A

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

            \[\leadsto \frac{x \cdot \frac{y + x}{y}}{1} \]
        4. Applied rewrites98.3%

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

        if 1.00000000000000007e-37 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2

        1. Initial program 99.9%

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

          \[\leadsto \frac{\color{blue}{x}}{x + 1} \]
        3. Step-by-step derivation
          1. Applied rewrites92.0%

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

        Alternative 6: 97.8% accurate, 0.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ t_1 := \frac{x}{1 + x} \cdot \frac{x}{y}\\ \mathbf{if}\;t\_0 \leq -100000000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 10^{-37}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
                (t_1 (* (/ x (+ 1.0 x)) (/ x y))))
           (if (<= t_0 -100000000000.0)
             t_1
             (if (<= t_0 1e-37)
               (/ (fma (/ x y) x x) 1.0)
               (if (<= t_0 2.0) (/ x (+ x 1.0)) t_1)))))
        double code(double x, double y) {
        	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
        	double t_1 = (x / (1.0 + x)) * (x / y);
        	double tmp;
        	if (t_0 <= -100000000000.0) {
        		tmp = t_1;
        	} else if (t_0 <= 1e-37) {
        		tmp = fma((x / y), x, x) / 1.0;
        	} else if (t_0 <= 2.0) {
        		tmp = x / (x + 1.0);
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        function code(x, y)
        	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
        	t_1 = Float64(Float64(x / Float64(1.0 + x)) * Float64(x / y))
        	tmp = 0.0
        	if (t_0 <= -100000000000.0)
        		tmp = t_1;
        	elseif (t_0 <= 1e-37)
        		tmp = Float64(fma(Float64(x / y), x, x) / 1.0);
        	elseif (t_0 <= 2.0)
        		tmp = Float64(x / Float64(x + 1.0));
        	else
        		tmp = t_1;
        	end
        	return tmp
        end
        
        code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100000000000.0], t$95$1, If[LessEqual[t$95$0, 1e-37], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / 1.0), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
        t_1 := \frac{x}{1 + x} \cdot \frac{x}{y}\\
        \mathbf{if}\;t\_0 \leq -100000000000:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;t\_0 \leq 10^{-37}:\\
        \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\
        
        \mathbf{elif}\;t\_0 \leq 2:\\
        \;\;\;\;\frac{x}{x + 1}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e11 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

          1. Initial program 72.2%

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

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

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

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

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

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

              \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y \cdot 1}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{x \cdot x}{y \cdot x + y} \]
            7. lower-fma.f6471.7

              \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
          4. Applied rewrites71.7%

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

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

              \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \]
            3. lift-fma.f64N/A

              \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y}} \]
            4. +-commutativeN/A

              \[\leadsto \frac{x \cdot x}{y + \color{blue}{y \cdot x}} \]
            5. *-commutativeN/A

              \[\leadsto \frac{x \cdot x}{y + x \cdot \color{blue}{y}} \]
            6. distribute-rgt1-inN/A

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

              \[\leadsto \frac{x \cdot x}{\left(1 + x\right) \cdot y} \]
            8. times-fracN/A

              \[\leadsto \frac{x}{1 + x} \cdot \color{blue}{\frac{x}{y}} \]
            9. lower-*.f64N/A

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

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

              \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{y} \]
            12. lift-/.f6499.3

              \[\leadsto \frac{x}{1 + x} \cdot \frac{x}{\color{blue}{y}} \]
          6. Applied rewrites99.3%

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

          if -1e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.00000000000000007e-37

          1. Initial program 99.9%

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

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

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

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

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

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

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

                \[\leadsto \frac{\frac{x}{y} \cdot x + x}{1} \]
              5. lower-fma.f64N/A

                \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, \color{blue}{x}, x\right)}{1} \]
              6. lift-/.f6498.3

                \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1} \]
            4. Applied rewrites98.3%

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

            if 1.00000000000000007e-37 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2

            1. Initial program 99.9%

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

              \[\leadsto \frac{\color{blue}{x}}{x + 1} \]
            3. Step-by-step derivation
              1. Applied rewrites92.0%

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

            Alternative 7: 93.1% accurate, 0.2× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+16}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t\_0 \leq 10^{-37}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\ \mathbf{elif}\;t\_0 \leq 100:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
            (FPCore (x y)
             :precision binary64
             (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
               (if (<= t_0 -2e+16)
                 (/ x y)
                 (if (<= t_0 1e-37)
                   (/ (fma (/ x y) x x) 1.0)
                   (if (<= t_0 100.0)
                     (/ x (+ x 1.0))
                     (if (<= t_0 5e+182) (* x (/ x (fma y x y))) (/ x y)))))))
            double code(double x, double y) {
            	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
            	double tmp;
            	if (t_0 <= -2e+16) {
            		tmp = x / y;
            	} else if (t_0 <= 1e-37) {
            		tmp = fma((x / y), x, x) / 1.0;
            	} else if (t_0 <= 100.0) {
            		tmp = x / (x + 1.0);
            	} else if (t_0 <= 5e+182) {
            		tmp = x * (x / fma(y, x, y));
            	} else {
            		tmp = x / y;
            	}
            	return tmp;
            }
            
            function code(x, y)
            	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
            	tmp = 0.0
            	if (t_0 <= -2e+16)
            		tmp = Float64(x / y);
            	elseif (t_0 <= 1e-37)
            		tmp = Float64(fma(Float64(x / y), x, x) / 1.0);
            	elseif (t_0 <= 100.0)
            		tmp = Float64(x / Float64(x + 1.0));
            	elseif (t_0 <= 5e+182)
            		tmp = Float64(x * Float64(x / fma(y, x, y)));
            	else
            		tmp = Float64(x / y);
            	end
            	return tmp
            end
            
            code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+16], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 1e-37], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / 1.0), $MachinePrecision], If[LessEqual[t$95$0, 100.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+182], N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
            \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+16}:\\
            \;\;\;\;\frac{x}{y}\\
            
            \mathbf{elif}\;t\_0 \leq 10^{-37}:\\
            \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\
            
            \mathbf{elif}\;t\_0 \leq 100:\\
            \;\;\;\;\frac{x}{x + 1}\\
            
            \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\
            \;\;\;\;x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{x}{y}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 4 regimes
            2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -2e16 or 4.99999999999999973e182 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

              1. Initial program 66.8%

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

                \[\leadsto \color{blue}{\frac{x}{y}} \]
              3. Step-by-step derivation
                1. lift-/.f6489.9

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

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

              if -2e16 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.00000000000000007e-37

              1. Initial program 99.9%

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

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

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

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

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

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

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

                    \[\leadsto \frac{\frac{x}{y} \cdot x + x}{1} \]
                  5. lower-fma.f64N/A

                    \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, \color{blue}{x}, x\right)}{1} \]
                  6. lift-/.f6497.8

                    \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1} \]
                4. Applied rewrites97.8%

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

                if 1.00000000000000007e-37 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 100

                1. Initial program 99.9%

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

                  \[\leadsto \frac{\color{blue}{x}}{x + 1} \]
                3. Step-by-step derivation
                  1. Applied rewrites91.3%

                    \[\leadsto \frac{\color{blue}{x}}{x + 1} \]

                  if 100 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 4.99999999999999973e182

                  1. Initial program 99.7%

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

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

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

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

                      \[\leadsto \frac{x \cdot \color{blue}{\frac{x + y}{y}}}{x + 1} \]
                    5. +-commutativeN/A

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
                    6. *-lft-identityN/A

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{1 \cdot y} + x}{y}}{x + 1} \]
                    7. *-rgt-identityN/A

                      \[\leadsto \frac{x \cdot \frac{1 \cdot y + \color{blue}{x \cdot 1}}{y}}{x + 1} \]
                    8. lower-/.f64N/A

                      \[\leadsto \frac{x \cdot \color{blue}{\frac{1 \cdot y + x \cdot 1}{y}}}{x + 1} \]
                    9. *-lft-identityN/A

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{y} + x \cdot 1}{y}}{x + 1} \]
                    10. *-rgt-identityN/A

                      \[\leadsto \frac{x \cdot \frac{y + \color{blue}{x}}{y}}{x + 1} \]
                    11. lower-+.f6499.7

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
                  3. Applied rewrites99.7%

                    \[\leadsto \frac{x \cdot \color{blue}{\frac{y + x}{y}}}{x + 1} \]
                  4. Taylor expanded in y around 0

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

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

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

                      \[\leadsto \frac{x \cdot x}{\left(x + 1\right) \cdot y} \]
                    4. distribute-rgt1-inN/A

                      \[\leadsto \frac{x \cdot x}{y + \color{blue}{x \cdot y}} \]
                    5. *-commutativeN/A

                      \[\leadsto \frac{x \cdot x}{y + y \cdot \color{blue}{x}} \]
                    6. +-commutativeN/A

                      \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y}} \]
                    7. associate-/l*N/A

                      \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot x + y}} \]
                    8. lower-*.f64N/A

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

                      \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot x + y}} \]
                    10. lift-fma.f6484.8

                      \[\leadsto x \cdot \frac{x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
                  6. Applied rewrites84.8%

                    \[\leadsto \color{blue}{x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}} \]
                4. Recombined 4 regimes into one program.
                5. Add Preprocessing

                Alternative 8: 93.1% accurate, 0.2× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+16}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t\_0 \leq 10^{-37}:\\ \;\;\;\;\mathsf{fma}\left({y}^{-1}, x, 1\right) \cdot x\\ \mathbf{elif}\;t\_0 \leq 100:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
                (FPCore (x y)
                 :precision binary64
                 (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
                   (if (<= t_0 -2e+16)
                     (/ x y)
                     (if (<= t_0 1e-37)
                       (* (fma (pow y -1.0) x 1.0) x)
                       (if (<= t_0 100.0)
                         (/ x (+ x 1.0))
                         (if (<= t_0 5e+182) (* x (/ x (fma y x y))) (/ x y)))))))
                double code(double x, double y) {
                	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                	double tmp;
                	if (t_0 <= -2e+16) {
                		tmp = x / y;
                	} else if (t_0 <= 1e-37) {
                		tmp = fma(pow(y, -1.0), x, 1.0) * x;
                	} else if (t_0 <= 100.0) {
                		tmp = x / (x + 1.0);
                	} else if (t_0 <= 5e+182) {
                		tmp = x * (x / fma(y, x, y));
                	} else {
                		tmp = x / y;
                	}
                	return tmp;
                }
                
                function code(x, y)
                	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
                	tmp = 0.0
                	if (t_0 <= -2e+16)
                		tmp = Float64(x / y);
                	elseif (t_0 <= 1e-37)
                		tmp = Float64(fma((y ^ -1.0), x, 1.0) * x);
                	elseif (t_0 <= 100.0)
                		tmp = Float64(x / Float64(x + 1.0));
                	elseif (t_0 <= 5e+182)
                		tmp = Float64(x * Float64(x / fma(y, x, y)));
                	else
                		tmp = Float64(x / y);
                	end
                	return tmp
                end
                
                code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+16], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 1e-37], N[(N[(N[Power[y, -1.0], $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, 100.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+182], N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
                \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+16}:\\
                \;\;\;\;\frac{x}{y}\\
                
                \mathbf{elif}\;t\_0 \leq 10^{-37}:\\
                \;\;\;\;\mathsf{fma}\left({y}^{-1}, x, 1\right) \cdot x\\
                
                \mathbf{elif}\;t\_0 \leq 100:\\
                \;\;\;\;\frac{x}{x + 1}\\
                
                \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\
                \;\;\;\;x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{x}{y}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 4 regimes
                2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -2e16 or 4.99999999999999973e182 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                  1. Initial program 66.8%

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

                    \[\leadsto \color{blue}{\frac{x}{y}} \]
                  3. Step-by-step derivation
                    1. lift-/.f6489.9

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

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

                  if -2e16 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1.00000000000000007e-37

                  1. Initial program 99.9%

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

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

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

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

                      \[\leadsto \frac{x \cdot \color{blue}{\frac{x + y}{y}}}{x + 1} \]
                    5. +-commutativeN/A

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
                    6. *-lft-identityN/A

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{1 \cdot y} + x}{y}}{x + 1} \]
                    7. *-rgt-identityN/A

                      \[\leadsto \frac{x \cdot \frac{1 \cdot y + \color{blue}{x \cdot 1}}{y}}{x + 1} \]
                    8. lower-/.f64N/A

                      \[\leadsto \frac{x \cdot \color{blue}{\frac{1 \cdot y + x \cdot 1}{y}}}{x + 1} \]
                    9. *-lft-identityN/A

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{y} + x \cdot 1}{y}}{x + 1} \]
                    10. *-rgt-identityN/A

                      \[\leadsto \frac{x \cdot \frac{y + \color{blue}{x}}{y}}{x + 1} \]
                    11. lower-+.f6499.9

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
                  3. Applied rewrites99.9%

                    \[\leadsto \frac{x \cdot \color{blue}{\frac{y + x}{y}}}{x + 1} \]
                  4. Taylor expanded in x around 0

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(\frac{1}{y} - 1, x, 1\right) \cdot x \]
                    7. inv-powN/A

                      \[\leadsto \mathsf{fma}\left({y}^{-1} - 1, x, 1\right) \cdot x \]
                    8. lower-pow.f6498.0

                      \[\leadsto \mathsf{fma}\left({y}^{-1} - 1, x, 1\right) \cdot x \]
                  6. Applied rewrites98.0%

                    \[\leadsto \color{blue}{\mathsf{fma}\left({y}^{-1} - 1, x, 1\right) \cdot x} \]
                  7. Taylor expanded in y around 0

                    \[\leadsto \mathsf{fma}\left(\frac{1}{y}, x, 1\right) \cdot x \]
                  8. Step-by-step derivation
                    1. inv-powN/A

                      \[\leadsto \mathsf{fma}\left({y}^{-1}, x, 1\right) \cdot x \]
                    2. lift-pow.f6497.7

                      \[\leadsto \mathsf{fma}\left({y}^{-1}, x, 1\right) \cdot x \]
                  9. Applied rewrites97.7%

                    \[\leadsto \mathsf{fma}\left({y}^{-1}, x, 1\right) \cdot x \]

                  if 1.00000000000000007e-37 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 100

                  1. Initial program 99.9%

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

                    \[\leadsto \frac{\color{blue}{x}}{x + 1} \]
                  3. Step-by-step derivation
                    1. Applied rewrites91.3%

                      \[\leadsto \frac{\color{blue}{x}}{x + 1} \]

                    if 100 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 4.99999999999999973e182

                    1. Initial program 99.7%

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

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

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

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

                        \[\leadsto \frac{x \cdot \color{blue}{\frac{x + y}{y}}}{x + 1} \]
                      5. +-commutativeN/A

                        \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
                      6. *-lft-identityN/A

                        \[\leadsto \frac{x \cdot \frac{\color{blue}{1 \cdot y} + x}{y}}{x + 1} \]
                      7. *-rgt-identityN/A

                        \[\leadsto \frac{x \cdot \frac{1 \cdot y + \color{blue}{x \cdot 1}}{y}}{x + 1} \]
                      8. lower-/.f64N/A

                        \[\leadsto \frac{x \cdot \color{blue}{\frac{1 \cdot y + x \cdot 1}{y}}}{x + 1} \]
                      9. *-lft-identityN/A

                        \[\leadsto \frac{x \cdot \frac{\color{blue}{y} + x \cdot 1}{y}}{x + 1} \]
                      10. *-rgt-identityN/A

                        \[\leadsto \frac{x \cdot \frac{y + \color{blue}{x}}{y}}{x + 1} \]
                      11. lower-+.f6499.7

                        \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
                    3. Applied rewrites99.7%

                      \[\leadsto \frac{x \cdot \color{blue}{\frac{y + x}{y}}}{x + 1} \]
                    4. Taylor expanded in y around 0

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

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

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

                        \[\leadsto \frac{x \cdot x}{\left(x + 1\right) \cdot y} \]
                      4. distribute-rgt1-inN/A

                        \[\leadsto \frac{x \cdot x}{y + \color{blue}{x \cdot y}} \]
                      5. *-commutativeN/A

                        \[\leadsto \frac{x \cdot x}{y + y \cdot \color{blue}{x}} \]
                      6. +-commutativeN/A

                        \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y}} \]
                      7. associate-/l*N/A

                        \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot x + y}} \]
                      8. lower-*.f64N/A

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

                        \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot x + y}} \]
                      10. lift-fma.f6484.8

                        \[\leadsto x \cdot \frac{x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
                    6. Applied rewrites84.8%

                      \[\leadsto \color{blue}{x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}} \]
                  4. Recombined 4 regimes into one program.
                  5. Add Preprocessing

                  Alternative 9: 90.1% accurate, 0.2× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\ t_1 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t\_1 \leq -0.02:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 100:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
                  (FPCore (x y)
                   :precision binary64
                   (let* ((t_0 (* x (/ x (fma y x y))))
                          (t_1 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
                     (if (<= t_1 (- INFINITY))
                       (/ x y)
                       (if (<= t_1 -0.02)
                         t_0
                         (if (<= t_1 100.0) (/ x (+ x 1.0)) (if (<= t_1 5e+182) t_0 (/ x y)))))))
                  double code(double x, double y) {
                  	double t_0 = x * (x / fma(y, x, y));
                  	double t_1 = (x * ((x / y) + 1.0)) / (x + 1.0);
                  	double tmp;
                  	if (t_1 <= -((double) INFINITY)) {
                  		tmp = x / y;
                  	} else if (t_1 <= -0.02) {
                  		tmp = t_0;
                  	} else if (t_1 <= 100.0) {
                  		tmp = x / (x + 1.0);
                  	} else if (t_1 <= 5e+182) {
                  		tmp = t_0;
                  	} else {
                  		tmp = x / y;
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y)
                  	t_0 = Float64(x * Float64(x / fma(y, x, y)))
                  	t_1 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
                  	tmp = 0.0
                  	if (t_1 <= Float64(-Inf))
                  		tmp = Float64(x / y);
                  	elseif (t_1 <= -0.02)
                  		tmp = t_0;
                  	elseif (t_1 <= 100.0)
                  		tmp = Float64(x / Float64(x + 1.0));
                  	elseif (t_1 <= 5e+182)
                  		tmp = t_0;
                  	else
                  		tmp = Float64(x / y);
                  	end
                  	return tmp
                  end
                  
                  code[x_, y_] := Block[{t$95$0 = N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x / y), $MachinePrecision], If[LessEqual[t$95$1, -0.02], t$95$0, If[LessEqual[t$95$1, 100.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+182], t$95$0, N[(x / y), $MachinePrecision]]]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\
                  t_1 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
                  \mathbf{if}\;t\_1 \leq -\infty:\\
                  \;\;\;\;\frac{x}{y}\\
                  
                  \mathbf{elif}\;t\_1 \leq -0.02:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;t\_1 \leq 100:\\
                  \;\;\;\;\frac{x}{x + 1}\\
                  
                  \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+182}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{x}{y}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -inf.0 or 4.99999999999999973e182 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                    1. Initial program 56.3%

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

                      \[\leadsto \color{blue}{\frac{x}{y}} \]
                    3. Step-by-step derivation
                      1. lift-/.f6497.9

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

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

                    if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -0.0200000000000000004 or 100 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 4.99999999999999973e182

                    1. Initial program 99.7%

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

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

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

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

                        \[\leadsto \frac{x \cdot \color{blue}{\frac{x + y}{y}}}{x + 1} \]
                      5. +-commutativeN/A

                        \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
                      6. *-lft-identityN/A

                        \[\leadsto \frac{x \cdot \frac{\color{blue}{1 \cdot y} + x}{y}}{x + 1} \]
                      7. *-rgt-identityN/A

                        \[\leadsto \frac{x \cdot \frac{1 \cdot y + \color{blue}{x \cdot 1}}{y}}{x + 1} \]
                      8. lower-/.f64N/A

                        \[\leadsto \frac{x \cdot \color{blue}{\frac{1 \cdot y + x \cdot 1}{y}}}{x + 1} \]
                      9. *-lft-identityN/A

                        \[\leadsto \frac{x \cdot \frac{\color{blue}{y} + x \cdot 1}{y}}{x + 1} \]
                      10. *-rgt-identityN/A

                        \[\leadsto \frac{x \cdot \frac{y + \color{blue}{x}}{y}}{x + 1} \]
                      11. lower-+.f6499.7

                        \[\leadsto \frac{x \cdot \frac{\color{blue}{y + x}}{y}}{x + 1} \]
                    3. Applied rewrites99.7%

                      \[\leadsto \frac{x \cdot \color{blue}{\frac{y + x}{y}}}{x + 1} \]
                    4. Taylor expanded in y around 0

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

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

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

                        \[\leadsto \frac{x \cdot x}{\left(x + 1\right) \cdot y} \]
                      4. distribute-rgt1-inN/A

                        \[\leadsto \frac{x \cdot x}{y + \color{blue}{x \cdot y}} \]
                      5. *-commutativeN/A

                        \[\leadsto \frac{x \cdot x}{y + y \cdot \color{blue}{x}} \]
                      6. +-commutativeN/A

                        \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y}} \]
                      7. associate-/l*N/A

                        \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot x + y}} \]
                      8. lower-*.f64N/A

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

                        \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot x + y}} \]
                      10. lift-fma.f6485.7

                        \[\leadsto x \cdot \frac{x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
                    6. Applied rewrites85.7%

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

                    if -0.0200000000000000004 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 100

                    1. Initial program 99.9%

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

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

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

                    Alternative 10: 87.2% accurate, 0.2× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_0 \leq -100000000000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t\_0 \leq 100:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;\frac{x \cdot x}{\mathsf{fma}\left(y, x, y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
                    (FPCore (x y)
                     :precision binary64
                     (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
                       (if (<= t_0 -100000000000.0)
                         (/ x y)
                         (if (<= t_0 100.0)
                           (/ x (+ x 1.0))
                           (if (<= t_0 5e+182) (/ (* x x) (fma y x y)) (/ x y))))))
                    double code(double x, double y) {
                    	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                    	double tmp;
                    	if (t_0 <= -100000000000.0) {
                    		tmp = x / y;
                    	} else if (t_0 <= 100.0) {
                    		tmp = x / (x + 1.0);
                    	} else if (t_0 <= 5e+182) {
                    		tmp = (x * x) / fma(y, x, y);
                    	} else {
                    		tmp = x / y;
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y)
                    	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
                    	tmp = 0.0
                    	if (t_0 <= -100000000000.0)
                    		tmp = Float64(x / y);
                    	elseif (t_0 <= 100.0)
                    		tmp = Float64(x / Float64(x + 1.0));
                    	elseif (t_0 <= 5e+182)
                    		tmp = Float64(Float64(x * x) / fma(y, x, y));
                    	else
                    		tmp = Float64(x / y);
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 100.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+182], N[(N[(x * x), $MachinePrecision] / N[(y * x + y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
                    \mathbf{if}\;t\_0 \leq -100000000000:\\
                    \;\;\;\;\frac{x}{y}\\
                    
                    \mathbf{elif}\;t\_0 \leq 100:\\
                    \;\;\;\;\frac{x}{x + 1}\\
                    
                    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\
                    \;\;\;\;\frac{x \cdot x}{\mathsf{fma}\left(y, x, y\right)}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\frac{x}{y}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 3 regimes
                    2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e11 or 4.99999999999999973e182 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                      1. Initial program 67.1%

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

                        \[\leadsto \color{blue}{\frac{x}{y}} \]
                      3. Step-by-step derivation
                        1. lift-/.f6489.6

                          \[\leadsto \frac{x}{\color{blue}{y}} \]
                      4. Applied rewrites89.6%

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

                      if -1e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 100

                      1. Initial program 99.9%

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

                        \[\leadsto \frac{\color{blue}{x}}{x + 1} \]
                      3. Step-by-step derivation
                        1. Applied rewrites86.6%

                          \[\leadsto \frac{\color{blue}{x}}{x + 1} \]

                        if 100 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 4.99999999999999973e182

                        1. Initial program 99.7%

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

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

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

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

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

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

                            \[\leadsto \frac{x \cdot x}{y \cdot x + \color{blue}{y \cdot 1}} \]
                          6. *-rgt-identityN/A

                            \[\leadsto \frac{x \cdot x}{y \cdot x + y} \]
                          7. lower-fma.f6479.4

                            \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
                        4. Applied rewrites79.4%

                          \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(y, x, y\right)}} \]
                      4. Recombined 3 regimes into one program.
                      5. Add Preprocessing

                      Alternative 11: 86.2% accurate, 0.3× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_0 \leq -100000000000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
                      (FPCore (x y)
                       :precision binary64
                       (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
                         (if (<= t_0 -100000000000.0)
                           (/ x y)
                           (if (<= t_0 2.0) (/ x (+ x 1.0)) (/ x y)))))
                      double code(double x, double y) {
                      	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                      	double tmp;
                      	if (t_0 <= -100000000000.0) {
                      		tmp = x / y;
                      	} else if (t_0 <= 2.0) {
                      		tmp = x / (x + 1.0);
                      	} else {
                      		tmp = x / y;
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x, y)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          real(8) :: t_0
                          real(8) :: tmp
                          t_0 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
                          if (t_0 <= (-100000000000.0d0)) then
                              tmp = x / y
                          else if (t_0 <= 2.0d0) then
                              tmp = x / (x + 1.0d0)
                          else
                              tmp = x / y
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double x, double y) {
                      	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                      	double tmp;
                      	if (t_0 <= -100000000000.0) {
                      		tmp = x / y;
                      	} else if (t_0 <= 2.0) {
                      		tmp = x / (x + 1.0);
                      	} else {
                      		tmp = x / y;
                      	}
                      	return tmp;
                      }
                      
                      def code(x, y):
                      	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0)
                      	tmp = 0
                      	if t_0 <= -100000000000.0:
                      		tmp = x / y
                      	elif t_0 <= 2.0:
                      		tmp = x / (x + 1.0)
                      	else:
                      		tmp = x / y
                      	return tmp
                      
                      function code(x, y)
                      	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
                      	tmp = 0.0
                      	if (t_0 <= -100000000000.0)
                      		tmp = Float64(x / y);
                      	elseif (t_0 <= 2.0)
                      		tmp = Float64(x / Float64(x + 1.0));
                      	else
                      		tmp = Float64(x / y);
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(x, y)
                      	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                      	tmp = 0.0;
                      	if (t_0 <= -100000000000.0)
                      		tmp = x / y;
                      	elseif (t_0 <= 2.0)
                      		tmp = x / (x + 1.0);
                      	else
                      		tmp = x / y;
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
                      \mathbf{if}\;t\_0 \leq -100000000000:\\
                      \;\;\;\;\frac{x}{y}\\
                      
                      \mathbf{elif}\;t\_0 \leq 2:\\
                      \;\;\;\;\frac{x}{x + 1}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{x}{y}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e11 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                        1. Initial program 72.2%

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

                          \[\leadsto \color{blue}{\frac{x}{y}} \]
                        3. Step-by-step derivation
                          1. lift-/.f6485.3

                            \[\leadsto \frac{x}{\color{blue}{y}} \]
                        4. Applied rewrites85.3%

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

                        if -1e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2

                        1. Initial program 99.9%

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

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

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

                        Alternative 12: 85.1% accurate, 0.2× speedup?

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

                          1. Initial program 72.2%

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

                            \[\leadsto \color{blue}{\frac{x}{y}} \]
                          3. Step-by-step derivation
                            1. lift-/.f6485.3

                              \[\leadsto \frac{x}{\color{blue}{y}} \]
                          4. Applied rewrites85.3%

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

                          if -1e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.0000000000000001e-9

                          1. Initial program 99.9%

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

                            \[\leadsto \color{blue}{x} \]
                          3. Step-by-step derivation
                            1. Applied rewrites83.7%

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

                            if 5.0000000000000001e-9 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2

                            1. Initial program 100.0%

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

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

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

                                \[\leadsto \frac{\color{blue}{x}}{x} \]
                              3. Step-by-step derivation
                                1. Applied rewrites89.4%

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

                              Alternative 13: 73.9% accurate, 0.4× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_0 \leq -100000000000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
                              (FPCore (x y)
                               :precision binary64
                               (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
                                 (if (<= t_0 -100000000000.0) (/ x y) (if (<= t_0 1.0) x (/ x y)))))
                              double code(double x, double y) {
                              	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                              	double tmp;
                              	if (t_0 <= -100000000000.0) {
                              		tmp = x / y;
                              	} else if (t_0 <= 1.0) {
                              		tmp = x;
                              	} else {
                              		tmp = x / y;
                              	}
                              	return tmp;
                              }
                              
                              module fmin_fmax_functions
                                  implicit none
                                  private
                                  public fmax
                                  public fmin
                              
                                  interface fmax
                                      module procedure fmax88
                                      module procedure fmax44
                                      module procedure fmax84
                                      module procedure fmax48
                                  end interface
                                  interface fmin
                                      module procedure fmin88
                                      module procedure fmin44
                                      module procedure fmin84
                                      module procedure fmin48
                                  end interface
                              contains
                                  real(8) function fmax88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmax44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmax84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmax48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmin44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmin48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                  end function
                              end module
                              
                              real(8) function code(x, y)
                              use fmin_fmax_functions
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  real(8) :: t_0
                                  real(8) :: tmp
                                  t_0 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
                                  if (t_0 <= (-100000000000.0d0)) then
                                      tmp = x / y
                                  else if (t_0 <= 1.0d0) then
                                      tmp = x
                                  else
                                      tmp = x / y
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double x, double y) {
                              	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                              	double tmp;
                              	if (t_0 <= -100000000000.0) {
                              		tmp = x / y;
                              	} else if (t_0 <= 1.0) {
                              		tmp = x;
                              	} else {
                              		tmp = x / y;
                              	}
                              	return tmp;
                              }
                              
                              def code(x, y):
                              	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0)
                              	tmp = 0
                              	if t_0 <= -100000000000.0:
                              		tmp = x / y
                              	elif t_0 <= 1.0:
                              		tmp = x
                              	else:
                              		tmp = x / y
                              	return tmp
                              
                              function code(x, y)
                              	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
                              	tmp = 0.0
                              	if (t_0 <= -100000000000.0)
                              		tmp = Float64(x / y);
                              	elseif (t_0 <= 1.0)
                              		tmp = x;
                              	else
                              		tmp = Float64(x / y);
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(x, y)
                              	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                              	tmp = 0.0;
                              	if (t_0 <= -100000000000.0)
                              		tmp = x / y;
                              	elseif (t_0 <= 1.0)
                              		tmp = x;
                              	else
                              		tmp = x / y;
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 1.0], x, N[(x / y), $MachinePrecision]]]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
                              \mathbf{if}\;t\_0 \leq -100000000000:\\
                              \;\;\;\;\frac{x}{y}\\
                              
                              \mathbf{elif}\;t\_0 \leq 1:\\
                              \;\;\;\;x\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\frac{x}{y}\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -1e11 or 1 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                                1. Initial program 73.1%

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

                                  \[\leadsto \color{blue}{\frac{x}{y}} \]
                                3. Step-by-step derivation
                                  1. lift-/.f6482.8

                                    \[\leadsto \frac{x}{\color{blue}{y}} \]
                                4. Applied rewrites82.8%

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

                                if -1e11 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 1

                                1. Initial program 99.9%

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

                                  \[\leadsto \color{blue}{x} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites66.8%

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

                                Alternative 14: 39.0% accurate, 11.0× speedup?

                                \[\begin{array}{l} \\ x \end{array} \]
                                (FPCore (x y) :precision binary64 x)
                                double code(double x, double y) {
                                	return x;
                                }
                                
                                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
                                end function
                                
                                public static double code(double x, double y) {
                                	return x;
                                }
                                
                                def code(x, y):
                                	return x
                                
                                function code(x, y)
                                	return x
                                end
                                
                                function tmp = code(x, y)
                                	tmp = x;
                                end
                                
                                code[x_, y_] := x
                                
                                \begin{array}{l}
                                
                                \\
                                x
                                \end{array}
                                
                                Derivation
                                1. Initial program 88.2%

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

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

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

                                  Reproduce

                                  ?
                                  herbie shell --seed 2025101 
                                  (FPCore (x y)
                                    :name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
                                    :precision binary64
                                    (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))