Data.Colour.RGB:hslsv from colour-2.3.3, C

Percentage Accurate: 100.0% → 100.0%
Time: 2.3s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

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

Alternative 1: 98.4% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq -1 \cdot 10^{-5}:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (if (<= (/ (- x y) (- 2.0 (+ x y))) -1e-5)
  (/ (- x y) (- 2.0 x))
  (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
	double tmp;
	if (((x - y) / (2.0 - (x + y))) <= -1e-5) {
		tmp = (x - y) / (2.0 - x);
	} else {
		tmp = (x - y) / (2.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) :: tmp
    if (((x - y) / (2.0d0 - (x + y))) <= (-1d-5)) then
        tmp = (x - y) / (2.0d0 - x)
    else
        tmp = (x - y) / (2.0d0 - y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (((x - y) / (2.0 - (x + y))) <= -1e-5) {
		tmp = (x - y) / (2.0 - x);
	} else {
		tmp = (x - y) / (2.0 - y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if ((x - y) / (2.0 - (x + y))) <= -1e-5:
		tmp = (x - y) / (2.0 - x)
	else:
		tmp = (x - y) / (2.0 - y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) <= -1e-5)
		tmp = Float64(Float64(x - y) / Float64(2.0 - x));
	else
		tmp = Float64(Float64(x - y) / Float64(2.0 - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((x - y) / (2.0 - (x + y))) <= -1e-5)
		tmp = (x - y) / (2.0 - x);
	else
		tmp = (x - y) / (2.0 - y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-5], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq -1 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - y}{2 - x}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < -1.0000000000000001e-5

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{x - y}{\color{blue}{2 - x}} \]
      3. Step-by-step derivation
        1. lower--.f6462.5%

          \[\leadsto \frac{x - y}{2 - \color{blue}{x}} \]
      4. Applied rewrites62.5%

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

      if -1.0000000000000001e-5 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

      1. Initial program 100.0%

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

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

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

      Alternative 2: 97.2% accurate, 0.5× speedup?

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

        1. Initial program 100.0%

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

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

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

            \[\leadsto \frac{x - y}{\color{blue}{2 - x}} \]
          3. Step-by-step derivation
            1. lower--.f6462.5%

              \[\leadsto \frac{x - y}{2 - \color{blue}{x}} \]
          4. Applied rewrites62.5%

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

          if 1.9999999999999999e-39 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

          1. Initial program 100.0%

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

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

              \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\mathsf{neg}\left(\left(2 - \left(x + y\right)\right)\right)}} \]
            3. div-flipN/A

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{1}{\frac{\left(y + x\right) - 2}{\color{blue}{y - x}}} \]
            14. lower--.f6499.9%

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

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

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

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

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

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

        Alternative 3: 97.0% accurate, 0.3× speedup?

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

          1. Initial program 100.0%

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

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

              \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
            2. lower--.f6450.6%

              \[\leadsto \frac{x}{2 - \color{blue}{x}} \]
          4. Applied rewrites50.6%

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

          if -1.0000000000000001e-5 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < 1.9999999999999999e-39

          1. Initial program 100.0%

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

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

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

              \[\leadsto \frac{x - y}{\color{blue}{2 - x}} \]
            3. Step-by-step derivation
              1. lower--.f6462.5%

                \[\leadsto \frac{x - y}{2 - \color{blue}{x}} \]
            4. Applied rewrites62.5%

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

              \[\leadsto \frac{x - y}{2} \]
            6. Step-by-step derivation
              1. Applied rewrites25.7%

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

              if 1.9999999999999999e-39 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

              1. Initial program 100.0%

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

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

                  \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\mathsf{neg}\left(\left(2 - \left(x + y\right)\right)\right)}} \]
                3. div-flipN/A

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{\frac{\left(y + x\right) - 2}{\color{blue}{y - x}}} \]
                14. lower--.f6499.9%

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

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

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

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

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

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

            Alternative 4: 86.8% accurate, 0.2× speedup?

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

              1. Initial program 100.0%

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

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

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

                if -1.0000000000000001e-5 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < -1.0000000000000001e-33

                1. Initial program 100.0%

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

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

                    \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\mathsf{neg}\left(\left(2 - \left(x + y\right)\right)\right)}} \]
                  3. div-flipN/A

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{\frac{\left(y + x\right) - 2}{\color{blue}{y - x}}} \]
                  14. lower--.f6499.9%

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

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

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

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

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

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

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

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

                    \[\leadsto y \cdot \left(\frac{-1}{4} \cdot y - \frac{1}{2}\right) \]
                  3. lower-*.f6414.3%

                    \[\leadsto y \cdot \left(-0.25 \cdot y - 0.5\right) \]
                9. Applied rewrites14.3%

                  \[\leadsto y \cdot \color{blue}{\left(-0.25 \cdot y - 0.5\right)} \]

                if -1.0000000000000001e-33 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < 2.0000000000000001e-172

                1. Initial program 100.0%

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

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

                    \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
                  2. lower--.f6450.6%

                    \[\leadsto \frac{x}{2 - \color{blue}{x}} \]
                4. Applied rewrites50.6%

                  \[\leadsto \color{blue}{\frac{x}{2 - x}} \]
                5. Taylor expanded in x around 0

                  \[\leadsto \frac{1}{2} \cdot \color{blue}{x} \]
                6. Step-by-step derivation
                  1. lower-*.f6414.3%

                    \[\leadsto 0.5 \cdot x \]
                7. Applied rewrites14.3%

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

                if 2.0000000000000001e-172 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

                1. Initial program 100.0%

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

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

                    \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\mathsf{neg}\left(\left(2 - \left(x + y\right)\right)\right)}} \]
                  3. div-flipN/A

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{\frac{\left(y + x\right) - 2}{\color{blue}{y - x}}} \]
                  14. lower--.f6499.9%

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

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

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

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

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

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

              Alternative 5: 86.3% accurate, 0.5× speedup?

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

                1. Initial program 100.0%

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

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

                    \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
                  2. lower--.f6450.6%

                    \[\leadsto \frac{x}{2 - \color{blue}{x}} \]
                4. Applied rewrites50.6%

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

                if 2.0000000000000001e-172 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

                1. Initial program 100.0%

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

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

                    \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\mathsf{neg}\left(\left(2 - \left(x + y\right)\right)\right)}} \]
                  3. div-flipN/A

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{\frac{\left(y + x\right) - 2}{\color{blue}{y - x}}} \]
                  14. lower--.f6499.9%

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

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

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

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

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

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

              Alternative 6: 85.6% accurate, 0.2× speedup?

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

                1. Initial program 100.0%

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

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

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

                  if -1.0000000000000001e-5 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < -1.0000000000000001e-33 or 2.0000000000000001e-172 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < 9.9999999999999995e-8

                  1. Initial program 100.0%

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

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

                      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\mathsf{neg}\left(\left(2 - \left(x + y\right)\right)\right)}} \]
                    3. div-flipN/A

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{1}{\frac{\left(y + x\right) - 2}{\color{blue}{y - x}}} \]
                    14. lower--.f6499.9%

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

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

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

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

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

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

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

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

                      \[\leadsto y \cdot \left(\frac{-1}{4} \cdot y - \frac{1}{2}\right) \]
                    3. lower-*.f6414.3%

                      \[\leadsto y \cdot \left(-0.25 \cdot y - 0.5\right) \]
                  9. Applied rewrites14.3%

                    \[\leadsto y \cdot \color{blue}{\left(-0.25 \cdot y - 0.5\right)} \]

                  if -1.0000000000000001e-33 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < 2.0000000000000001e-172

                  1. Initial program 100.0%

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

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

                      \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
                    2. lower--.f6450.6%

                      \[\leadsto \frac{x}{2 - \color{blue}{x}} \]
                  4. Applied rewrites50.6%

                    \[\leadsto \color{blue}{\frac{x}{2 - x}} \]
                  5. Taylor expanded in x around 0

                    \[\leadsto \frac{1}{2} \cdot \color{blue}{x} \]
                  6. Step-by-step derivation
                    1. lower-*.f6414.3%

                      \[\leadsto 0.5 \cdot x \]
                  7. Applied rewrites14.3%

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

                  if 9.9999999999999995e-8 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{1} \]
                  3. Step-by-step derivation
                    1. Applied rewrites38.2%

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

                  Alternative 7: 85.4% accurate, 0.2× speedup?

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

                    1. Initial program 100.0%

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

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

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

                      if -1.0000000000000001e-5 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < -1.0000000000000001e-33 or 2.0000000000000001e-172 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < 9.9999999999999995e-8

                      1. Initial program 100.0%

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

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

                          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\mathsf{neg}\left(\left(2 - \left(x + y\right)\right)\right)}} \]
                        3. div-flipN/A

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \frac{1}{\frac{\left(y + x\right) - 2}{\color{blue}{y - x}}} \]
                        14. lower--.f6499.9%

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

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

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

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

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

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

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

                          \[\leadsto -0.5 \cdot y \]
                      9. Applied rewrites14.7%

                        \[\leadsto -0.5 \cdot \color{blue}{y} \]

                      if -1.0000000000000001e-33 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < 2.0000000000000001e-172

                      1. Initial program 100.0%

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

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

                          \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
                        2. lower--.f6450.6%

                          \[\leadsto \frac{x}{2 - \color{blue}{x}} \]
                      4. Applied rewrites50.6%

                        \[\leadsto \color{blue}{\frac{x}{2 - x}} \]
                      5. Taylor expanded in x around 0

                        \[\leadsto \frac{1}{2} \cdot \color{blue}{x} \]
                      6. Step-by-step derivation
                        1. lower-*.f6414.3%

                          \[\leadsto 0.5 \cdot x \]
                      7. Applied rewrites14.3%

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

                      if 9.9999999999999995e-8 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

                      1. Initial program 100.0%

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

                        \[\leadsto \color{blue}{1} \]
                      3. Step-by-step derivation
                        1. Applied rewrites38.2%

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

                      Alternative 8: 85.4% accurate, 0.4× speedup?

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

                        1. Initial program 100.0%

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

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

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

                          if -1.0000000000000001e-5 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < 9.9999999999999995e-8

                          1. Initial program 100.0%

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

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

                              \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\mathsf{neg}\left(\left(2 - \left(x + y\right)\right)\right)}} \]
                            3. div-flipN/A

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{1}{\frac{\left(y + x\right) - 2}{\color{blue}{y - x}}} \]
                            14. lower--.f6499.9%

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

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

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

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

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

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

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

                              \[\leadsto -0.5 \cdot y \]
                          9. Applied rewrites14.7%

                            \[\leadsto -0.5 \cdot \color{blue}{y} \]

                          if 9.9999999999999995e-8 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

                          1. Initial program 100.0%

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

                            \[\leadsto \color{blue}{1} \]
                          3. Step-by-step derivation
                            1. Applied rewrites38.2%

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

                          Alternative 9: 74.9% accurate, 0.8× speedup?

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

                            1. Initial program 100.0%

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

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

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

                              if 2.7000000000000001e-295 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y)))

                              1. Initial program 100.0%

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

                                \[\leadsto \color{blue}{1} \]
                              3. Step-by-step derivation
                                1. Applied rewrites38.2%

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

                              Alternative 10: 38.4% accurate, 21.0× speedup?

                              \[-1 \]
                              (FPCore (x y)
                                :precision binary64
                                -1.0)
                              double code(double x, double y) {
                              	return -1.0;
                              }
                              
                              module fmin_fmax_functions
                                  implicit none
                                  private
                                  public fmax
                                  public fmin
                              
                                  interface fmax
                                      module procedure fmax88
                                      module procedure fmax44
                                      module procedure fmax84
                                      module procedure fmax48
                                  end interface
                                  interface fmin
                                      module procedure fmin88
                                      module procedure fmin44
                                      module procedure fmin84
                                      module procedure fmin48
                                  end interface
                              contains
                                  real(8) function fmax88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmax44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmax84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmax48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmin44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmin48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                  end function
                              end module
                              
                              real(8) function code(x, y)
                              use fmin_fmax_functions
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  code = -1.0d0
                              end function
                              
                              public static double code(double x, double y) {
                              	return -1.0;
                              }
                              
                              def code(x, y):
                              	return -1.0
                              
                              function code(x, y)
                              	return -1.0
                              end
                              
                              function tmp = code(x, y)
                              	tmp = -1.0;
                              end
                              
                              code[x_, y_] := -1.0
                              
                              -1
                              
                              Derivation
                              1. Initial program 100.0%

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

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

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

                                Reproduce

                                ?
                                herbie shell --seed 2025258 
                                (FPCore (x y)
                                  :name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
                                  :precision binary64
                                  (/ (- x y) (- 2.0 (+ x y))))