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

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

Specification

?
\[\begin{array}{l} \\ \frac{x - y}{2 - \left(x + y\right)} \end{array} \]
(FPCore (x y) :precision binary64 (/ (- 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)
    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]
\begin{array}{l}

\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}

Sampling outcomes in binary64 precision:

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?

\[\begin{array}{l} \\ \frac{x - y}{2 - \left(x + y\right)} \end{array} \]
(FPCore (x y) :precision binary64 (/ (- 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)
    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]
\begin{array}{l}

\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x - y}{2 - \left(x + y\right)} \end{array} \]
(FPCore (x y) :precision binary64 (/ (- 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)
    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]
\begin{array}{l}

\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{x - y}{2 - \left(x + y\right)} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 61.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x} + -1\\ \mathbf{if}\;x \leq -15500000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-144}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-263}:\\ \;\;\;\;\frac{y}{-2}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (/ y x) -1.0)))
   (if (<= x -15500000000.0)
     t_0
     (if (<= x -9.2e-144)
       (- 1.0 (/ x y))
       (if (<= x 5.1e-263) (/ y -2.0) (if (<= x 2.2e+42) 1.0 t_0))))))
double code(double x, double y) {
	double t_0 = (y / x) + -1.0;
	double tmp;
	if (x <= -15500000000.0) {
		tmp = t_0;
	} else if (x <= -9.2e-144) {
		tmp = 1.0 - (x / y);
	} else if (x <= 5.1e-263) {
		tmp = y / -2.0;
	} else if (x <= 2.2e+42) {
		tmp = 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (y / x) + (-1.0d0)
    if (x <= (-15500000000.0d0)) then
        tmp = t_0
    else if (x <= (-9.2d-144)) then
        tmp = 1.0d0 - (x / y)
    else if (x <= 5.1d-263) then
        tmp = y / (-2.0d0)
    else if (x <= 2.2d+42) then
        tmp = 1.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (y / x) + -1.0;
	double tmp;
	if (x <= -15500000000.0) {
		tmp = t_0;
	} else if (x <= -9.2e-144) {
		tmp = 1.0 - (x / y);
	} else if (x <= 5.1e-263) {
		tmp = y / -2.0;
	} else if (x <= 2.2e+42) {
		tmp = 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y / x) + -1.0
	tmp = 0
	if x <= -15500000000.0:
		tmp = t_0
	elif x <= -9.2e-144:
		tmp = 1.0 - (x / y)
	elif x <= 5.1e-263:
		tmp = y / -2.0
	elif x <= 2.2e+42:
		tmp = 1.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y / x) + -1.0)
	tmp = 0.0
	if (x <= -15500000000.0)
		tmp = t_0;
	elseif (x <= -9.2e-144)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (x <= 5.1e-263)
		tmp = Float64(y / -2.0);
	elseif (x <= 2.2e+42)
		tmp = 1.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y / x) + -1.0;
	tmp = 0.0;
	if (x <= -15500000000.0)
		tmp = t_0;
	elseif (x <= -9.2e-144)
		tmp = 1.0 - (x / y);
	elseif (x <= 5.1e-263)
		tmp = y / -2.0;
	elseif (x <= 2.2e+42)
		tmp = 1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -15500000000.0], t$95$0, If[LessEqual[x, -9.2e-144], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.1e-263], N[(y / -2.0), $MachinePrecision], If[LessEqual[x, 2.2e+42], 1.0, t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;x \leq -15500000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -9.2 \cdot 10^{-144}:\\
\;\;\;\;1 - \frac{x}{y}\\

\mathbf{elif}\;x \leq 5.1 \cdot 10^{-263}:\\
\;\;\;\;\frac{y}{-2}\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+42}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.55e10 or 2.2000000000000001e42 < x

    1. Initial program 100.0%

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

      \[\leadsto \frac{x - y}{\color{blue}{-1 \cdot x}} \]
    4. Step-by-step derivation
      1. mul-1-neg83.3%

        \[\leadsto \frac{x - y}{\color{blue}{-x}} \]
    5. Simplified83.3%

      \[\leadsto \frac{x - y}{\color{blue}{-x}} \]
    6. Taylor expanded in x around inf 83.3%

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

    if -1.55e10 < x < -9.2e-144

    1. Initial program 99.8%

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

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

      \[\leadsto \frac{x - y}{\color{blue}{-1 \cdot y}} \]
    5. Step-by-step derivation
      1. neg-mul-155.7%

        \[\leadsto \frac{x - y}{\color{blue}{-y}} \]
    6. Simplified55.7%

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. mul-1-neg55.7%

        \[\leadsto 1 + \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. unsub-neg55.7%

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    9. Simplified55.7%

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

    if -9.2e-144 < x < 5.09999999999999971e-263

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{2 - y}} \]
    4. Step-by-step derivation
      1. mul-1-neg81.4%

        \[\leadsto \color{blue}{-\frac{y}{2 - y}} \]
      2. distribute-neg-frac281.4%

        \[\leadsto \color{blue}{\frac{y}{-\left(2 - y\right)}} \]
      3. mul-1-neg81.4%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(2 - y\right)}} \]
      4. sub-neg81.4%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(2 + \left(-y\right)\right)}} \]
      5. +-commutative81.4%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(\left(-y\right) + 2\right)}} \]
      6. distribute-lft-in81.4%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(-y\right) + -1 \cdot 2}} \]
      7. neg-mul-181.4%

        \[\leadsto \frac{y}{\color{blue}{\left(-\left(-y\right)\right)} + -1 \cdot 2} \]
      8. remove-double-neg81.4%

        \[\leadsto \frac{y}{\color{blue}{y} + -1 \cdot 2} \]
      9. metadata-eval81.4%

        \[\leadsto \frac{y}{y + \color{blue}{-2}} \]
    5. Simplified81.4%

      \[\leadsto \color{blue}{\frac{y}{y + -2}} \]
    6. Taylor expanded in y around 0 52.1%

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

    if 5.09999999999999971e-263 < x < 2.2000000000000001e42

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{1} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification66.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -15500000000:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-144}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-263}:\\ \;\;\;\;\frac{y}{-2}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 60.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -22000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-142}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq 3.05 \cdot 10^{-266}:\\ \;\;\;\;\frac{y}{-2}\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{+49}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -22000000000.0)
   -1.0
   (if (<= x -3.8e-142)
     (- 1.0 (/ x y))
     (if (<= x 3.05e-266) (/ y -2.0) (if (<= x 2.75e+49) 1.0 -1.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -22000000000.0) {
		tmp = -1.0;
	} else if (x <= -3.8e-142) {
		tmp = 1.0 - (x / y);
	} else if (x <= 3.05e-266) {
		tmp = y / -2.0;
	} else if (x <= 2.75e+49) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-22000000000.0d0)) then
        tmp = -1.0d0
    else if (x <= (-3.8d-142)) then
        tmp = 1.0d0 - (x / y)
    else if (x <= 3.05d-266) then
        tmp = y / (-2.0d0)
    else if (x <= 2.75d+49) 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 <= -22000000000.0) {
		tmp = -1.0;
	} else if (x <= -3.8e-142) {
		tmp = 1.0 - (x / y);
	} else if (x <= 3.05e-266) {
		tmp = y / -2.0;
	} else if (x <= 2.75e+49) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -22000000000.0:
		tmp = -1.0
	elif x <= -3.8e-142:
		tmp = 1.0 - (x / y)
	elif x <= 3.05e-266:
		tmp = y / -2.0
	elif x <= 2.75e+49:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -22000000000.0)
		tmp = -1.0;
	elseif (x <= -3.8e-142)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (x <= 3.05e-266)
		tmp = Float64(y / -2.0);
	elseif (x <= 2.75e+49)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -22000000000.0)
		tmp = -1.0;
	elseif (x <= -3.8e-142)
		tmp = 1.0 - (x / y);
	elseif (x <= 3.05e-266)
		tmp = y / -2.0;
	elseif (x <= 2.75e+49)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -22000000000.0], -1.0, If[LessEqual[x, -3.8e-142], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.05e-266], N[(y / -2.0), $MachinePrecision], If[LessEqual[x, 2.75e+49], 1.0, -1.0]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -22000000000:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -3.8 \cdot 10^{-142}:\\
