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

Percentage Accurate: 100.0% → 100.0%
Time: 8.3s
Alternatives: 9
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 9 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, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := y + \left(-2 + x\right)\\
\frac{y}{t\_0} - \frac{x}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{x - y}{2 - \left(x + y\right)} \]
  2. Step-by-step derivation
    1. remove-double-neg100.0%

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

      \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
    3. distribute-neg-frac2100.0%

      \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
    4. distribute-frac-neg100.0%

      \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
    5. sub-neg100.0%

      \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
    6. distribute-neg-in100.0%

      \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
    7. remove-double-neg100.0%

      \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
    8. +-commutative100.0%

      \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
    9. sub-neg100.0%

      \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
    10. neg-sub0100.0%

      \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
    11. associate--r-100.0%

      \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
    12. metadata-eval100.0%

      \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
    13. metadata-eval100.0%

      \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
    14. +-commutative100.0%

      \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
    15. +-commutative100.0%

      \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
    16. associate-+r+100.0%

      \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
    17. metadata-eval100.0%

      \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. div-sub100.0%

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

      \[\leadsto \frac{y}{\color{blue}{\left(y + -2\right) + x}} - \frac{x}{x + \left(y + -2\right)} \]
    3. associate-+l+100.0%

      \[\leadsto \frac{y}{\color{blue}{y + \left(-2 + x\right)}} - \frac{x}{x + \left(y + -2\right)} \]
    4. +-commutative100.0%

      \[\leadsto \frac{y}{y + \left(-2 + x\right)} - \frac{x}{\color{blue}{\left(y + -2\right) + x}} \]
    5. associate-+l+100.0%

      \[\leadsto \frac{y}{y + \left(-2 + x\right)} - \frac{x}{\color{blue}{y + \left(-2 + x\right)}} \]
  6. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{y}{y + \left(-2 + x\right)} - \frac{x}{y + \left(-2 + x\right)}} \]
  7. Final simplification100.0%

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

