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

Percentage Accurate: 100.0% → 100.0%
Time: 1.9s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\frac{x - y}{2 - \left(x + y\right)} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
	return (x - y) / (2.0 - (x + y));
}
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]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	(x - y) / ((2) - (x + y))
END code
\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 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

\[\frac{x - y}{2 - \left(x + y\right)} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
	return (x - y) / (2.0 - (x + y));
}
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]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	(x - y) / ((2) - (x + y))
END code
\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 0.005:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (if (<= (/ (- x y) (- 2.0 (+ x y))) 0.005)
  (/ (- 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))) <= 0.005) {
		tmp = (x - y) / (2.0 - x);
	} else {
		tmp = (x - y) / (2.0 - y);
	}
	return tmp;
}
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))) <= 0.005d0) 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))) <= 0.005) {
		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))) <= 0.005:
		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))) <= 0.005)
		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))) <= 0.005)
		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], 0.005], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	LET tmp = IF (((x - y) / ((2) - (x + y))) <= (5000000000000000104083408558608425664715468883514404296875e-60)) THEN ((x - y) / ((2) - x)) ELSE ((x - y) / ((2) - y)) ENDIF IN
	tmp
END code
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq 0.005:\\
\;\;\;\;\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))) < 0.0050000000000000001

    1. Initial program 100.0%

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

      \[\leadsto \frac{x - y}{2 - x} \]
    3. Step-by-step derivation
      1. Applied rewrites63.5%

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

      if 0.0050000000000000001 < (/.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 - y} \]
      3. Step-by-step derivation
        1. Applied rewrites62.2%

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

      Alternative 2: 97.8% accurate, 0.5× speedup?

      \[\begin{array}{l} \mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq 0.005:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
      (FPCore (x y)
        :precision binary64
        :pre TRUE
        (if (<= (/ (- x y) (- 2.0 (+ x y))) 0.005) (/ (- x y) (- 2.0 x)) 1.0))
      double code(double x, double y) {
      	double tmp;
      	if (((x - y) / (2.0 - (x + y))) <= 0.005) {
      		tmp = (x - y) / (2.0 - x);
      	} else {
      		tmp = 1.0;
      	}
      	return tmp;
      }
      
      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))) <= 0.005d0) then
              tmp = (x - y) / (2.0d0 - x)
          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))) <= 0.005) {
      		tmp = (x - y) / (2.0 - x);
      	} else {
      		tmp = 1.0;
      	}
      	return tmp;
      }
      
      def code(x, y):
      	tmp = 0
      	if ((x - y) / (2.0 - (x + y))) <= 0.005:
      		tmp = (x - y) / (2.0 - x)
      	else:
      		tmp = 1.0
      	return tmp
      
      function code(x, y)
      	tmp = 0.0
      	if (Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) <= 0.005)
      		tmp = Float64(Float64(x - y) / Float64(2.0 - x));
      	else
      		tmp = 1.0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	tmp = 0.0;
      	if (((x - y) / (2.0 - (x + y))) <= 0.005)
      		tmp = (x - y) / (2.0 - x);
      	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], 0.005], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]
      
      f(x, y):
      	x in [-inf, +inf],
      	y in [-inf, +inf]
      code: THEORY
      BEGIN
      f(x, y: real): real =
      	LET tmp = IF (((x - y) / ((2) - (x + y))) <= (5000000000000000104083408558608425664715468883514404296875e-60)) THEN ((x - y) / ((2) - x)) ELSE (1) ENDIF IN
      	tmp
      END code
      \begin{array}{l}
      \mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq 0.005:\\
      \;\;\;\;\frac{x - y}{2 - x}\\
      
      \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))) < 0.0050000000000000001

        1. Initial program 100.0%

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

          \[\leadsto \frac{x - y}{2 - x} \]
        3. Step-by-step derivation
          1. Applied rewrites63.5%

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

          if 0.0050000000000000001 < (/.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 1 \]
          3. Step-by-step derivation
            1. Applied rewrites37.3%

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

          Alternative 3: 97.4% accurate, 0.3× speedup?

          \[\begin{array}{l} t_0 := \frac{x - y}{2 - \left(x + y\right)}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;t\_0 \leq 0.005:\\ \;\;\;\;\frac{x - y}{2}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
          (FPCore (x y)
            :precision binary64
            :pre TRUE
            (let* ((t_0 (/ (- x y) (- 2.0 (+ x y)))))
            (if (<= t_0 -2e-7)
              (/ x (- 2.0 x))
              (if (<= t_0 0.005) (/ (- x y) 2.0) 1.0))))
          double code(double x, double y) {
          	double t_0 = (x - y) / (2.0 - (x + y));
          	double tmp;
          	if (t_0 <= -2e-7) {
          		tmp = x / (2.0 - x);
          	} else if (t_0 <= 0.005) {
          		tmp = (x - y) / 2.0;
          	} else {
          		tmp = 1.0;
          	}
          	return tmp;
          }
          
          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 <= (-2d-7)) then
                  tmp = x / (2.0d0 - x)
              else if (t_0 <= 0.005d0) then
                  tmp = (x - y) / 2.0d0
              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 <= -2e-7) {
          		tmp = x / (2.0 - x);
          	} else if (t_0 <= 0.005) {
          		tmp = (x - y) / 2.0;
          	} else {
          		tmp = 1.0;
          	}
          	return tmp;
          }
          
          def code(x, y):
          	t_0 = (x - y) / (2.0 - (x + y))
          	tmp = 0
          	if t_0 <= -2e-7:
          		tmp = x / (2.0 - x)
          	elif t_0 <= 0.005:
          		tmp = (x - y) / 2.0
          	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 <= -2e-7)
          		tmp = Float64(x / Float64(2.0 - x));
          	elseif (t_0 <= 0.005)
          		tmp = Float64(Float64(x - y) / 2.0);
          	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 <= -2e-7)
          		tmp = x / (2.0 - x);
          	elseif (t_0 <= 0.005)
          		tmp = (x - y) / 2.0;
          	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, -2e-7], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.005], N[(N[(x - y), $MachinePrecision] / 2.0), $MachinePrecision], 1.0]]]
          
          f(x, y):
          	x in [-inf, +inf],
          	y in [-inf, +inf]
          code: THEORY
          BEGIN
          f(x, y: real): real =
          	LET t_0 = ((x - y) / ((2) - (x + y))) IN
          		LET tmp_1 = IF (t_0 <= (5000000000000000104083408558608425664715468883514404296875e-60)) THEN ((x - y) / (2)) ELSE (1) ENDIF IN
          		LET tmp = IF (t_0 <= (-199999999999999990949622365177251737122787744738161563873291015625e-72)) THEN (x / ((2) - x)) ELSE tmp_1 ENDIF IN
          	tmp
          END code
          \begin{array}{l}
          t_0 := \frac{x - y}{2 - \left(x + y\right)}\\
          \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-7}:\\
          \;\;\;\;\frac{x}{2 - x}\\
          
          \mathbf{elif}\;t\_0 \leq 0.005:\\
          \;\;\;\;\frac{x - y}{2}\\
          
          \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.9999999999999999e-7

            1. Initial program 100.0%

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

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

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

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

              1. Initial program 100.0%

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

                \[\leadsto \frac{x - y}{2 - x} \]
              3. Step-by-step derivation
                1. Applied rewrites63.5%

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

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

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

                  if 0.0050000000000000001 < (/.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 1 \]
                  3. Step-by-step derivation
                    1. Applied rewrites37.3%

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

                  Alternative 4: 86.2% accurate, 0.6× speedup?

                  \[\begin{array}{l} \mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq 0.005:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
                  (FPCore (x y)
                    :precision binary64
                    :pre TRUE
                    (if (<= (/ (- x y) (- 2.0 (+ x y))) 0.005) (/ x (- 2.0 x)) 1.0))
                  double code(double x, double y) {
                  	double tmp;
                  	if (((x - y) / (2.0 - (x + y))) <= 0.005) {
                  		tmp = x / (2.0 - x);
                  	} else {
                  		tmp = 1.0;
                  	}
                  	return tmp;
                  }
                  
                  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))) <= 0.005d0) then
                          tmp = x / (2.0d0 - x)
                      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))) <= 0.005) {
                  		tmp = x / (2.0 - x);
                  	} else {
                  		tmp = 1.0;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y):
                  	tmp = 0
                  	if ((x - y) / (2.0 - (x + y))) <= 0.005:
                  		tmp = x / (2.0 - x)
                  	else:
                  		tmp = 1.0
                  	return tmp
                  
                  function code(x, y)
                  	tmp = 0.0
                  	if (Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) <= 0.005)
                  		tmp = Float64(x / Float64(2.0 - x));
                  	else
                  		tmp = 1.0;
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y)
                  	tmp = 0.0;
                  	if (((x - y) / (2.0 - (x + y))) <= 0.005)
                  		tmp = x / (2.0 - x);
                  	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], 0.005], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]
                  
                  f(x, y):
                  	x in [-inf, +inf],
                  	y in [-inf, +inf]
                  code: THEORY
                  BEGIN
                  f(x, y: real): real =
                  	LET tmp = IF (((x - y) / ((2) - (x + y))) <= (5000000000000000104083408558608425664715468883514404296875e-60)) THEN (x / ((2) - x)) ELSE (1) ENDIF IN
                  	tmp
                  END code
                  \begin{array}{l}
                  \mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq 0.005:\\
                  \;\;\;\;\frac{x}{2 - x}\\
                  
                  \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))) < 0.0050000000000000001

                    1. Initial program 100.0%

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

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

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

                      if 0.0050000000000000001 < (/.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 1 \]
                      3. Step-by-step derivation
                        1. Applied rewrites37.3%

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

                      Alternative 5: 85.2% accurate, 0.4× speedup?

                      \[\begin{array}{l} t_0 := \frac{x - y}{2 - \left(x + y\right)}\\ \mathbf{if}\;t\_0 \leq -0.5:\\ \;\;\;\;-1\\ \mathbf{elif}\;t\_0 \leq 0.005:\\ \;\;\;\;0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
                      (FPCore (x y)
                        :precision binary64
                        :pre TRUE
                        (let* ((t_0 (/ (- x y) (- 2.0 (+ x y)))))
                        (if (<= t_0 -0.5) -1.0 (if (<= t_0 0.005) (* 0.5 x) 1.0))))
                      double code(double x, double y) {
                      	double t_0 = (x - y) / (2.0 - (x + y));
                      	double tmp;
                      	if (t_0 <= -0.5) {
                      		tmp = -1.0;
                      	} else if (t_0 <= 0.005) {
                      		tmp = 0.5 * x;
                      	} else {
                      		tmp = 1.0;
                      	}
                      	return tmp;
                      }
                      
                      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 <= (-0.5d0)) then
                              tmp = -1.0d0
                          else if (t_0 <= 0.005d0) then
                              tmp = 0.5d0 * x
                          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 <= -0.5) {
                      		tmp = -1.0;
                      	} else if (t_0 <= 0.005) {
                      		tmp = 0.5 * x;
                      	} else {
                      		tmp = 1.0;
                      	}
                      	return tmp;
                      }
                      
                      def code(x, y):
                      	t_0 = (x - y) / (2.0 - (x + y))
                      	tmp = 0
                      	if t_0 <= -0.5:
                      		tmp = -1.0
                      	elif t_0 <= 0.005:
                      		tmp = 0.5 * x
                      	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 <= -0.5)
                      		tmp = -1.0;
                      	elseif (t_0 <= 0.005)
                      		tmp = Float64(0.5 * x);
                      	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 <= -0.5)
                      		tmp = -1.0;
                      	elseif (t_0 <= 0.005)
                      		tmp = 0.5 * x;
                      	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, -0.5], -1.0, If[LessEqual[t$95$0, 0.005], N[(0.5 * x), $MachinePrecision], 1.0]]]
                      
                      f(x, y):
                      	x in [-inf, +inf],
                      	y in [-inf, +inf]
                      code: THEORY
                      BEGIN
                      f(x, y: real): real =
                      	LET t_0 = ((x - y) / ((2) - (x + y))) IN
                      		LET tmp_1 = IF (t_0 <= (5000000000000000104083408558608425664715468883514404296875e-60)) THEN ((5e-1) * x) ELSE (1) ENDIF IN
                      		LET tmp = IF (t_0 <= (-5e-1)) THEN (-1) ELSE tmp_1 ENDIF IN
                      	tmp
                      END code
                      \begin{array}{l}
                      t_0 := \frac{x - y}{2 - \left(x + y\right)}\\
                      \mathbf{if}\;t\_0 \leq -0.5:\\
                      \;\;\;\;-1\\
                      
                      \mathbf{elif}\;t\_0 \leq 0.005:\\
                      \;\;\;\;0.5 \cdot x\\
                      
                      \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))) < -0.5

                        1. Initial program 100.0%

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

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

                            \[\leadsto -1 \]

                          if -0.5 < (/.f64 (-.f64 x y) (-.f64 #s(literal 2 binary64) (+.f64 x y))) < 0.0050000000000000001

                          1. Initial program 100.0%

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

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

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

                              \[\leadsto \frac{1}{2} \cdot x \]
                            3. Step-by-step derivation
                              1. Applied rewrites15.1%

                                \[\leadsto 0.5 \cdot x \]

                              if 0.0050000000000000001 < (/.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 1 \]
                              3. Step-by-step derivation
                                1. Applied rewrites37.3%

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

                              Alternative 6: 74.3% accurate, 0.8× speedup?

                              \[\begin{array}{l} \mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq 1.2423345892717348 \cdot 10^{-287}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
                              (FPCore (x y)
                                :precision binary64
                                :pre TRUE
                                (if (<= (/ (- x y) (- 2.0 (+ x y))) 1.2423345892717348e-287) -1.0 1.0))
                              double code(double x, double y) {
                              	double tmp;
                              	if (((x - y) / (2.0 - (x + y))) <= 1.2423345892717348e-287) {
                              		tmp = -1.0;
                              	} else {
                              		tmp = 1.0;
                              	}
                              	return tmp;
                              }
                              
                              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))) <= 1.2423345892717348d-287) 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))) <= 1.2423345892717348e-287) {
                              		tmp = -1.0;
                              	} else {
                              		tmp = 1.0;
                              	}
                              	return tmp;
                              }
                              
                              def code(x, y):
                              	tmp = 0
                              	if ((x - y) / (2.0 - (x + y))) <= 1.2423345892717348e-287:
                              		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))) <= 1.2423345892717348e-287)
                              		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))) <= 1.2423345892717348e-287)
                              		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], 1.2423345892717348e-287], -1.0, 1.0]
                              
                              f(x, y):
                              	x in [-inf, +inf],
                              	y in [-inf, +inf]
                              code: THEORY
                              BEGIN
                              f(x, y: real): real =
                              	LET tmp = IF (((x - y) / ((2) - (x + y))) <= (1242334589271734766694965026517907720287440807835919262790717453718264796586232870372742219313993639126732271887653312891673217485764275913935208689788400991999425081684233369133967092053600591711271565009616305561755793329555419578904695226767333125048876406319501324407047827118955270741031890851361457221001975359953622888113881968686396988159422708259137900394205831693205730602502096063680098810999724250314232074827573860718884208569997659215263730395847721814035768566635675449346359019778049325138083304927054078954017120551506776185727842591748845651099572271896389078801269178897586440719058896315829702125368319145544851777972247625557177649505143600781948884891059403656754511757753789424896240234375e-998)) THEN (-1) ELSE (1) ENDIF IN
                              	tmp
                              END code
                              \begin{array}{l}
                              \mathbf{if}\;\frac{x - y}{2 - \left(x + y\right)} \leq 1.2423345892717348 \cdot 10^{-287}:\\
                              \;\;\;\;-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))) < 1.2423345892717348e-287

                                1. Initial program 100.0%

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

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

                                    \[\leadsto -1 \]

                                  if 1.2423345892717348e-287 < (/.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 1 \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites37.3%

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

                                  Alternative 7: 38.6% accurate, 12.6× speedup?

                                  \[-1 \]
                                  (FPCore (x y)
                                    :precision binary64
                                    :pre TRUE
                                    -1.0)
                                  double code(double x, double y) {
                                  	return -1.0;
                                  }
                                  
                                  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
                                  
                                  f(x, y):
                                  	x in [-inf, +inf],
                                  	y in [-inf, +inf]
                                  code: THEORY
                                  BEGIN
                                  f(x, y: real): real =
                                  	-1
                                  END code
                                  -1
                                  
                                  Derivation
                                  1. Initial program 100.0%

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

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

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

                                    Reproduce

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