\;\;\;\;1 - \frac{x}{y}\\

\mathbf{elif}\;x \leq 3.05 \cdot 10^{-266}:\\
\;\;\;\;\frac{y}{-2}\\

\mathbf{elif}\;x \leq 2.75 \cdot 10^{+49}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.2e10 or 2.75000000000000021e49 < x

    1. Initial program 100.0%

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

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

    if -2.2e10 < x < -3.79999999999999972e-142

    1. Initial program 99.8%

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

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

      \[\leadsto \frac{x - y}{\color{blue}{-1 \cdot y}} \]
    5. Step-by-step derivation
      1. neg-mul-155.7%

        \[\leadsto \frac{x - y}{\color{blue}{-y}} \]
    6. Simplified55.7%

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. mul-1-neg55.7%

        \[\leadsto 1 + \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. unsub-neg55.7%

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    9. Simplified55.7%

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

    if -3.79999999999999972e-142 < x < 3.05e-266

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{2 - y}} \]
    4. Step-by-step derivation
      1. mul-1-neg81.4%

        \[\leadsto \color{blue}{-\frac{y}{2 - y}} \]
      2. distribute-neg-frac281.4%

        \[\leadsto \color{blue}{\frac{y}{-\left(2 - y\right)}} \]
      3. mul-1-neg81.4%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(2 - y\right)}} \]
      4. sub-neg81.4%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(2 + \left(-y\right)\right)}} \]
      5. +-commutative81.4%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(\left(-y\right) + 2\right)}} \]
      6. distribute-lft-in81.4%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(-y\right) + -1 \cdot 2}} \]
      7. neg-mul-181.4%

        \[\leadsto \frac{y}{\color{blue}{\left(-\left(-y\right)\right)} + -1 \cdot 2} \]
      8. remove-double-neg81.4%

        \[\leadsto \frac{y}{\color{blue}{y} + -1 \cdot 2} \]
      9. metadata-eval81.4%

        \[\leadsto \frac{y}{y + \color{blue}{-2}} \]
    5. Simplified81.4%

      \[\leadsto \color{blue}{\frac{y}{y + -2}} \]
    6. Taylor expanded in y around 0 52.1%

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

    if 3.05e-266 < x < 2.75000000000000021e49

    1. Initial program 100.0%

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

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