Alternative 2: 60.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{+111}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{+86}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -2400000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-212}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-263}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-126}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-81}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.25e+111)
   -1.0
   (if (<= x -2.25e+86)
     1.0
     (if (<= x -2400000.0)
       -1.0
       (if (<= x -1.35e-212)
         1.0
         (if (<= x -1.4e-263)
           (* y -0.5)
           (if (<= x 6.5e-126)
             1.0
             (if (<= x 3.1e-81) (* x 0.5) (if (<= x 1.65e+20) 1.0 -1.0)))))))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.25e+111) {
		tmp = -1.0;
	} else if (x <= -2.25e+86) {
		tmp = 1.0;
	} else if (x <= -2400000.0) {
		tmp = -1.0;
	} else if (x <= -1.35e-212) {
		tmp = 1.0;
	} else if (x <= -1.4e-263) {
		tmp = y * -0.5;
	} else if (x <= 6.5e-126) {
		tmp = 1.0;
	} else if (x <= 3.1e-81) {
		tmp = x * 0.5;
	} else if (x <= 1.65e+20) {
		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 <= (-1.25d+111)) then
        tmp = -1.0d0
    else if (x <= (-2.25d+86)) then
        tmp = 1.0d0
    else if (x <= (-2400000.0d0)) then
        tmp = -1.0d0
    else if (x <= (-1.35d-212)) then
        tmp = 1.0d0
    else if (x <= (-1.4d-263)) then
        tmp = y * (-0.5d0)
    else if (x <= 6.5d-126) then
        tmp = 1.0d0
    else if (x <= 3.1d-81) then
        tmp = x * 0.5d0
    else if (x <= 1.65d+20) 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 <= -1.25e+111) {
		tmp = -1.0;
	} else if (x <= -2.25e+86) {
		tmp = 1.0;
	} else if (x <= -2400000.0) {
		tmp = -1.0;
	} else if (x <= -1.35e-212) {
		tmp = 1.0;
	} else if (x <= -1.4e-263) {
		tmp = y * -0.5;
	} else if (x <= 6.5e-126) {
		tmp = 1.0;
	} else if (x <= 3.1e-81) {
		tmp = x * 0.5;
	} else if (x <= 1.65e+20) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.25e+111:
		tmp = -1.0
	elif x <= -2.25e+86:
		tmp = 1.0
	elif x <= -2400000.0:
		tmp = -1.0
	elif x <= -1.35e-212:
		tmp = 1.0
	elif x <= -1.4e-263:
		tmp = y * -0.5
	elif x <= 6.5e-126:
		tmp = 1.0
	elif x <= 3.1e-81:
		tmp = x * 0.5
	elif x <= 1.65e+20:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.25e+111)
		tmp = -1.0;
	elseif (x <= -2.25e+86)
		tmp = 1.0;
	elseif (x <= -2400000.0)
		tmp = -1.0;
	elseif (x <= -1.35e-212)
		tmp = 1.0;
	elseif (x <= -1.4e-263)
		tmp = Float64(y * -0.5);
	elseif (x <= 6.5e-126)
		tmp = 1.0;
	elseif (x <= 3.1e-81)
		tmp = Float64(x * 0.5);
	elseif (x <= 1.65e+20)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.25e+111)
		tmp = -1.0;
	elseif (x <= -2.25e+86)
		tmp = 1.0;
	elseif (x <= -2400000.0)
		tmp = -1.0;
	elseif (x <= -1.35e-212)
		tmp = 1.0;
	elseif (x <= -1.4e-263)
		tmp = y * -0.5;
	elseif (x <= 6.5e-126)
		tmp = 1.0;
	elseif (x <= 3.1e-81)
		tmp = x * 0.5;
	elseif (x <= 1.65e+20)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.25e+111], -1.0, If[LessEqual[x, -2.25e+86], 1.0, If[LessEqual[x, -2400000.0], -1.0, If[LessEqual[x, -1.35e-212], 1.0, If[LessEqual[x, -1.4e-263], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 6.5e-126], 1.0, If[LessEqual[x, 3.1e-81], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.65e+20], 1.0, -1.0]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+111}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -2.25 \cdot 10^{+86}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -2400000:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -1.35 \cdot 10^{-212}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -1.4 \cdot 10^{-263}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 6.5 \cdot 10^{-126}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-81}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 1.65 \cdot 10^{+20}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.2499999999999999e111 or -2.24999999999999996e86 < x < -2.4e6 or 1.65e20 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 84.6%

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

    if -1.2499999999999999e111 < x < -2.24999999999999996e86 or -2.4e6 < x < -1.34999999999999991e-212 or -1.4e-263 < x < 6.50000000000000014e-126 or 3.09999999999999988e-81 < x < 1.65e20

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 63.2%

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

    if -1.34999999999999991e-212 < x < -1.4e-263

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg99.9%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac299.9%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg99.9%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg99.9%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in99.9%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg99.9%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative99.9%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg99.9%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub099.9%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-99.9%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval99.9%

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

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative99.9%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+99.9%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval99.9%

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

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

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

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    7. Step-by-step derivation
      1. *-commutative69.8%

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    8. Simplified69.8%

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

    if 6.50000000000000014e-126 < x < 3.09999999999999988e-81

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{-\left(x - 2\right)}} \]
      3. neg-sub074.2%

        \[\leadsto \frac{x}{\color{blue}{0 - \left(x - 2\right)}} \]
      4. associate-+l-74.2%

        \[\leadsto \frac{x}{\color{blue}{\left(0 - x\right) + 2}} \]
      5. neg-sub074.2%

        \[\leadsto \frac{x}{\color{blue}{\left(-x\right)} + 2} \]
      6. +-commutative74.2%

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

        \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
    7. Simplified74.2%

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

      \[\leadsto \color{blue}{0.5 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative74.2%

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    10. Simplified74.2%

      \[\leadsto \color{blue}{x \cdot 0.5} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification73.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{+111}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{+86}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -2400000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-212}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-263}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-126}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-81}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 72.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ t_1 := -1 - \frac{y \cdot -2}{x}\\ t_2 := \frac{y}{y - 2}\\ \mathbf{if}\;x \leq -5 \cdot 10^{+110}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{+86}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -45:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-126}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-81}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{+19}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x)))
        (t_1 (- -1.0 (/ (* y -2.0) x)))
        (t_2 (/ y (- y 2.0))))
   (if (<= x -5e+110)
     t_1
     (if (<= x -2.25e+86)
       1.0
       (if (<= x -45.0)
         t_0
         (if (<= x 8.5e-126)
           t_2
           (if (<= x 1.95e-81) t_0 (if (<= x 5.8e+19) t_2 t_1))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double t_1 = -1.0 - ((y * -2.0) / x);
	double t_2 = y / (y - 2.0);
	double tmp;
	if (x <= -5e+110) {
		tmp = t_1;
	} else if (x <= -2.25e+86) {
		tmp = 1.0;
	} else if (x <= -45.0) {
		tmp = t_0;
	} else if (x <= 8.5e-126) {
		tmp = t_2;
	} else if (x <= 1.95e-81) {
		tmp = t_0;
	} else if (x <= 5.8e+19) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = x / (2.0d0 - x)
    t_1 = (-1.0d0) - ((y * (-2.0d0)) / x)
    t_2 = y / (y - 2.0d0)
    if (x <= (-5d+110)) then
        tmp = t_1
    else if (x <= (-2.25d+86)) then
        tmp = 1.0d0
    else if (x <= (-45.0d0)) then
        tmp = t_0
    else if (x <= 8.5d-126) then
        tmp = t_2
    else if (x <= 1.95d-81) then
        tmp = t_0
    else if (x <= 5.8d+19) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double t_1 = -1.0 - ((y * -2.0) / x);
	double t_2 = y / (y - 2.0);
	double tmp;
	if (x <= -5e+110) {
		tmp = t_1;
	} else if (x <= -2.25e+86) {
		tmp = 1.0;
	} else if (x <= -45.0) {
		tmp = t_0;
	} else if (x <= 8.5e-126) {
		tmp = t_2;
	} else if (x <= 1.95e-81) {
		tmp = t_0;
	} else if (x <= 5.8e+19) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	t_1 = -1.0 - ((y * -2.0) / x)
	t_2 = y / (y - 2.0)
	tmp = 0
	if x <= -5e+110:
		tmp = t_1
	elif x <= -2.25e+86:
		tmp = 1.0
	elif x <= -45.0:
		tmp = t_0
	elif x <= 8.5e-126:
		tmp = t_2
	elif x <= 1.95e-81:
		tmp = t_0
	elif x <= 5.8e+19:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	t_1 = Float64(-1.0 - Float64(Float64(y * -2.0) / x))
	t_2 = Float64(y / Float64(y - 2.0))
	tmp = 0.0
	if (x <= -5e+110)
		tmp = t_1;
	elseif (x <= -2.25e+86)
		tmp = 1.0;
	elseif (x <= -45.0)
		tmp = t_0;
	elseif (x <= 8.5e-126)
		tmp = t_2;
	elseif (x <= 1.95e-81)
		tmp = t_0;
	elseif (x <= 5.8e+19)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	t_1 = -1.0 - ((y * -2.0) / x);
	t_2 = y / (y - 2.0);
	tmp = 0.0;
	if (x <= -5e+110)
		tmp = t_1;
	elseif (x <= -2.25e+86)
		tmp = 1.0;
	elseif (x <= -45.0)
		tmp = t_0;
	elseif (x <= 8.5e-126)
		tmp = t_2;
	elseif (x <= 1.95e-81)
		tmp = t_0;
	elseif (x <= 5.8e+19)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 - N[(N[(y * -2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5e+110], t$95$1, If[LessEqual[x, -2.25e+86], 1.0, If[LessEqual[x, -45.0], t$95$0, If[LessEqual[x, 8.5e-126], t$95$2, If[LessEqual[x, 1.95e-81], t$95$0, If[LessEqual[x, 5.8e+19], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
t_1 := -1 - \frac{y \cdot -2}{x}\\
t_2 := \frac{y}{y - 2}\\
\mathbf{if}\;x \leq -5 \cdot 10^{+110}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -2.25 \cdot 10^{+86}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -45:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-126}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.95 \cdot 10^{-81}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 5.8 \cdot 10^{+19}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.99999999999999978e110 or 5.8e19 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 86.2%

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

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

        \[\leadsto \color{blue}{\left(-\left(1 + -1 \cdot \frac{y - 2}{x}\right)\right) + \frac{y}{x}} \]
      3. distribute-neg-in86.2%

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

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

        \[\leadsto \left(-1 + \left(-\color{blue}{\left(-\frac{y - 2}{x}\right)}\right)\right) + \frac{y}{x} \]
      6. remove-double-neg86.2%

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

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

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

        \[\leadsto -1 + \left(\left(-\color{blue}{-1 \cdot \frac{y - 2}{x}}\right) + \frac{y}{x}\right) \]
      10. neg-sub086.3%

        \[\leadsto -1 + \left(\color{blue}{\left(0 - -1 \cdot \frac{y - 2}{x}\right)} + \frac{y}{x}\right) \]
      11. associate--r-86.3%

        \[\leadsto -1 + \color{blue}{\left(0 - \left(-1 \cdot \frac{y - 2}{x} - \frac{y}{x}\right)\right)} \]
      12. associate-*r/86.3%

        \[\leadsto -1 + \left(0 - \left(\color{blue}{\frac{-1 \cdot \left(y - 2\right)}{x}} - \frac{y}{x}\right)\right) \]
      13. sub-neg86.3%

        \[\leadsto -1 + \left(0 - \left(\frac{-1 \cdot \color{blue}{\left(y + \left(-2\right)\right)}}{x} - \frac{y}{x}\right)\right) \]
      14. metadata-eval86.3%

        \[\leadsto -1 + \left(0 - \left(\frac{-1 \cdot \left(y + \color{blue}{-2}\right)}{x} - \frac{y}{x}\right)\right) \]
      15. +-commutative86.3%

        \[\leadsto -1 + \left(0 - \left(\frac{-1 \cdot \color{blue}{\left(-2 + y\right)}}{x} - \frac{y}{x}\right)\right) \]
      16. distribute-lft-in86.3%

        \[\leadsto -1 + \left(0 - \left(\frac{\color{blue}{-1 \cdot -2 + -1 \cdot y}}{x} - \frac{y}{x}\right)\right) \]
      17. metadata-eval86.3%

        \[\leadsto -1 + \left(0 - \left(\frac{\color{blue}{2} + -1 \cdot y}{x} - \frac{y}{x}\right)\right) \]
      18. div-sub86.3%

        \[\leadsto -1 + \left(0 - \color{blue}{\frac{\left(2 + -1 \cdot y\right) - y}{x}}\right) \]
    7. Simplified86.3%

      \[\leadsto \color{blue}{-1 - \frac{2 + y \cdot -2}{x}} \]
    8. Taylor expanded in y around inf 86.3%

      \[\leadsto -1 - \color{blue}{-2 \cdot \frac{y}{x}} \]
    9. Step-by-step derivation
      1. associate-*r/86.3%

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

        \[\leadsto -1 - \frac{\color{blue}{y \cdot -2}}{x} \]
    10. Simplified86.3%

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

    if -4.99999999999999978e110 < x < -2.24999999999999996e86

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 100.0%

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

    if -2.24999999999999996e86 < x < -45 or 8.49999999999999938e-126 < x < 1.94999999999999992e-81

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{x - 2}} \]
    6. Step-by-step derivation
      1. mul-1-neg78.7%

        \[\leadsto \color{blue}{-\frac{x}{x - 2}} \]
      2. distribute-neg-frac278.7%

        \[\leadsto \color{blue}{\frac{x}{-\left(x - 2\right)}} \]
      3. neg-sub078.7%

        \[\leadsto \frac{x}{\color{blue}{0 - \left(x - 2\right)}} \]
      4. associate-+l-78.7%

        \[\leadsto \frac{x}{\color{blue}{\left(0 - x\right) + 2}} \]
      5. neg-sub078.7%

        \[\leadsto \frac{x}{\color{blue}{\left(-x\right)} + 2} \]
      6. +-commutative78.7%

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

        \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
    7. Simplified78.7%

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

    if -45 < x < 8.49999999999999938e-126 or 1.94999999999999992e-81 < x < 5.8e19

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg99.9%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac299.9%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg99.9%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg99.9%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in99.9%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg99.9%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative99.9%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg99.9%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub099.9%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-99.9%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval99.9%

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

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative99.9%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+99.9%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval99.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+110}:\\ \;\;\;\;-1 - \frac{y \cdot -2}{x}\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{+86}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -45:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-126}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-81}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{+19}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{else}:\\ \;\;\;\;-1 - \frac{y \cdot -2}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 71.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y - 2}\\ t_1 := \frac{x}{2 - x}\\ \mathbf{if}\;x \leq -4.5 \cdot 10^{+110}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+86}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -6.5 \cdot 10^{-15}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-126}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+29}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (- y 2.0))) (t_1 (/ x (- 2.0 x))))
   (if (<= x -4.5e+110)
     -1.0
     (if (<= x -2e+86)
       1.0
       (if (<= x -6.5e-15)
         t_1
         (if (<= x 8.5e-126)
           t_0
           (if (<= x 1.75e-81) t_1 (if (<= x 3e+29) t_0 -1.0))))))))
