Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D

Percentage Accurate: 65.2% → 99.9%
Time: 3.0s
Alternatives: 14
Speedup: 0.9×

Specification

?
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function tmp = code(x, y)
	tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}

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

\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function tmp = code(x, y)
	tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}

Alternative 1: 99.9% accurate, 0.6× speedup?

\[\begin{array}{l} \mathbf{if}\;y \leq -1000000000000:\\ \;\;\;\;x - \frac{-1}{y}\\ \mathbf{elif}\;y \leq 1.15:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{y - -1}, x - 1, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x - 1}{y}, -1 - \frac{-1}{y}, x\right)\\ \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1000000000000.0)
   (- x (/ -1.0 y))
   (if (<= y 1.15)
     (fma (/ y (- y -1.0)) (- x 1.0) 1.0)
     (fma (/ (- x 1.0) y) (- -1.0 (/ -1.0 y)) x))))
double code(double x, double y) {
	double tmp;
	if (y <= -1000000000000.0) {
		tmp = x - (-1.0 / y);
	} else if (y <= 1.15) {
		tmp = fma((y / (y - -1.0)), (x - 1.0), 1.0);
	} else {
		tmp = fma(((x - 1.0) / y), (-1.0 - (-1.0 / y)), x);
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (y <= -1000000000000.0)
		tmp = Float64(x - Float64(-1.0 / y));
	elseif (y <= 1.15)
		tmp = fma(Float64(y / Float64(y - -1.0)), Float64(x - 1.0), 1.0);
	else
		tmp = fma(Float64(Float64(x - 1.0) / y), Float64(-1.0 - Float64(-1.0 / y)), x);
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -1000000000000.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.15], N[(N[(y / N[(y - -1.0), $MachinePrecision]), $MachinePrecision] * N[(x - 1.0), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision] * N[(-1.0 - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -1000000000000:\\
\;\;\;\;x - \frac{-1}{y}\\

\mathbf{elif}\;y \leq 1.15:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{y - -1}, x - 1, 1\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - 1}{y}, -1 - \frac{-1}{y}, x\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1e12

    1. Initial program 65.2%

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

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

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

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

        \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
      4. lower--.f6451.2%

        \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
    4. Applied rewrites51.2%

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

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

        \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
      3. mul-1-negN/A

        \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
      4. sub-flip-reverseN/A

        \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
      5. lower--.f6451.2%

        \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
    6. Applied rewrites51.2%

      \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
    7. Taylor expanded in x around 0

      \[\leadsto x - \frac{-1}{y} \]
    8. Step-by-step derivation
      1. Applied rewrites51.3%

        \[\leadsto x - \frac{-1}{y} \]

      if -1e12 < y < 1.1499999999999999

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{y}{y + 1} \cdot \left(\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)\right) + 1 \]
        10. sub-negate-revN/A

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{y + 1}}, x - 1, 1\right) \]
        14. add-flipN/A

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

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

          \[\leadsto \mathsf{fma}\left(\frac{y}{y - \color{blue}{-1}}, x - 1, 1\right) \]
        17. lower--.f6476.9%

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

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

      if 1.1499999999999999 < y

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

          \[\leadsto x + -1 \cdot \frac{-1 \cdot \frac{x - 1}{y} - -1 \cdot \left(x - 1\right)}{y} \]
        9. lower--.f6451.3%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x - 1}{y}, -1 - \frac{-1}{y}, x\right)} \]
    9. Recombined 3 regimes into one program.
    10. Add Preprocessing

    Alternative 2: 99.9% accurate, 0.3× speedup?

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

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{y}{y + 1} \cdot \left(\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)\right) + 1 \]
        10. sub-negate-revN/A

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{y + 1}}, x - 1, 1\right) \]
        14. add-flipN/A

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

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

          \[\leadsto \mathsf{fma}\left(\frac{y}{y - \color{blue}{-1}}, x - 1, 1\right) \]
        17. lower--.f6476.9%

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

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

      if -5e10 < (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < 1e-3

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

          \[\leadsto x + -1 \cdot \frac{-1 \cdot \frac{x - 1}{y} - -1 \cdot \left(x - 1\right)}{y} \]
        9. lower--.f6451.3%

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

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

        \[\leadsto x + -1 \cdot \frac{\frac{1}{y} - 1}{y} \]
      6. Step-by-step derivation
        1. lower--.f64N/A

          \[\leadsto x + -1 \cdot \frac{\frac{1}{y} - 1}{y} \]
        2. lower-/.f6450.8%

          \[\leadsto x + -1 \cdot \frac{\frac{1}{y} - 1}{y} \]
      7. Applied rewrites50.8%

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

    Alternative 3: 99.6% accurate, 0.3× speedup?

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

      1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{y}{y + 1} \cdot \left(\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)\right) + 1 \]
        10. sub-negate-revN/A

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{y + 1}}, x - 1, 1\right) \]
        14. add-flipN/A

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

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

          \[\leadsto \mathsf{fma}\left(\frac{y}{y - \color{blue}{-1}}, x - 1, 1\right) \]
        17. lower--.f6476.9%

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

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

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

      1. Initial program 65.2%

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

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

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

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

            \[\leadsto 1 - \color{blue}{\frac{y}{y + 1}} \]
          3. sub-to-fractionN/A

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

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

            \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
          6. lower--.f6440.0%

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

            \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
          8. add-flipN/A

            \[\leadsto \frac{\color{blue}{\left(y - \left(\mathsf{neg}\left(1\right)\right)\right)} - y}{y + 1} \]
          9. metadata-evalN/A

            \[\leadsto \frac{\left(y - \color{blue}{-1}\right) - y}{y + 1} \]
          10. lift--.f6440.0%

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

            \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y + 1}} \]
          12. add-flipN/A

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

            \[\leadsto \frac{\left(y - -1\right) - y}{y - \color{blue}{-1}} \]
          14. lift--.f6440.0%

            \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y - -1}} \]
        3. Applied rewrites40.0%

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

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

            \[\leadsto \frac{1 + \color{blue}{x \cdot y}}{y - -1} \]
          2. lower-*.f6488.3%

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

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

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

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

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

            \[\leadsto \frac{y \cdot x + 1}{y - -1} \]
          5. lower-fma.f6488.3%

            \[\leadsto \frac{\mathsf{fma}\left(y, \color{blue}{x}, 1\right)}{y - -1} \]
        8. Applied rewrites88.3%

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

      Alternative 4: 99.5% accurate, 0.8× speedup?

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

        1. Initial program 65.2%

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

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

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

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

            \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
          4. lower--.f6451.2%

            \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
        4. Applied rewrites51.2%

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

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

            \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
          3. mul-1-negN/A

            \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
          4. sub-flip-reverseN/A

            \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
          5. lower--.f6451.2%

            \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
        6. Applied rewrites51.2%

          \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
        7. Taylor expanded in x around 0

          \[\leadsto x - \frac{-1}{y} \]
        8. Step-by-step derivation
          1. Applied rewrites51.3%

            \[\leadsto x - \frac{-1}{y} \]

          if -5.0000000000000003e31 < y < 4.5e11

          1. Initial program 65.2%

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

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

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

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

                \[\leadsto 1 - \color{blue}{\frac{y}{y + 1}} \]
              3. sub-to-fractionN/A

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

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

                \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
              6. lower--.f6440.0%

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

                \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
              8. add-flipN/A

                \[\leadsto \frac{\color{blue}{\left(y - \left(\mathsf{neg}\left(1\right)\right)\right)} - y}{y + 1} \]
              9. metadata-evalN/A

                \[\leadsto \frac{\left(y - \color{blue}{-1}\right) - y}{y + 1} \]
              10. lift--.f6440.0%

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

                \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y + 1}} \]
              12. add-flipN/A

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

                \[\leadsto \frac{\left(y - -1\right) - y}{y - \color{blue}{-1}} \]
              14. lift--.f6440.0%

                \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y - -1}} \]
            3. Applied rewrites40.0%

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

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

                \[\leadsto \frac{1 + \color{blue}{x \cdot y}}{y - -1} \]
              2. lower-*.f6488.3%

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

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

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

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

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

                \[\leadsto \frac{y \cdot x + 1}{y - -1} \]
              5. lower-fma.f6488.3%

                \[\leadsto \frac{\mathsf{fma}\left(y, \color{blue}{x}, 1\right)}{y - -1} \]
            8. Applied rewrites88.3%

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

          Alternative 5: 98.3% accurate, 0.9× speedup?

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

            1. Initial program 65.2%

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

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

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

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

                \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
              4. lower--.f6451.2%

                \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
            4. Applied rewrites51.2%

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

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

                \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
              3. mul-1-negN/A

                \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
              4. sub-flip-reverseN/A

                \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
              5. lower--.f6451.2%

                \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
            6. Applied rewrites51.2%

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

            if -0.33000000000000002 < y < 1

            1. Initial program 65.2%

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

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

                \[\leadsto 1 - y \cdot \color{blue}{\left(1 - x\right)} \]
              2. lower--.f6449.6%

                \[\leadsto 1 - y \cdot \left(1 - \color{blue}{x}\right) \]
            4. Applied rewrites49.6%

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

          Alternative 6: 98.0% accurate, 0.9× speedup?

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

            1. Initial program 65.2%

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

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

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

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

                \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
              4. lower--.f6451.2%

                \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
            4. Applied rewrites51.2%

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

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

                \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
              3. mul-1-negN/A

                \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
              4. sub-flip-reverseN/A

                \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
              5. lower--.f6451.2%

                \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
            6. Applied rewrites51.2%

              \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
            7. Taylor expanded in x around 0

              \[\leadsto x - \frac{-1}{y} \]
            8. Step-by-step derivation
              1. Applied rewrites51.3%

                \[\leadsto x - \frac{-1}{y} \]

              if -0.02 < y < 0.14999999999999999

              1. Initial program 65.2%

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

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

                  \[\leadsto 1 - y \cdot \color{blue}{\left(1 - x\right)} \]
                2. lower--.f6449.6%

                  \[\leadsto 1 - y \cdot \left(1 - \color{blue}{x}\right) \]
              4. Applied rewrites49.6%

                \[\leadsto 1 - \color{blue}{y \cdot \left(1 - x\right)} \]
            9. Recombined 2 regimes into one program.
            10. Add Preprocessing

            Alternative 7: 86.2% accurate, 0.4× speedup?

            \[\begin{array}{l} t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{if}\;t\_0 \leq -0.4:\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-11}:\\ \;\;\;\;\frac{1}{y - -1}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{-1}{y}\\ \end{array} \]
            (FPCore (x y)
             :precision binary64
             (let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0))))
               (if (<= t_0 -0.4)
                 (- x (/ x y))
                 (if (<= t_0 2e-11) (/ 1.0 (- y -1.0)) (- x (/ -1.0 y))))))
            double code(double x, double y) {
            	double t_0 = ((1.0 - x) * y) / (y + 1.0);
            	double tmp;
            	if (t_0 <= -0.4) {
            		tmp = x - (x / y);
            	} else if (t_0 <= 2e-11) {
            		tmp = 1.0 / (y - -1.0);
            	} else {
            		tmp = x - (-1.0 / 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 = ((1.0d0 - x) * y) / (y + 1.0d0)
                if (t_0 <= (-0.4d0)) then
                    tmp = x - (x / y)
                else if (t_0 <= 2d-11) then
                    tmp = 1.0d0 / (y - (-1.0d0))
                else
                    tmp = x - ((-1.0d0) / y)
                end if
                code = tmp
            end function
            
            public static double code(double x, double y) {
            	double t_0 = ((1.0 - x) * y) / (y + 1.0);
            	double tmp;
            	if (t_0 <= -0.4) {
            		tmp = x - (x / y);
            	} else if (t_0 <= 2e-11) {
            		tmp = 1.0 / (y - -1.0);
            	} else {
            		tmp = x - (-1.0 / y);
            	}
            	return tmp;
            }
            
            def code(x, y):
            	t_0 = ((1.0 - x) * y) / (y + 1.0)
            	tmp = 0
            	if t_0 <= -0.4:
            		tmp = x - (x / y)
            	elif t_0 <= 2e-11:
            		tmp = 1.0 / (y - -1.0)
            	else:
            		tmp = x - (-1.0 / y)
            	return tmp
            
            function code(x, y)
            	t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))
            	tmp = 0.0
            	if (t_0 <= -0.4)
            		tmp = Float64(x - Float64(x / y));
            	elseif (t_0 <= 2e-11)
            		tmp = Float64(1.0 / Float64(y - -1.0));
            	else
            		tmp = Float64(x - Float64(-1.0 / y));
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y)
            	t_0 = ((1.0 - x) * y) / (y + 1.0);
            	tmp = 0.0;
            	if (t_0 <= -0.4)
            		tmp = x - (x / y);
            	elseif (t_0 <= 2e-11)
            		tmp = 1.0 / (y - -1.0);
            	else
            		tmp = x - (-1.0 / y);
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.4], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-11], N[(1.0 / N[(y - -1.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]]]
            
            \begin{array}{l}
            t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
            \mathbf{if}\;t\_0 \leq -0.4:\\
            \;\;\;\;x - \frac{x}{y}\\
            
            \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-11}:\\
            \;\;\;\;\frac{1}{y - -1}\\
            
            \mathbf{else}:\\
            \;\;\;\;x - \frac{-1}{y}\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -0.40000000000000002

              1. Initial program 65.2%

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

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

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

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

                  \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                4. lower--.f6451.2%

                  \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
              4. Applied rewrites51.2%

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

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

                  \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
                3. mul-1-negN/A

                  \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
                4. sub-flip-reverseN/A

                  \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                5. lower--.f6451.2%

                  \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
              6. Applied rewrites51.2%

                \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
              7. Taylor expanded in x around inf

                \[\leadsto x - \frac{x}{\color{blue}{y}} \]
              8. Step-by-step derivation
                1. lower-/.f6438.9%

                  \[\leadsto x - \frac{x}{y} \]
              9. Applied rewrites38.9%

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

              if -0.40000000000000002 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.9999999999999999e-11

              1. Initial program 65.2%

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

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

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

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

                    \[\leadsto 1 - \color{blue}{\frac{y}{y + 1}} \]
                  3. sub-to-fractionN/A

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

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

                    \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
                  6. lower--.f6440.0%

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

                    \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
                  8. add-flipN/A

                    \[\leadsto \frac{\color{blue}{\left(y - \left(\mathsf{neg}\left(1\right)\right)\right)} - y}{y + 1} \]
                  9. metadata-evalN/A

                    \[\leadsto \frac{\left(y - \color{blue}{-1}\right) - y}{y + 1} \]
                  10. lift--.f6440.0%

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

                    \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y + 1}} \]
                  12. add-flipN/A

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

                    \[\leadsto \frac{\left(y - -1\right) - y}{y - \color{blue}{-1}} \]
                  14. lift--.f6440.0%

                    \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y - -1}} \]
                3. Applied rewrites40.0%

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

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

                    \[\leadsto \frac{1 + \color{blue}{x \cdot y}}{y - -1} \]
                  2. lower-*.f6488.3%

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

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

                  \[\leadsto \frac{\color{blue}{1}}{y - -1} \]
                8. Step-by-step derivation
                  1. Applied rewrites50.9%

                    \[\leadsto \frac{\color{blue}{1}}{y - -1} \]

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

                  1. Initial program 65.2%

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

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

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

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

                      \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                    4. lower--.f6451.2%

                      \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                  4. Applied rewrites51.2%

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

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

                      \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
                    3. mul-1-negN/A

                      \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
                    4. sub-flip-reverseN/A

                      \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                    5. lower--.f6451.2%

                      \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                  6. Applied rewrites51.2%

                    \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
                  7. Taylor expanded in x around 0

                    \[\leadsto x - \frac{-1}{y} \]
                  8. Step-by-step derivation
                    1. Applied rewrites51.3%

                      \[\leadsto x - \frac{-1}{y} \]
                  9. Recombined 3 regimes into one program.
                  10. Add Preprocessing

                  Alternative 8: 86.1% accurate, 0.4× speedup?

                  \[\begin{array}{l} t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{if}\;t\_0 \leq -0.4:\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-11}:\\ \;\;\;\;1 + -1 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x - \frac{-1}{y}\\ \end{array} \]
                  (FPCore (x y)
                   :precision binary64
                   (let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0))))
                     (if (<= t_0 -0.4)
                       (- x (/ x y))
                       (if (<= t_0 2e-11) (+ 1.0 (* -1.0 y)) (- x (/ -1.0 y))))))
                  double code(double x, double y) {
                  	double t_0 = ((1.0 - x) * y) / (y + 1.0);
                  	double tmp;
                  	if (t_0 <= -0.4) {
                  		tmp = x - (x / y);
                  	} else if (t_0 <= 2e-11) {
                  		tmp = 1.0 + (-1.0 * y);
                  	} else {
                  		tmp = x - (-1.0 / 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 = ((1.0d0 - x) * y) / (y + 1.0d0)
                      if (t_0 <= (-0.4d0)) then
                          tmp = x - (x / y)
                      else if (t_0 <= 2d-11) then
                          tmp = 1.0d0 + ((-1.0d0) * y)
                      else
                          tmp = x - ((-1.0d0) / y)
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y) {
                  	double t_0 = ((1.0 - x) * y) / (y + 1.0);
                  	double tmp;
                  	if (t_0 <= -0.4) {
                  		tmp = x - (x / y);
                  	} else if (t_0 <= 2e-11) {
                  		tmp = 1.0 + (-1.0 * y);
                  	} else {
                  		tmp = x - (-1.0 / y);
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y):
                  	t_0 = ((1.0 - x) * y) / (y + 1.0)
                  	tmp = 0
                  	if t_0 <= -0.4:
                  		tmp = x - (x / y)
                  	elif t_0 <= 2e-11:
                  		tmp = 1.0 + (-1.0 * y)
                  	else:
                  		tmp = x - (-1.0 / y)
                  	return tmp
                  
                  function code(x, y)
                  	t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))
                  	tmp = 0.0
                  	if (t_0 <= -0.4)
                  		tmp = Float64(x - Float64(x / y));
                  	elseif (t_0 <= 2e-11)
                  		tmp = Float64(1.0 + Float64(-1.0 * y));
                  	else
                  		tmp = Float64(x - Float64(-1.0 / y));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y)
                  	t_0 = ((1.0 - x) * y) / (y + 1.0);
                  	tmp = 0.0;
                  	if (t_0 <= -0.4)
                  		tmp = x - (x / y);
                  	elseif (t_0 <= 2e-11)
                  		tmp = 1.0 + (-1.0 * y);
                  	else
                  		tmp = x - (-1.0 / y);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.4], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-11], N[(1.0 + N[(-1.0 * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]]]]
                  
                  \begin{array}{l}
                  t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
                  \mathbf{if}\;t\_0 \leq -0.4:\\
                  \;\;\;\;x - \frac{x}{y}\\
                  
                  \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-11}:\\
                  \;\;\;\;1 + -1 \cdot y\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;x - \frac{-1}{y}\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -0.40000000000000002

                    1. Initial program 65.2%

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

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

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

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

                        \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                      4. lower--.f6451.2%

                        \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                    4. Applied rewrites51.2%

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

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

                        \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
                      3. mul-1-negN/A

                        \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
                      4. sub-flip-reverseN/A

                        \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                      5. lower--.f6451.2%

                        \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                    6. Applied rewrites51.2%

                      \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
                    7. Taylor expanded in x around inf

                      \[\leadsto x - \frac{x}{\color{blue}{y}} \]
                    8. Step-by-step derivation
                      1. lower-/.f6438.9%

                        \[\leadsto x - \frac{x}{y} \]
                    9. Applied rewrites38.9%

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

                    if -0.40000000000000002 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.9999999999999999e-11

                    1. Initial program 65.2%

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

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

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

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

                          \[\leadsto 1 - \color{blue}{\frac{y}{y + 1}} \]
                        3. sub-to-fractionN/A

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

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

                          \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
                        6. lower--.f6440.0%

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

                          \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
                        8. add-flipN/A

                          \[\leadsto \frac{\color{blue}{\left(y - \left(\mathsf{neg}\left(1\right)\right)\right)} - y}{y + 1} \]
                        9. metadata-evalN/A

                          \[\leadsto \frac{\left(y - \color{blue}{-1}\right) - y}{y + 1} \]
                        10. lift--.f6440.0%

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

                          \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y + 1}} \]
                        12. add-flipN/A

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

                          \[\leadsto \frac{\left(y - -1\right) - y}{y - \color{blue}{-1}} \]
                        14. lift--.f6440.0%

                          \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y - -1}} \]
                      3. Applied rewrites40.0%

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

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

                          \[\leadsto \frac{1}{\color{blue}{1 + y}} \]
                        2. lower-+.f6450.9%

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

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

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

                          \[\leadsto 1 + -1 \cdot \color{blue}{y} \]
                        2. lower-*.f6438.1%

                          \[\leadsto 1 + -1 \cdot y \]
                      9. Applied rewrites38.1%

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

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

                      1. Initial program 65.2%

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

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

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

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

                          \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                        4. lower--.f6451.2%

                          \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                      4. Applied rewrites51.2%

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

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

                          \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
                        3. mul-1-negN/A

                          \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
                        4. sub-flip-reverseN/A

                          \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                        5. lower--.f6451.2%

                          \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                      6. Applied rewrites51.2%

                        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
                      7. Taylor expanded in x around 0

                        \[\leadsto x - \frac{-1}{y} \]
                      8. Step-by-step derivation
                        1. Applied rewrites51.3%

                          \[\leadsto x - \frac{-1}{y} \]
                      9. Recombined 3 regimes into one program.
                      10. Add Preprocessing

                      Alternative 9: 74.0% accurate, 0.3× speedup?

                      \[\begin{array}{l} t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\ t_1 := x - \frac{x}{y}\\ \mathbf{if}\;t\_0 \leq -0.4:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.9995:\\ \;\;\;\;1 + -1 \cdot y\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
                      (FPCore (x y)
                       :precision binary64
                       (let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0))) (t_1 (- x (/ x y))))
                         (if (<= t_0 -0.4)
                           t_1
                           (if (<= t_0 0.9995) (+ 1.0 (* -1.0 y)) (if (<= t_0 1.0) (/ 1.0 y) t_1)))))
                      double code(double x, double y) {
                      	double t_0 = ((1.0 - x) * y) / (y + 1.0);
                      	double t_1 = x - (x / y);
                      	double tmp;
                      	if (t_0 <= -0.4) {
                      		tmp = t_1;
                      	} else if (t_0 <= 0.9995) {
                      		tmp = 1.0 + (-1.0 * y);
                      	} else if (t_0 <= 1.0) {
                      		tmp = 1.0 / y;
                      	} 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 = ((1.0d0 - x) * y) / (y + 1.0d0)
                          t_1 = x - (x / y)
                          if (t_0 <= (-0.4d0)) then
                              tmp = t_1
                          else if (t_0 <= 0.9995d0) then
                              tmp = 1.0d0 + ((-1.0d0) * y)
                          else if (t_0 <= 1.0d0) then
                              tmp = 1.0d0 / y
                          else
                              tmp = t_1
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double x, double y) {
                      	double t_0 = ((1.0 - x) * y) / (y + 1.0);
                      	double t_1 = x - (x / y);
                      	double tmp;
                      	if (t_0 <= -0.4) {
                      		tmp = t_1;
                      	} else if (t_0 <= 0.9995) {
                      		tmp = 1.0 + (-1.0 * y);
                      	} else if (t_0 <= 1.0) {
                      		tmp = 1.0 / y;
                      	} else {
                      		tmp = t_1;
                      	}
                      	return tmp;
                      }
                      
                      def code(x, y):
                      	t_0 = ((1.0 - x) * y) / (y + 1.0)
                      	t_1 = x - (x / y)
                      	tmp = 0
                      	if t_0 <= -0.4:
                      		tmp = t_1
                      	elif t_0 <= 0.9995:
                      		tmp = 1.0 + (-1.0 * y)
                      	elif t_0 <= 1.0:
                      		tmp = 1.0 / y
                      	else:
                      		tmp = t_1
                      	return tmp
                      
                      function code(x, y)
                      	t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))
                      	t_1 = Float64(x - Float64(x / y))
                      	tmp = 0.0
                      	if (t_0 <= -0.4)
                      		tmp = t_1;
                      	elseif (t_0 <= 0.9995)
                      		tmp = Float64(1.0 + Float64(-1.0 * y));
                      	elseif (t_0 <= 1.0)
                      		tmp = Float64(1.0 / y);
                      	else
                      		tmp = t_1;
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(x, y)
                      	t_0 = ((1.0 - x) * y) / (y + 1.0);
                      	t_1 = x - (x / y);
                      	tmp = 0.0;
                      	if (t_0 <= -0.4)
                      		tmp = t_1;
                      	elseif (t_0 <= 0.9995)
                      		tmp = 1.0 + (-1.0 * y);
                      	elseif (t_0 <= 1.0)
                      		tmp = 1.0 / y;
                      	else
                      		tmp = t_1;
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.4], t$95$1, If[LessEqual[t$95$0, 0.9995], N[(1.0 + N[(-1.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(1.0 / y), $MachinePrecision], t$95$1]]]]]
                      
                      \begin{array}{l}
                      t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
                      t_1 := x - \frac{x}{y}\\
                      \mathbf{if}\;t\_0 \leq -0.4:\\
                      \;\;\;\;t\_1\\
                      
                      \mathbf{elif}\;t\_0 \leq 0.9995:\\
                      \;\;\;\;1 + -1 \cdot y\\
                      
                      \mathbf{elif}\;t\_0 \leq 1:\\
                      \;\;\;\;\frac{1}{y}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;t\_1\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 3 regimes
                      2. if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -0.40000000000000002 or 1 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))

                        1. Initial program 65.2%

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

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

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

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

                            \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                          4. lower--.f6451.2%

                            \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                        4. Applied rewrites51.2%

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

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

                            \[\leadsto x + -1 \cdot \color{blue}{\frac{x - 1}{y}} \]
                          3. mul-1-negN/A

                            \[\leadsto x + \left(\mathsf{neg}\left(\frac{x - 1}{y}\right)\right) \]
                          4. sub-flip-reverseN/A

                            \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                          5. lower--.f6451.2%

                            \[\leadsto x - \color{blue}{\frac{x - 1}{y}} \]
                        6. Applied rewrites51.2%

                          \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
                        7. Taylor expanded in x around inf

                          \[\leadsto x - \frac{x}{\color{blue}{y}} \]
                        8. Step-by-step derivation
                          1. lower-/.f6438.9%

                            \[\leadsto x - \frac{x}{y} \]
                        9. Applied rewrites38.9%

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

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

                        1. Initial program 65.2%

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

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

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

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

                              \[\leadsto 1 - \color{blue}{\frac{y}{y + 1}} \]
                            3. sub-to-fractionN/A

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

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

                              \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
                            6. lower--.f6440.0%

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

                              \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
                            8. add-flipN/A

                              \[\leadsto \frac{\color{blue}{\left(y - \left(\mathsf{neg}\left(1\right)\right)\right)} - y}{y + 1} \]
                            9. metadata-evalN/A

                              \[\leadsto \frac{\left(y - \color{blue}{-1}\right) - y}{y + 1} \]
                            10. lift--.f6440.0%

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

                              \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y + 1}} \]
                            12. add-flipN/A

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

                              \[\leadsto \frac{\left(y - -1\right) - y}{y - \color{blue}{-1}} \]
                            14. lift--.f6440.0%

                              \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y - -1}} \]
                          3. Applied rewrites40.0%

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

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

                              \[\leadsto \frac{1}{\color{blue}{1 + y}} \]
                            2. lower-+.f6450.9%

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

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

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

                              \[\leadsto 1 + -1 \cdot \color{blue}{y} \]
                            2. lower-*.f6438.1%

                              \[\leadsto 1 + -1 \cdot y \]
                          9. Applied rewrites38.1%

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

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

                          1. Initial program 65.2%

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

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

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

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

                              \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                            4. lower--.f6451.2%

                              \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                          4. Applied rewrites51.2%

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

                            \[\leadsto \frac{1}{\color{blue}{y}} \]
                          6. Step-by-step derivation
                            1. lower-/.f6414.9%

                              \[\leadsto \frac{1}{y} \]
                          7. Applied rewrites14.9%

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

                        Alternative 10: 73.8% accurate, 0.3× speedup?

                        \[\begin{array}{l} t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\ t_1 := 1 - \left(1 - x\right)\\ \mathbf{if}\;t\_0 \leq -0.4:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.9995:\\ \;\;\;\;1 + -1 \cdot y\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
                        (FPCore (x y)
                         :precision binary64
                         (let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0))) (t_1 (- 1.0 (- 1.0 x))))
                           (if (<= t_0 -0.4)
                             t_1
                             (if (<= t_0 0.9995) (+ 1.0 (* -1.0 y)) (if (<= t_0 1.0) (/ 1.0 y) t_1)))))
                        double code(double x, double y) {
                        	double t_0 = ((1.0 - x) * y) / (y + 1.0);
                        	double t_1 = 1.0 - (1.0 - x);
                        	double tmp;
                        	if (t_0 <= -0.4) {
                        		tmp = t_1;
                        	} else if (t_0 <= 0.9995) {
                        		tmp = 1.0 + (-1.0 * y);
                        	} else if (t_0 <= 1.0) {
                        		tmp = 1.0 / y;
                        	} 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 = ((1.0d0 - x) * y) / (y + 1.0d0)
                            t_1 = 1.0d0 - (1.0d0 - x)
                            if (t_0 <= (-0.4d0)) then
                                tmp = t_1
                            else if (t_0 <= 0.9995d0) then
                                tmp = 1.0d0 + ((-1.0d0) * y)
                            else if (t_0 <= 1.0d0) then
                                tmp = 1.0d0 / y
                            else
                                tmp = t_1
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y) {
                        	double t_0 = ((1.0 - x) * y) / (y + 1.0);
                        	double t_1 = 1.0 - (1.0 - x);
                        	double tmp;
                        	if (t_0 <= -0.4) {
                        		tmp = t_1;
                        	} else if (t_0 <= 0.9995) {
                        		tmp = 1.0 + (-1.0 * y);
                        	} else if (t_0 <= 1.0) {
                        		tmp = 1.0 / y;
                        	} else {
                        		tmp = t_1;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y):
                        	t_0 = ((1.0 - x) * y) / (y + 1.0)
                        	t_1 = 1.0 - (1.0 - x)
                        	tmp = 0
                        	if t_0 <= -0.4:
                        		tmp = t_1
                        	elif t_0 <= 0.9995:
                        		tmp = 1.0 + (-1.0 * y)
                        	elif t_0 <= 1.0:
                        		tmp = 1.0 / y
                        	else:
                        		tmp = t_1
                        	return tmp
                        
                        function code(x, y)
                        	t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))
                        	t_1 = Float64(1.0 - Float64(1.0 - x))
                        	tmp = 0.0
                        	if (t_0 <= -0.4)
                        		tmp = t_1;
                        	elseif (t_0 <= 0.9995)
                        		tmp = Float64(1.0 + Float64(-1.0 * y));
                        	elseif (t_0 <= 1.0)
                        		tmp = Float64(1.0 / y);
                        	else
                        		tmp = t_1;
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y)
                        	t_0 = ((1.0 - x) * y) / (y + 1.0);
                        	t_1 = 1.0 - (1.0 - x);
                        	tmp = 0.0;
                        	if (t_0 <= -0.4)
                        		tmp = t_1;
                        	elseif (t_0 <= 0.9995)
                        		tmp = 1.0 + (-1.0 * y);
                        	elseif (t_0 <= 1.0)
                        		tmp = 1.0 / y;
                        	else
                        		tmp = t_1;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.4], t$95$1, If[LessEqual[t$95$0, 0.9995], N[(1.0 + N[(-1.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(1.0 / y), $MachinePrecision], t$95$1]]]]]
                        
                        \begin{array}{l}
                        t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
                        t_1 := 1 - \left(1 - x\right)\\
                        \mathbf{if}\;t\_0 \leq -0.4:\\
                        \;\;\;\;t\_1\\
                        
                        \mathbf{elif}\;t\_0 \leq 0.9995:\\
                        \;\;\;\;1 + -1 \cdot y\\
                        
                        \mathbf{elif}\;t\_0 \leq 1:\\
                        \;\;\;\;\frac{1}{y}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;t\_1\\
                        
                        
                        \end{array}
                        
                        Derivation
                        1. Split input into 3 regimes
                        2. if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < -0.40000000000000002 or 1 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))

                          1. Initial program 65.2%

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

                            \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]
                          3. Step-by-step derivation
                            1. lower--.f6428.2%

                              \[\leadsto 1 - \left(1 - \color{blue}{x}\right) \]
                          4. Applied rewrites28.2%

                            \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]

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

                          1. Initial program 65.2%

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

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

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

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

                                \[\leadsto 1 - \color{blue}{\frac{y}{y + 1}} \]
                              3. sub-to-fractionN/A

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

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

                                \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
                              6. lower--.f6440.0%

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

                                \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - y}{y + 1} \]
                              8. add-flipN/A

                                \[\leadsto \frac{\color{blue}{\left(y - \left(\mathsf{neg}\left(1\right)\right)\right)} - y}{y + 1} \]
                              9. metadata-evalN/A

                                \[\leadsto \frac{\left(y - \color{blue}{-1}\right) - y}{y + 1} \]
                              10. lift--.f6440.0%

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

                                \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y + 1}} \]
                              12. add-flipN/A

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

                                \[\leadsto \frac{\left(y - -1\right) - y}{y - \color{blue}{-1}} \]
                              14. lift--.f6440.0%

                                \[\leadsto \frac{\left(y - -1\right) - y}{\color{blue}{y - -1}} \]
                            3. Applied rewrites40.0%

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

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

                                \[\leadsto \frac{1}{\color{blue}{1 + y}} \]
                              2. lower-+.f6450.9%

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

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

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

                                \[\leadsto 1 + -1 \cdot \color{blue}{y} \]
                              2. lower-*.f6438.1%

                                \[\leadsto 1 + -1 \cdot y \]
                            9. Applied rewrites38.1%

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

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

                            1. Initial program 65.2%

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

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

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

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

                                \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                              4. lower--.f6451.2%

                                \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                            4. Applied rewrites51.2%

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

                              \[\leadsto \frac{1}{\color{blue}{y}} \]
                            6. Step-by-step derivation
                              1. lower-/.f6414.9%

                                \[\leadsto \frac{1}{y} \]
                            7. Applied rewrites14.9%

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

                          Alternative 11: 61.3% accurate, 0.4× speedup?

                          \[\begin{array}{l} t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-16}:\\ \;\;\;\;1 - \left(1 - x\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;1 - \left(-x\right)\\ \end{array} \]
                          (FPCore (x y)
                           :precision binary64
                           (let* ((t_0 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0)))))
                             (if (<= t_0 -2e-16)
                               (- 1.0 (- 1.0 x))
                               (if (<= t_0 5e-9) (/ 1.0 y) (- 1.0 (- x))))))
                          double code(double x, double y) {
                          	double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
                          	double tmp;
                          	if (t_0 <= -2e-16) {
                          		tmp = 1.0 - (1.0 - x);
                          	} else if (t_0 <= 5e-9) {
                          		tmp = 1.0 / y;
                          	} else {
                          		tmp = 1.0 - -x;
                          	}
                          	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 = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
                              if (t_0 <= (-2d-16)) then
                                  tmp = 1.0d0 - (1.0d0 - x)
                              else if (t_0 <= 5d-9) then
                                  tmp = 1.0d0 / y
                              else
                                  tmp = 1.0d0 - -x
                              end if
                              code = tmp
                          end function
                          
                          public static double code(double x, double y) {
                          	double t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
                          	double tmp;
                          	if (t_0 <= -2e-16) {
                          		tmp = 1.0 - (1.0 - x);
                          	} else if (t_0 <= 5e-9) {
                          		tmp = 1.0 / y;
                          	} else {
                          		tmp = 1.0 - -x;
                          	}
                          	return tmp;
                          }
                          
                          def code(x, y):
                          	t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0))
                          	tmp = 0
                          	if t_0 <= -2e-16:
                          		tmp = 1.0 - (1.0 - x)
                          	elif t_0 <= 5e-9:
                          		tmp = 1.0 / y
                          	else:
                          		tmp = 1.0 - -x
                          	return tmp
                          
                          function code(x, y)
                          	t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
                          	tmp = 0.0
                          	if (t_0 <= -2e-16)
                          		tmp = Float64(1.0 - Float64(1.0 - x));
                          	elseif (t_0 <= 5e-9)
                          		tmp = Float64(1.0 / y);
                          	else
                          		tmp = Float64(1.0 - Float64(-x));
                          	end
                          	return tmp
                          end
                          
                          function tmp_2 = code(x, y)
                          	t_0 = 1.0 - (((1.0 - x) * y) / (y + 1.0));
                          	tmp = 0.0;
                          	if (t_0 <= -2e-16)
                          		tmp = 1.0 - (1.0 - x);
                          	elseif (t_0 <= 5e-9)
                          		tmp = 1.0 / y;
                          	else
                          		tmp = 1.0 - -x;
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-16], N[(1.0 - N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-9], N[(1.0 / y), $MachinePrecision], N[(1.0 - (-x)), $MachinePrecision]]]]
                          
                          \begin{array}{l}
                          t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
                          \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-16}:\\
                          \;\;\;\;1 - \left(1 - x\right)\\
                          
                          \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-9}:\\
                          \;\;\;\;\frac{1}{y}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;1 - \left(-x\right)\\
                          
                          
                          \end{array}
                          
                          Derivation
                          1. Split input into 3 regimes
                          2. if (-.f64 #s(literal 1 binary64) (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))) < -2e-16

                            1. Initial program 65.2%

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

                              \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]
                            3. Step-by-step derivation
                              1. lower--.f6428.2%

                                \[\leadsto 1 - \left(1 - \color{blue}{x}\right) \]
                            4. Applied rewrites28.2%

                              \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]

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

                            1. Initial program 65.2%

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

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

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

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

                                \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                              4. lower--.f6451.2%

                                \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                            4. Applied rewrites51.2%

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

                              \[\leadsto \frac{1}{\color{blue}{y}} \]
                            6. Step-by-step derivation
                              1. lower-/.f6414.9%

                                \[\leadsto \frac{1}{y} \]
                            7. Applied rewrites14.9%

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

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

                            1. Initial program 65.2%

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

                              \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]
                            3. Step-by-step derivation
                              1. lower--.f6428.2%

                                \[\leadsto 1 - \left(1 - \color{blue}{x}\right) \]
                            4. Applied rewrites28.2%

                              \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]
                            5. Taylor expanded in x around inf

                              \[\leadsto 1 - -1 \cdot \color{blue}{x} \]
                            6. Step-by-step derivation
                              1. lower-*.f6449.5%

                                \[\leadsto 1 - -1 \cdot x \]
                            7. Applied rewrites49.5%

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

                                \[\leadsto 1 - -1 \cdot x \]
                              2. mul-1-negN/A

                                \[\leadsto 1 - \left(\mathsf{neg}\left(x\right)\right) \]
                              3. lower-neg.f6449.5%

                                \[\leadsto 1 - \left(-x\right) \]
                            9. Applied rewrites49.5%

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

                          Alternative 12: 61.1% accurate, 0.4× speedup?

                          \[\begin{array}{l} t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\ t_1 := 1 - \left(-x\right)\\ \mathbf{if}\;t\_0 \leq 0.9995:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
                          (FPCore (x y)
                           :precision binary64
                           (let* ((t_0 (/ (* (- 1.0 x) y) (+ y 1.0))) (t_1 (- 1.0 (- x))))
                             (if (<= t_0 0.9995) t_1 (if (<= t_0 2.0) (/ 1.0 y) t_1))))
                          double code(double x, double y) {
                          	double t_0 = ((1.0 - x) * y) / (y + 1.0);
                          	double t_1 = 1.0 - -x;
                          	double tmp;
                          	if (t_0 <= 0.9995) {
                          		tmp = t_1;
                          	} else if (t_0 <= 2.0) {
                          		tmp = 1.0 / y;
                          	} 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 = ((1.0d0 - x) * y) / (y + 1.0d0)
                              t_1 = 1.0d0 - -x
                              if (t_0 <= 0.9995d0) then
                                  tmp = t_1
                              else if (t_0 <= 2.0d0) then
                                  tmp = 1.0d0 / y
                              else
                                  tmp = t_1
                              end if
                              code = tmp
                          end function
                          
                          public static double code(double x, double y) {
                          	double t_0 = ((1.0 - x) * y) / (y + 1.0);
                          	double t_1 = 1.0 - -x;
                          	double tmp;
                          	if (t_0 <= 0.9995) {
                          		tmp = t_1;
                          	} else if (t_0 <= 2.0) {
                          		tmp = 1.0 / y;
                          	} else {
                          		tmp = t_1;
                          	}
                          	return tmp;
                          }
                          
                          def code(x, y):
                          	t_0 = ((1.0 - x) * y) / (y + 1.0)
                          	t_1 = 1.0 - -x
                          	tmp = 0
                          	if t_0 <= 0.9995:
                          		tmp = t_1
                          	elif t_0 <= 2.0:
                          		tmp = 1.0 / y
                          	else:
                          		tmp = t_1
                          	return tmp
                          
                          function code(x, y)
                          	t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))
                          	t_1 = Float64(1.0 - Float64(-x))
                          	tmp = 0.0
                          	if (t_0 <= 0.9995)
                          		tmp = t_1;
                          	elseif (t_0 <= 2.0)
                          		tmp = Float64(1.0 / y);
                          	else
                          		tmp = t_1;
                          	end
                          	return tmp
                          end
                          
                          function tmp_2 = code(x, y)
                          	t_0 = ((1.0 - x) * y) / (y + 1.0);
                          	t_1 = 1.0 - -x;
                          	tmp = 0.0;
                          	if (t_0 <= 0.9995)
                          		tmp = t_1;
                          	elseif (t_0 <= 2.0)
                          		tmp = 1.0 / y;
                          	else
                          		tmp = t_1;
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - (-x)), $MachinePrecision]}, If[LessEqual[t$95$0, 0.9995], t$95$1, If[LessEqual[t$95$0, 2.0], N[(1.0 / y), $MachinePrecision], t$95$1]]]]
                          
                          \begin{array}{l}
                          t_0 := \frac{\left(1 - x\right) \cdot y}{y + 1}\\
                          t_1 := 1 - \left(-x\right)\\
                          \mathbf{if}\;t\_0 \leq 0.9995:\\
                          \;\;\;\;t\_1\\
                          
                          \mathbf{elif}\;t\_0 \leq 2:\\
                          \;\;\;\;\frac{1}{y}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;t\_1\\
                          
                          
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.99950000000000006 or 2 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64)))

                            1. Initial program 65.2%

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

                              \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]
                            3. Step-by-step derivation
                              1. lower--.f6428.2%

                                \[\leadsto 1 - \left(1 - \color{blue}{x}\right) \]
                            4. Applied rewrites28.2%

                              \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]
                            5. Taylor expanded in x around inf

                              \[\leadsto 1 - -1 \cdot \color{blue}{x} \]
                            6. Step-by-step derivation
                              1. lower-*.f6449.5%

                                \[\leadsto 1 - -1 \cdot x \]
                            7. Applied rewrites49.5%

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

                                \[\leadsto 1 - -1 \cdot x \]
                              2. mul-1-negN/A

                                \[\leadsto 1 - \left(\mathsf{neg}\left(x\right)\right) \]
                              3. lower-neg.f6449.5%

                                \[\leadsto 1 - \left(-x\right) \]
                            9. Applied rewrites49.5%

                              \[\leadsto 1 - \color{blue}{\left(-x\right)} \]

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

                            1. Initial program 65.2%

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

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

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

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

                                \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                              4. lower--.f6451.2%

                                \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                            4. Applied rewrites51.2%

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

                              \[\leadsto \frac{1}{\color{blue}{y}} \]
                            6. Step-by-step derivation
                              1. lower-/.f6414.9%

                                \[\leadsto \frac{1}{y} \]
                            7. Applied rewrites14.9%

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

                          Alternative 13: 14.9% accurate, 3.5× speedup?

                          \[\frac{1}{y} \]
                          (FPCore (x y) :precision binary64 (/ 1.0 y))
                          double code(double x, double y) {
                          	return 1.0 / y;
                          }
                          
                          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 = 1.0d0 / y
                          end function
                          
                          public static double code(double x, double y) {
                          	return 1.0 / y;
                          }
                          
                          def code(x, y):
                          	return 1.0 / y
                          
                          function code(x, y)
                          	return Float64(1.0 / y)
                          end
                          
                          function tmp = code(x, y)
                          	tmp = 1.0 / y;
                          end
                          
                          code[x_, y_] := N[(1.0 / y), $MachinePrecision]
                          
                          \frac{1}{y}
                          
                          Derivation
                          1. Initial program 65.2%

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

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

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

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

                              \[\leadsto x + -1 \cdot \frac{x - 1}{\color{blue}{y}} \]
                            4. lower--.f6451.2%

                              \[\leadsto x + -1 \cdot \frac{x - 1}{y} \]
                          4. Applied rewrites51.2%

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

                            \[\leadsto \frac{1}{\color{blue}{y}} \]
                          6. Step-by-step derivation
                            1. lower-/.f6414.9%

                              \[\leadsto \frac{1}{y} \]
                          7. Applied rewrites14.9%

                            \[\leadsto \frac{1}{\color{blue}{y}} \]
                          8. Add Preprocessing

                          Alternative 14: 3.1% accurate, 4.2× speedup?

                          \[1 - 1 \]
                          (FPCore (x y) :precision binary64 (- 1.0 1.0))
                          double code(double x, double y) {
                          	return 1.0 - 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 = 1.0d0 - 1.0d0
                          end function
                          
                          public static double code(double x, double y) {
                          	return 1.0 - 1.0;
                          }
                          
                          def code(x, y):
                          	return 1.0 - 1.0
                          
                          function code(x, y)
                          	return Float64(1.0 - 1.0)
                          end
                          
                          function tmp = code(x, y)
                          	tmp = 1.0 - 1.0;
                          end
                          
                          code[x_, y_] := N[(1.0 - 1.0), $MachinePrecision]
                          
                          1 - 1
                          
                          Derivation
                          1. Initial program 65.2%

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

                            \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]
                          3. Step-by-step derivation
                            1. lower--.f6428.2%

                              \[\leadsto 1 - \left(1 - \color{blue}{x}\right) \]
                          4. Applied rewrites28.2%

                            \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \]
                          5. Taylor expanded in x around 0

                            \[\leadsto 1 - 1 \]
                          6. Step-by-step derivation
                            1. Applied rewrites3.1%

                              \[\leadsto 1 - 1 \]
                            2. Add Preprocessing

                            Reproduce

                            ?
                            herbie shell --seed 2025188 
                            (FPCore (x y)
                              :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, D"
                              :precision binary64
                              (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))