Alternative 4: 60.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -13500000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.02 \cdot 10^{-143}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-265}:\\ \;\;\;\;\frac{y}{-2}\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{+49}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -13500000000.0)
   -1.0
   (if (<= x -1.02e-143)
     1.0
     (if (<= x 8.2e-265) (/ y -2.0) (if (<= x 2.75e+49) 1.0 -1.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -13500000000.0) {
		tmp = -1.0;
	} else if (x <= -1.02e-143) {
		tmp = 1.0;
	} else if (x <= 8.2e-265) {
		tmp = y / -2.0;
	} else if (x <= 2.75e+49) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-13500000000.0d0)) then
        tmp = -1.0d0
    else if (x <= (-1.02d-143)) then
        tmp = 1.0d0
    else if (x <= 8.2d-265) then
        tmp = y / (-2.0d0)
    else if (x <= 2.75d+49) 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 <= -13500000000.0) {
		tmp = -1.0;
	} else if (x <= -1.02e-143) {
		tmp = 1.0;
	} else if (x <= 8.2e-265) {
		tmp = y / -2.0;
	} else if (x <= 2.75e+49) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -13500000000.0:
		tmp = -1.0
	elif x <= -1.02e-143:
		tmp = 1.0
	elif x <= 8.2e-265:
		tmp = y / -2.0
	elif x <= 2.75e+49:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -13500000000.0)
		tmp = -1.0;
	elseif (x <= -1.02e-143)
		tmp = 1.0;
	elseif (x <= 8.2e-265)
		tmp = Float64(y / -2.0);
	elseif (x <= 2.75e+49)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -13500000000.0)
		tmp = -1.0;
	elseif (x <= -1.02e-143)
		tmp = 1.0;
	elseif (x <= 8.2e-265)
		tmp = y / -2.0;
	elseif (x <= 2.75e+49)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -13500000000.0], -1.0, If[LessEqual[x, -1.02e-143], 1.0, If[LessEqual[x, 8.2e-265], N[(y / -2.0), $MachinePrecision], If[LessEqual[x, 2.75e+49], 1.0, -1.0]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -13500000000:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -1.02 \cdot 10^{-143}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 8.2 \cdot 10^{-265}:\\
\;\;\;\;\frac{y}{-2}\\

\mathbf{elif}\;x \leq 2.75 \cdot 10^{+49}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.35e10 or 2.75000000000000021e49 < x

    1. Initial program 100.0%

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

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

    if -1.35e10 < x < -1.02e-143 or 8.2e-265 < x < 2.75000000000000021e49

    1. Initial program 99.9%

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

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

    if -1.02e-143 < x < 8.2e-265

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{2 - y}} \]
    4. Step-by-step derivation
      1. mul-1-neg81.4%

        \[\leadsto \color{blue}{-\frac{y}{2 - y}} \]
      2. distribute-neg-frac281.4%

        \[\leadsto \color{blue}{\frac{y}{-\left(2 - y\right)}} \]
      3. mul-1-neg81.4%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(2 - y\right)}} \]
      4. sub-neg81.4%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(2 + \left(-y\right)\right)}} \]
      5. +-commutative81.4%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(\left(-y\right) + 2\right)}} \]
      6. distribute-lft-in81.4%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(-y\right) + -1 \cdot 2}} \]
      7. neg-mul-181.4%

        \[\leadsto \frac{y}{\color{blue}{\left(-\left(-y\right)\right)} + -1 \cdot 2} \]
      8. remove-double-neg81.4%

        \[\leadsto \frac{y}{\color{blue}{y} + -1 \cdot 2} \]
      9. metadata-eval81.4%

        \[\leadsto \frac{y}{y + \color{blue}{-2}} \]
    5. Simplified81.4%

      \[\leadsto \color{blue}{\frac{y}{y + -2}} \]
    6. Taylor expanded in y around 0 52.1%

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