double code(double x, double y) {
	double t_0 = y / (y - 2.0);
	double t_1 = x / (2.0 - x);
	double tmp;
	if (x <= -4.5e+110) {
		tmp = -1.0;
	} else if (x <= -2e+86) {
		tmp = 1.0;
	} else if (x <= -6.5e-15) {
		tmp = t_1;
	} else if (x <= 8.5e-126) {
		tmp = t_0;
	} else if (x <= 1.75e-81) {
		tmp = t_1;
	} else if (x <= 3e+29) {
		tmp = t_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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y / (y - 2.0d0)
    t_1 = x / (2.0d0 - x)
    if (x <= (-4.5d+110)) then
        tmp = -1.0d0
    else if (x <= (-2d+86)) then
        tmp = 1.0d0
    else if (x <= (-6.5d-15)) then
        tmp = t_1
    else if (x <= 8.5d-126) then
        tmp = t_0
    else if (x <= 1.75d-81) then
        tmp = t_1
    else if (x <= 3d+29) 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 / (y - 2.0);
	double t_1 = x / (2.0 - x);
	double tmp;
	if (x <= -4.5e+110) {
		tmp = -1.0;
	} else if (x <= -2e+86) {
		tmp = 1.0;
	} else if (x <= -6.5e-15) {
		tmp = t_1;
	} else if (x <= 8.5e-126) {
		tmp = t_0;
	} else if (x <= 1.75e-81) {
		tmp = t_1;
	} else if (x <= 3e+29) {
		tmp = t_0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (y - 2.0)
	t_1 = x / (2.0 - x)
	tmp = 0
	if x <= -4.5e+110:
		tmp = -1.0
	elif x <= -2e+86:
		tmp = 1.0
	elif x <= -6.5e-15:
		tmp = t_1
	elif x <= 8.5e-126:
		tmp = t_0
	elif x <= 1.75e-81:
		tmp = t_1
	elif x <= 3e+29:
		tmp = t_0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(y - 2.0))
	t_1 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (x <= -4.5e+110)
		tmp = -1.0;
	elseif (x <= -2e+86)
		tmp = 1.0;
	elseif (x <= -6.5e-15)
		tmp = t_1;
	elseif (x <= 8.5e-126)
		tmp = t_0;
	elseif (x <= 1.75e-81)
		tmp = t_1;
	elseif (x <= 3e+29)
		tmp = t_0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (y - 2.0);
	t_1 = x / (2.0 - x);
	tmp = 0.0;
	if (x <= -4.5e+110)
		tmp = -1.0;
	elseif (x <= -2e+86)
		tmp = 1.0;
	elseif (x <= -6.5e-15)
		tmp = t_1;
	elseif (x <= 8.5e-126)
		tmp = t_0;
	elseif (x <= 1.75e-81)
		tmp = t_1;
	elseif (x <= 3e+29)
		tmp = t_0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.5e+110], -1.0, If[LessEqual[x, -2e+86], 1.0, If[LessEqual[x, -6.5e-15], t$95$1, If[LessEqual[x, 8.5e-126], t$95$0, If[LessEqual[x, 1.75e-81], t$95$1, If[LessEqual[x, 3e+29], t$95$0, -1.0]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;x \leq -4.5 \cdot 10^{+110}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -2 \cdot 10^{+86}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -6.5 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-126}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.75 \cdot 10^{-81}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 3 \cdot 10^{+29}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.5000000000000003e110 or 2.9999999999999999e29 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 85.8%

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

    if -4.5000000000000003e110 < x < -2e86

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 100.0%

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

    if -2e86 < x < -6.49999999999999991e-15 or 8.49999999999999938e-126 < x < 1.74999999999999993e-81

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{x - 2}} \]
    6. Step-by-step derivation
      1. mul-1-neg78.7%

        \[\leadsto \color{blue}{-\frac{x}{x - 2}} \]
      2. distribute-neg-frac278.7%

        \[\leadsto \color{blue}{\frac{x}{-\left(x - 2\right)}} \]
      3. neg-sub078.7%

        \[\leadsto \frac{x}{\color{blue}{0 - \left(x - 2\right)}} \]
      4. associate-+l-78.7%

        \[\leadsto \frac{x}{\color{blue}{\left(0 - x\right) + 2}} \]
      5. neg-sub078.7%

        \[\leadsto \frac{x}{\color{blue}{\left(-x\right)} + 2} \]
      6. +-commutative78.7%

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

        \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
    7. Simplified78.7%

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

    if -6.49999999999999991e-15 < x < 8.49999999999999938e-126 or 1.74999999999999993e-81 < x < 2.9999999999999999e29

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+110}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+86}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -6.5 \cdot 10^{-15}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-126}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+29}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 60.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+110}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{+83}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3250000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-126}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -4.5e+110)
   -1.0
   (if (<= x -7.5e+83)
     1.0
     (if (<= x -3250000.0)
       -1.0
       (if (<= x 1.2e-126)
         1.0
         (if (<= x 1.75e-81) (* x 0.5) (if (<= x 2.4e+19) 1.0 -1.0)))))))