Alternative 5: 75.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -29000000000 \lor \neg \left(x \leq 2.6\right):\\ \;\;\;\;\frac{x}{2 - \left(x + y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y + -2}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -29000000000.0) (not (<= x 2.6)))
   (/ x (- 2.0 (+ x y)))
   (/ y (+ y -2.0))))
double code(double x, double y) {
	double tmp;
	if ((x <= -29000000000.0) || !(x <= 2.6)) {
		tmp = x / (2.0 - (x + y));
	} else {
		tmp = y / (y + -2.0);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-29000000000.0d0)) .or. (.not. (x <= 2.6d0))) then
        tmp = x / (2.0d0 - (x + y))
    else
        tmp = y / (y + (-2.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -29000000000.0) || !(x <= 2.6)) {
		tmp = x / (2.0 - (x + y));
	} else {
		tmp = y / (y + -2.0);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -29000000000.0) or not (x <= 2.6):
		tmp = x / (2.0 - (x + y))
	else:
		tmp = y / (y + -2.0)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -29000000000.0) || !(x <= 2.6))
		tmp = Float64(x / Float64(2.0 - Float64(x + y)));
	else
		tmp = Float64(y / Float64(y + -2.0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -29000000000.0) || ~((x <= 2.6)))
		tmp = x / (2.0 - (x + y));
	else
		tmp = y / (y + -2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -29000000000.0], N[Not[LessEqual[x, 2.6]], $MachinePrecision]], N[(x / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -29000000000 \lor \neg \left(x \leq 2.6\right):\\
\;\;\;\;\frac{x}{2 - \left(x + y\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.9e10 or 2.60000000000000009 < x

    1. Initial program 100.0%

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

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

    if -2.9e10 < x < 2.60000000000000009

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{2 - y}} \]
    4. Step-by-step derivation
      1. mul-1-neg74.2%

        \[\leadsto \color{blue}{-\frac{y}{2 - y}} \]
      2. distribute-neg-frac274.2%

        \[\leadsto \color{blue}{\frac{y}{-\left(2 - y\right)}} \]
      3. mul-1-neg74.2%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(2 - y\right)}} \]
      4. sub-neg74.2%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(2 + \left(-y\right)\right)}} \]
      5. +-commutative74.2%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(\left(-y\right) + 2\right)}} \]
      6. distribute-lft-in74.2%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(-y\right) + -1 \cdot 2}} \]
      7. neg-mul-174.2%

        \[\leadsto \frac{y}{\color{blue}{\left(-\left(-y\right)\right)} + -1 \cdot 2} \]
      8. remove-double-neg74.2%

        \[\leadsto \frac{y}{\color{blue}{y} + -1 \cdot 2} \]
      9. metadata-eval74.2%

        \[\leadsto \frac{y}{y + \color{blue}{-2}} \]
    5. Simplified74.2%

      \[\leadsto \color{blue}{\frac{y}{y + -2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -29000000000 \lor \neg \left(x \leq 2.6\right):\\ \;\;\;\;\frac{x}{2 - \left(x + y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y + -2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 87.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -20500000000:\\ \;\;\;\;\frac{x}{2 - \left(x + y\right)}\\ \mathbf{elif}\;x \leq 0.6:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -20500000000.0)
   (/ x (- 2.0 (+ x y)))
   (if (<= x 0.6) (/ (- x y) (- 2.0 y)) (/ (- x y) (- 2.0 x)))))
double code(double x, double y) {
	double tmp;
	if (x <= -20500000000.0) {
		tmp = x / (2.0 - (x + y));
	} else if (x <= 0.6) {
		tmp = (x - y) / (2.0 - y);
	} else {
		tmp = (x - y) / (2.0 - x);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-20500000000.0d0)) then
        tmp = x / (2.0d0 - (x + y))
    else if (x <= 0.6d0) then
        tmp = (x - y) / (2.0d0 - y)
    else
        tmp = (x - y) / (2.0d0 - x)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -20500000000.0) {
		tmp = x / (2.0 - (x + y));
	} else if (x <= 0.6) {
		tmp = (x - y) / (2.0 - y);
	} else {
		tmp = (x - y) / (2.0 - x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -20500000000.0:
		tmp = x / (2.0 - (x + y))
	elif x <= 0.6:
		tmp = (x - y) / (2.0 - y)
	else:
		tmp = (x - y) / (2.0 - x)
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -20500000000.0)
		tmp = Float64(x / Float64(2.0 - Float64(x + y)));
	elseif (x <= 0.6)
		tmp = Float64(Float64(x - y) / Float64(2.0 - y));
	else
		tmp = Float64(Float64(x - y) / Float64(2.0 - x));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -20500000000.0)
		tmp = x / (2.0 - (x + y));
	elseif (x <= 0.6)
		tmp = (x - y) / (2.0 - y);
	else
		tmp = (x - y) / (2.0 - x);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -20500000000.0], N[(x / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.6], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -20500000000:\\
\;\;\;\;\frac{x}{2 - \left(x + y\right)}\\

\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;\frac{x - y}{2 - y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.05e10

    1. Initial program 100.0%

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

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

    if -2.05e10 < x < 0.599999999999999978

    1. Initial program 100.0%

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

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

    if 0.599999999999999978 < x

    1. Initial program 100.0%

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

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

Alternative 7: 84.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.4 \cdot 10^{-5}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+58}:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -5.4e-5)
   (/ y (+ y -2.0))
   (if (<= y 3.2e+58) (/ (- x y) (- 2.0 x)) (- 1.0 (/ x y)))))
double code(double x, double y) {
	double tmp;
	if (y <= -5.4e-5) {
		tmp = y / (y + -2.0);
	} else if (y <= 3.2e+58) {
		tmp = (x - y) / (2.0 - x);
	} else {
		tmp = 1.0 - (x / y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-5.4d-5)) then
        tmp = y / (y + (-2.0d0))
    else if (y <= 3.2d+58) then
        tmp = (x - y) / (2.0d0 - x)
    else
        tmp = 1.0d0 - (x / y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -5.4e-5) {
		tmp = y / (y + -2.0);
	} else if (y <= 3.2e+58) {
		tmp = (x - y) / (2.0 - x);
	} else {
		tmp = 1.0 - (x / y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -5.4e-5:
		tmp = y / (y + -2.0)
	elif y <= 3.2e+58:
		tmp = (x - y) / (2.0 - x)
	else:
		tmp = 1.0 - (x / y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -5.4e-5)
		tmp = Float64(y / Float64(y + -2.0));
	elseif (y <= 3.2e+58)
		tmp = Float64(Float64(x - y) / Float64(2.0 - x));
	else
		tmp = Float64(1.0 - Float64(x / y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -5.4e-5)
		tmp = y / (y + -2.0);
	elseif (y <= 3.2e+58)
		tmp = (x - y) / (2.0 - x);
	else
		tmp = 1.0 - (x / y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -5.4e-5], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+58], N[(N[(x - y), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{-5}:\\
\;\;\;\;\frac{y}{y + -2}\\

\mathbf{elif}\;y \leq 3.2 \cdot 10^{+58}:\\
\;\;\;\;\frac{x - y}{2 - x}\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{2 - y}} \]
    4. Step-by-step derivation
      1. mul-1-neg74.4%

        \[\leadsto \color{blue}{-\frac{y}{2 - y}} \]
      2. distribute-neg-frac274.4%

        \[\leadsto \color{blue}{\frac{y}{-\left(2 - y\right)}} \]
      3. mul-1-neg74.4%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(2 - y\right)}} \]
      4. sub-neg74.4%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(2 + \left(-y\right)\right)}} \]
      5. +-commutative74.4%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(\left(-y\right) + 2\right)}} \]
      6. distribute-lft-in74.4%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(-y\right) + -1 \cdot 2}} \]
      7. neg-mul-174.4%

        \[\leadsto \frac{y}{\color{blue}{\left(-\left(-y\right)\right)} + -1 \cdot 2} \]
      8. remove-double-neg74.4%

        \[\leadsto \frac{y}{\color{blue}{y} + -1 \cdot 2} \]
      9. metadata-eval74.4%

        \[\leadsto \frac{y}{y + \color{blue}{-2}} \]
    5. Simplified74.4%

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

    if -5.3999999999999998e-5 < y < 3.20000000000000015e58

    1. Initial program 100.0%

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

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

    if 3.20000000000000015e58 < y

    1. Initial program 99.9%

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

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

      \[\leadsto \frac{x - y}{\color{blue}{-1 \cdot y}} \]
    5. Step-by-step derivation
      1. neg-mul-177.7%

        \[\leadsto \frac{x - y}{\color{blue}{-y}} \]
    6. Simplified77.7%

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. mul-1-neg77.7%

        \[\leadsto 1 + \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. unsub-neg77.7%

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    9. Simplified77.7%

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

Alternative 8: 75.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7800000000 \lor \neg \left(x \leq 3.2\right):\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y + -2}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -7800000000.0) (not (<= x 3.2)))
   (/ x (- 2.0 x))
   (/ y (+ y -2.0))))