double code(double x, double y) {
	double tmp;
	if (x <= -4.5e+110) {
		tmp = -1.0;
	} else if (x <= -7.5e+83) {
		tmp = 1.0;
	} else if (x <= -3250000.0) {
		tmp = -1.0;
	} else if (x <= 1.2e-126) {
		tmp = 1.0;
	} else if (x <= 1.75e-81) {
		tmp = x * 0.5;
	} else if (x <= 2.4e+19) {
		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 <= (-4.5d+110)) then
        tmp = -1.0d0
    else if (x <= (-7.5d+83)) then
        tmp = 1.0d0
    else if (x <= (-3250000.0d0)) then
        tmp = -1.0d0
    else if (x <= 1.2d-126) then
        tmp = 1.0d0
    else if (x <= 1.75d-81) then
        tmp = x * 0.5d0
    else if (x <= 2.4d+19) 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 <= -4.5e+110) {
		tmp = -1.0;
	} else if (x <= -7.5e+83) {
		tmp = 1.0;
	} else if (x <= -3250000.0) {
		tmp = -1.0;
	} else if (x <= 1.2e-126) {
		tmp = 1.0;
	} else if (x <= 1.75e-81) {
		tmp = x * 0.5;
	} else if (x <= 2.4e+19) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -4.5e+110:
		tmp = -1.0
	elif x <= -7.5e+83:
		tmp = 1.0
	elif x <= -3250000.0:
		tmp = -1.0
	elif x <= 1.2e-126:
		tmp = 1.0
	elif x <= 1.75e-81:
		tmp = x * 0.5
	elif x <= 2.4e+19:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -4.5e+110)
		tmp = -1.0;
	elseif (x <= -7.5e+83)
		tmp = 1.0;
	elseif (x <= -3250000.0)
		tmp = -1.0;
	elseif (x <= 1.2e-126)
		tmp = 1.0;
	elseif (x <= 1.75e-81)
		tmp = Float64(x * 0.5);
	elseif (x <= 2.4e+19)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -4.5e+110)
		tmp = -1.0;
	elseif (x <= -7.5e+83)
		tmp = 1.0;
	elseif (x <= -3250000.0)
		tmp = -1.0;
	elseif (x <= 1.2e-126)
		tmp = 1.0;
	elseif (x <= 1.75e-81)
		tmp = x * 0.5;
	elseif (x <= 2.4e+19)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -4.5e+110], -1.0, If[LessEqual[x, -7.5e+83], 1.0, If[LessEqual[x, -3250000.0], -1.0, If[LessEqual[x, 1.2e-126], 1.0, If[LessEqual[x, 1.75e-81], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2.4e+19], 1.0, -1.0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{+110}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -7.5 \cdot 10^{+83}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -3250000:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-126}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 1.75 \cdot 10^{-81}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 2.4 \cdot 10^{+19}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.5000000000000003e110 or -7.49999999999999989e83 < x < -3.25e6 or 2.4e19 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 84.6%

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

    if -4.5000000000000003e110 < x < -7.49999999999999989e83 or -3.25e6 < x < 1.20000000000000003e-126 or 1.74999999999999993e-81 < x < 2.4e19

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 59.0%

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

    if 1.20000000000000003e-126 < x < 1.74999999999999993e-81

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{-\left(x - 2\right)}} \]
      3. neg-sub074.2%

        \[\leadsto \frac{x}{\color{blue}{0 - \left(x - 2\right)}} \]
      4. associate-+l-74.2%

        \[\leadsto \frac{x}{\color{blue}{\left(0 - x\right) + 2}} \]
      5. neg-sub074.2%

        \[\leadsto \frac{x}{\color{blue}{\left(-x\right)} + 2} \]
      6. +-commutative74.2%

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

        \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
    7. Simplified74.2%

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

      \[\leadsto \color{blue}{0.5 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative74.2%

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    10. Simplified74.2%

      \[\leadsto \color{blue}{x \cdot 0.5} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+110}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{+83}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3250000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-126}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 72.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -4 \cdot 10^{+84}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-160}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{-196}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+42}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -4e+84)
     1.0
     (if (<= y -1.6e-160)
       t_0
       (if (<= y -4.6e-196) (* y -0.5) (if (<= y 1.2e+42) t_0 1.0))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -4e+84) {
		tmp = 1.0;
	} else if (y <= -1.6e-160) {
		tmp = t_0;
	} else if (y <= -4.6e-196) {
		tmp = y * -0.5;
	} else if (y <= 1.2e+42) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = x / (2.0d0 - x)
    if (y <= (-4d+84)) then
        tmp = 1.0d0
    else if (y <= (-1.6d-160)) then
        tmp = t_0
    else if (y <= (-4.6d-196)) then
        tmp = y * (-0.5d0)
    else if (y <= 1.2d+42) 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 = x / (2.0 - x);
	double tmp;
	if (y <= -4e+84) {
		tmp = 1.0;
	} else if (y <= -1.6e-160) {
		tmp = t_0;
	} else if (y <= -4.6e-196) {
		tmp = y * -0.5;
	} else if (y <= 1.2e+42) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -4e+84:
		tmp = 1.0
	elif y <= -1.6e-160:
		tmp = t_0
	elif y <= -4.6e-196:
		tmp = y * -0.5
	elif y <= 1.2e+42:
		tmp = t_0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -4e+84)
		tmp = 1.0;
	elseif (y <= -1.6e-160)
		tmp = t_0;
	elseif (y <= -4.6e-196)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.2e+42)
		tmp = t_0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -4e+84)
		tmp = 1.0;
	elseif (y <= -1.6e-160)
		tmp = t_0;
	elseif (y <= -4.6e-196)
		tmp = y * -0.5;
	elseif (y <= 1.2e+42)
		tmp = t_0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4e+84], 1.0, If[LessEqual[y, -1.6e-160], t$95$0, If[LessEqual[y, -4.6e-196], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.2e+42], t$95$0, 1.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -4 \cdot 10^{+84}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq -1.6 \cdot 10^{-160}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -4.6 \cdot 10^{-196}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.2 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.00000000000000023e84 or 1.1999999999999999e42 < y

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 83.1%

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

    if -4.00000000000000023e84 < y < -1.60000000000000004e-160 or -4.6000000000000004e-196 < y < 1.1999999999999999e42

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{x - 2}} \]
    6. Step-by-step derivation
      1. mul-1-neg72.5%

        \[\leadsto \color{blue}{-\frac{x}{x - 2}} \]
      2. distribute-neg-frac272.5%

        \[\leadsto \color{blue}{\frac{x}{-\left(x - 2\right)}} \]
      3. neg-sub072.5%

        \[\leadsto \frac{x}{\color{blue}{0 - \left(x - 2\right)}} \]
      4. associate-+l-72.5%

        \[\leadsto \frac{x}{\color{blue}{\left(0 - x\right) + 2}} \]
      5. neg-sub072.5%

        \[\leadsto \frac{x}{\color{blue}{\left(-x\right)} + 2} \]
      6. +-commutative72.5%

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

        \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
    7. Simplified72.5%

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

    if -1.60000000000000004e-160 < y < -4.6000000000000004e-196

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    7. Step-by-step derivation
      1. *-commutative86.0%

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    8. Simplified86.0%

      \[\leadsto \color{blue}{y \cdot -0.5} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{+84}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-160}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{-196}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+42}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+111}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{+86}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3300000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+23}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1e+111)
   -1.0
   (if (<= x -2.1e+86)
     1.0
     (if (<= x -3300000.0) -1.0 (if (<= x 1.95e+23) 1.0 -1.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -1e+111) {
		tmp = -1.0;
	} else if (x <= -2.1e+86) {
		tmp = 1.0;
	} else if (x <= -3300000.0) {
		tmp = -1.0;
	} else if (x <= 1.95e+23) {
		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 <= (-1d+111)) then
        tmp = -1.0d0
    else if (x <= (-2.1d+86)) then
        tmp = 1.0d0
    else if (x <= (-3300000.0d0)) then
        tmp = -1.0d0
    else if (x <= 1.95d+23) 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 <= -1e+111) {
		tmp = -1.0;
	} else if (x <= -2.1e+86) {
		tmp = 1.0;
	} else if (x <= -3300000.0) {
		tmp = -1.0;
	} else if (x <= 1.95e+23) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1e+111:
		tmp = -1.0
	elif x <= -2.1e+86:
		tmp = 1.0
	elif x <= -3300000.0:
		tmp = -1.0
	elif x <= 1.95e+23:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1e+111)
		tmp = -1.0;
	elseif (x <= -2.1e+86)
		tmp = 1.0;
	elseif (x <= -3300000.0)
		tmp = -1.0;
	elseif (x <= 1.95e+23)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1e+111)
		tmp = -1.0;
	elseif (x <= -2.1e+86)
		tmp = 1.0;
	elseif (x <= -3300000.0)
		tmp = -1.0;
	elseif (x <= 1.95e+23)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1e+111], -1.0, If[LessEqual[x, -2.1e+86], 1.0, If[LessEqual[x, -3300000.0], -1.0, If[LessEqual[x, 1.95e+23], 1.0, -1.0]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+111}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -2.1 \cdot 10^{+86}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -3300000:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 1.95 \cdot 10^{+23}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.99999999999999957e110 or -2.0999999999999999e86 < x < -3.3e6 or 1.95e23 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 84.6%

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

    if -9.99999999999999957e110 < x < -2.0999999999999999e86 or -3.3e6 < x < 1.95e23

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
      3. distribute-neg-frac2100.0%

        \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
      4. distribute-frac-neg100.0%

        \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
      5. sub-neg100.0%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      6. distribute-neg-in100.0%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      7. remove-double-neg100.0%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
      9. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
      13. metadata-eval100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
      14. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
      15. +-commutative100.0%

        \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
      16. associate-+r+100.0%

        \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
      17. metadata-eval100.0%

        \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 55.9%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+111}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{+86}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3300000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+23}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 9: 38.0% 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. Step-by-step derivation
    1. remove-double-neg100.0%

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

      \[\leadsto -\left(-\frac{x - y}{2 - \color{blue}{\left(y + x\right)}}\right) \]
    3. distribute-neg-frac2100.0%

      \[\leadsto -\color{blue}{\frac{x - y}{-\left(2 - \left(y + x\right)\right)}} \]
    4. distribute-frac-neg100.0%

      \[\leadsto \color{blue}{\frac{-\left(x - y\right)}{-\left(2 - \left(y + x\right)\right)}} \]
    5. sub-neg100.0%

      \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
    6. distribute-neg-in100.0%

      \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{-\left(2 - \left(y + x\right)\right)} \]
    7. remove-double-neg100.0%

      \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{-\left(2 - \left(y + x\right)\right)} \]
    8. +-commutative100.0%

      \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{-\left(2 - \left(y + x\right)\right)} \]
    9. sub-neg100.0%

      \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
    10. neg-sub0100.0%

      \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
    11. associate--r-100.0%

      \[\leadsto \frac{y - x}{\color{blue}{\left(0 - 2\right) + \left(y + x\right)}} \]
    12. metadata-eval100.0%

      \[\leadsto \frac{y - x}{\color{blue}{-2} + \left(y + x\right)} \]
    13. metadata-eval100.0%

      \[\leadsto \frac{y - x}{\color{blue}{\left(-2\right)} + \left(y + x\right)} \]
    14. +-commutative100.0%

      \[\leadsto \frac{y - x}{\color{blue}{\left(y + x\right) + \left(-2\right)}} \]
    15. +-commutative100.0%

      \[\leadsto \frac{y - x}{\color{blue}{\left(x + y\right)} + \left(-2\right)} \]
    16. associate-+r+100.0%

      \[\leadsto \frac{y - x}{\color{blue}{x + \left(y + \left(-2\right)\right)}} \]
    17. metadata-eval100.0%

      \[\leadsto \frac{y - x}{x + \left(y + \color{blue}{-2}\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 39.9%

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification39.9%

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

Developer target: 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 2024054 
(FPCore (x y)
  :name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
  :precision binary64

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

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