double code(double x, double y) {
	double tmp;
	if ((x <= -7800000000.0) || !(x <= 3.2)) {
		tmp = x / (2.0 - x);
	} else {
		tmp = y / (y + -2.0);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-7800000000.0d0)) .or. (.not. (x <= 3.2d0))) 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 <= -7800000000.0) || !(x <= 3.2)) {
		tmp = x / (2.0 - x);
	} else {
		tmp = y / (y + -2.0);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -7800000000.0) or not (x <= 3.2):
		tmp = x / (2.0 - x)
	else:
		tmp = y / (y + -2.0)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -7800000000.0) || !(x <= 3.2))
		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 <= -7800000000.0) || ~((x <= 3.2)))
		tmp = x / (2.0 - x);
	else
		tmp = y / (y + -2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -7800000000.0], N[Not[LessEqual[x, 3.2]], $MachinePrecision]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7800000000 \lor \neg \left(x \leq 3.2\right):\\
\;\;\;\;\frac{x}{2 - x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.8e9 or 3.2000000000000002 < x

    1. Initial program 100.0%

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

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

    if -7.8e9 < x < 3.2000000000000002

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{2 - y}} \]
    4. Step-by-step derivation
      1. mul-1-neg74.2%

        \[\leadsto \color{blue}{-\frac{y}{2 - y}} \]
      2. distribute-neg-frac274.2%

        \[\leadsto \color{blue}{\frac{y}{-\left(2 - y\right)}} \]
      3. mul-1-neg74.2%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(2 - y\right)}} \]
      4. sub-neg74.2%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(2 + \left(-y\right)\right)}} \]
      5. +-commutative74.2%

        \[\leadsto \frac{y}{-1 \cdot \color{blue}{\left(\left(-y\right) + 2\right)}} \]
      6. distribute-lft-in74.2%

        \[\leadsto \frac{y}{\color{blue}{-1 \cdot \left(-y\right) + -1 \cdot 2}} \]
      7. neg-mul-174.2%

        \[\leadsto \frac{y}{\color{blue}{\left(-\left(-y\right)\right)} + -1 \cdot 2} \]
      8. remove-double-neg74.2%

        \[\leadsto \frac{y}{\color{blue}{y} + -1 \cdot 2} \]
      9. metadata-eval74.2%

        \[\leadsto \frac{y}{y + \color{blue}{-2}} \]
    5. Simplified74.2%

      \[\leadsto \color{blue}{\frac{y}{y + -2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7800000000 \lor \neg \left(x \leq 3.2\right):\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y + -2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 73.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{+23} \lor \neg \left(y \leq 2.8 \cdot 10^{+56}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -9e+23) (not (<= y 2.8e+56))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
	double tmp;
	if ((y <= -9e+23) || !(y <= 2.8e+56)) {
		tmp = 1.0 - (x / y);
	} else {
		tmp = x / (2.0 - x);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-9d+23)) .or. (.not. (y <= 2.8d+56))) then
        tmp = 1.0d0 - (x / y)
    else
        tmp = x / (2.0d0 - x)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -9e+23) || !(y <= 2.8e+56)) {
		tmp = 1.0 - (x / y);
	} else {
		tmp = x / (2.0 - x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -9e+23) or not (y <= 2.8e+56):
		tmp = 1.0 - (x / y)
	else:
		tmp = x / (2.0 - x)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -9e+23) || !(y <= 2.8e+56))
		tmp = Float64(1.0 - Float64(x / y));
	else
		tmp = Float64(x / Float64(2.0 - x));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -9e+23) || ~((y <= 2.8e+56)))
		tmp = 1.0 - (x / y);
	else
		tmp = x / (2.0 - x);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -9e+23], N[Not[LessEqual[y, 2.8e+56]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+23} \lor \neg \left(y \leq 2.8 \cdot 10^{+56}\right):\\
\;\;\;\;1 - \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.99999999999999958e23 or 2.80000000000000008e56 < y

    1. Initial program 100.0%

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

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

      \[\leadsto \frac{x - y}{\color{blue}{-1 \cdot y}} \]
    5. Step-by-step derivation
      1. neg-mul-177.5%

        \[\leadsto \frac{x - y}{\color{blue}{-y}} \]
    6. Simplified77.5%

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. mul-1-neg77.5%

        \[\leadsto 1 + \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. unsub-neg77.5%

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    9. Simplified77.5%

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

    if -8.99999999999999958e23 < y < 2.80000000000000008e56

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\frac{x}{2 - x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification72.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{+23} \lor \neg \left(y \leq 2.8 \cdot 10^{+56}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 62.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -10200000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+49}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -10200000000.0) -1.0 (if (<= x 5e+49) 1.0 -1.0)))
double code(double x, double y) {
	double tmp;
	if (x <= -10200000000.0) {
		tmp = -1.0;
	} else if (x <= 5e+49) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-10200000000.0d0)) then
        tmp = -1.0d0
    else if (x <= 5d+49) 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 <= -10200000000.0) {
		tmp = -1.0;
	} else if (x <= 5e+49) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -10200000000.0:
		tmp = -1.0
	elif x <= 5e+49:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -10200000000.0)
		tmp = -1.0;
	elseif (x <= 5e+49)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -10200000000.0)
		tmp = -1.0;
	elseif (x <= 5e+49)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -10200000000.0], -1.0, If[LessEqual[x, 5e+49], 1.0, -1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -10200000000:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 5 \cdot 10^{+49}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.02e10 or 5.0000000000000004e49 < x

    1. Initial program 100.0%

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

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

    if -1.02e10 < x < 5.0000000000000004e49

    1. Initial program 100.0%

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

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

Alternative 11: 38.6% accurate, 9.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
	return -1.0;
}
real(8) function code(x, y)
    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
\begin{array}{l}

\\
-1
\end{array}
Derivation
  1. Initial program 100.0%

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

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

Developer Target 1: 100.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 - \left(x + y\right)\\ \frac{x}{t\_0} - \frac{y}{t\_0} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
	double t_0 = 2.0 - (x + y);
	return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    t_0 = 2.0d0 - (x + y)
    code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
	double t_0 = 2.0 - (x + y);
	return (x / t_0) - (y / t_0);
}
def code(x, y):
	t_0 = 2.0 - (x + y)
	return (x / t_0) - (y / t_0)
function code(x, y)
	t_0 = Float64(2.0 - Float64(x + y))
	return Float64(Float64(x / t_0) - Float64(y / t_0))
end
function tmp = code(x, y)
	t_0 = 2.0 - (x + y);
	tmp = (x / t_0) - (y / t_0);
end
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t\_0} - \frac{y}{t\_0}
\end{array}
\end{array}

Reproduce

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

  :alt
  (! :herbie-platform default (- (/ x (- 2 (+ x y))) (/ y (- 2 (+ x y)))))

  (/ (- x y) (- 2.0 (+ x y))))