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

Percentage Accurate: 100.0% → 100.0%
Time: 8.9s
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 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. Step-by-step derivation
    1. div-sub99.9%

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

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

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

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

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

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

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

Alternative 2: 60.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+61}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-24}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-96}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-300}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-292}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 2.02 \cdot 10^{-230}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-203}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-186}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-153}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 75000000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.1e+61)
   -1.0
   (if (<= x -2.5e-24)
     1.0
     (if (<= x -6.2e-96)
       (* x 0.5)
       (if (<= x -1.55e-300)
         1.0
         (if (<= x 2.8e-292)
           (* y -0.5)
           (if (<= x 2.02e-230)
             1.0
             (if (<= x 6e-203)
               (* y -0.5)
               (if (<= x 2.7e-186)
                 1.0
                 (if (<= x 6.5e-153)
                   (* x 0.5)
                   (if (<= x 75000000.0) 1.0 -1.0)))))))))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.1e+61) {
		tmp = -1.0;
	} else if (x <= -2.5e-24) {
		tmp = 1.0;
	} else if (x <= -6.2e-96) {
		tmp = x * 0.5;
	} else if (x <= -1.55e-300) {
		tmp = 1.0;
	} else if (x <= 2.8e-292) {
		tmp = y * -0.5;
	} else if (x <= 2.02e-230) {
		tmp = 1.0;
	} else if (x <= 6e-203) {
		tmp = y * -0.5;
	} else if (x <= 2.7e-186) {
		tmp = 1.0;
	} else if (x <= 6.5e-153) {
		tmp = x * 0.5;
	} else if (x <= 75000000.0) {
		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.1d+61)) then
        tmp = -1.0d0
    else if (x <= (-2.5d-24)) then
        tmp = 1.0d0
    else if (x <= (-6.2d-96)) then
        tmp = x * 0.5d0
    else if (x <= (-1.55d-300)) then
        tmp = 1.0d0
    else if (x <= 2.8d-292) then
        tmp = y * (-0.5d0)
    else if (x <= 2.02d-230) then
        tmp = 1.0d0
    else if (x <= 6d-203) then
        tmp = y * (-0.5d0)
    else if (x <= 2.7d-186) then
        tmp = 1.0d0
    else if (x <= 6.5d-153) then
        tmp = x * 0.5d0
    else if (x <= 75000000.0d0) 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.1e+61) {
		tmp = -1.0;
	} else if (x <= -2.5e-24) {
		tmp = 1.0;
	} else if (x <= -6.2e-96) {
		tmp = x * 0.5;
	} else if (x <= -1.55e-300) {
		tmp = 1.0;
	} else if (x <= 2.8e-292) {
		tmp = y * -0.5;
	} else if (x <= 2.02e-230) {
		tmp = 1.0;
	} else if (x <= 6e-203) {
		tmp = y * -0.5;
	} else if (x <= 2.7e-186) {
		tmp = 1.0;
	} else if (x <= 6.5e-153) {
		tmp = x * 0.5;
	} else if (x <= 75000000.0) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.1e+61:
		tmp = -1.0
	elif x <= -2.5e-24:
		tmp = 1.0
	elif x <= -6.2e-96:
		tmp = x * 0.5
	elif x <= -1.55e-300:
		tmp = 1.0
	elif x <= 2.8e-292:
		tmp = y * -0.5
	elif x <= 2.02e-230:
		tmp = 1.0
	elif x <= 6e-203:
		tmp = y * -0.5
	elif x <= 2.7e-186:
		tmp = 1.0
	elif x <= 6.5e-153:
		tmp = x * 0.5
	elif x <= 75000000.0:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.1e+61)
		tmp = -1.0;
	elseif (x <= -2.5e-24)
		tmp = 1.0;
	elseif (x <= -6.2e-96)
		tmp = Float64(x * 0.5);
	elseif (x <= -1.55e-300)
		tmp = 1.0;
	elseif (x <= 2.8e-292)
		tmp = Float64(y * -0.5);
	elseif (x <= 2.02e-230)
		tmp = 1.0;
	elseif (x <= 6e-203)
		tmp = Float64(y * -0.5);
	elseif (x <= 2.7e-186)
		tmp = 1.0;
	elseif (x <= 6.5e-153)
		tmp = Float64(x * 0.5);
	elseif (x <= 75000000.0)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.1e+61)
		tmp = -1.0;
	elseif (x <= -2.5e-24)
		tmp = 1.0;
	elseif (x <= -6.2e-96)
		tmp = x * 0.5;
	elseif (x <= -1.55e-300)
		tmp = 1.0;
	elseif (x <= 2.8e-292)
		tmp = y * -0.5;
	elseif (x <= 2.02e-230)
		tmp = 1.0;
	elseif (x <= 6e-203)
		tmp = y * -0.5;
	elseif (x <= 2.7e-186)
		tmp = 1.0;
	elseif (x <= 6.5e-153)
		tmp = x * 0.5;
	elseif (x <= 75000000.0)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.1e+61], -1.0, If[LessEqual[x, -2.5e-24], 1.0, If[LessEqual[x, -6.2e-96], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -1.55e-300], 1.0, If[LessEqual[x, 2.8e-292], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2.02e-230], 1.0, If[LessEqual[x, 6e-203], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2.7e-186], 1.0, If[LessEqual[x, 6.5e-153], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 75000000.0], 1.0, -1.0]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.5 \cdot 10^{-24}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -6.2 \cdot 10^{-96}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq -1.55 \cdot 10^{-300}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-292}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 2.02 \cdot 10^{-230}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 6 \cdot 10^{-203}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 2.7 \cdot 10^{-186}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 6.5 \cdot 10^{-153}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 75000000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.1e61 or 7.5e7 < x

    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 inf 80.2%

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

    if -1.1e61 < x < -2.4999999999999999e-24 or -6.1999999999999998e-96 < x < -1.5500000000000001e-300 or 2.8000000000000001e-292 < x < 2.0199999999999999e-230 or 6.0000000000000002e-203 < x < 2.6999999999999999e-186 or 6.50000000000000032e-153 < x < 7.5e7

    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 62.9%

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

    if -2.4999999999999999e-24 < x < -6.1999999999999998e-96 or 2.6999999999999999e-186 < x < 6.50000000000000032e-153

    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.6%

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

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

        \[\leadsto \color{blue}{\frac{x}{-\left(x - 2\right)}} \]
      3. sub-neg74.6%

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

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

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

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

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

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

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

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

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

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

    if -1.5500000000000001e-300 < x < 2.8000000000000001e-292 or 2.0199999999999999e-230 < x < 6.0000000000000002e-203

    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 89.1%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+61}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-24}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-96}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-300}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-292}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 2.02 \cdot 10^{-230}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-203}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-186}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-153}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 75000000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y - 2}\\ t_1 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -9.2 \cdot 10^{-24}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-73}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-43}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 11000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+83} \lor \neg \left(y \leq 1.8 \cdot 10^{+117}\right):\\ \;\;\;\;\frac{1}{y} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (- y 2.0))) (t_1 (/ x (- 2.0 x))))
   (if (<= y -9.2e-24)
     t_0
     (if (<= y 3e-73)
       t_1
       (if (<= y 3.6e-43)
         t_0
         (if (<= y 11000000000.0)
           -1.0
           (if (or (<= y 1.3e+83) (not (<= y 1.8e+117)))
             (* (/ 1.0 y) (- y x))
             t_1)))))))
double code(double x, double y) {
	double t_0 = y / (y - 2.0);
	double t_1 = x / (2.0 - x);
	double tmp;
	if (y <= -9.2e-24) {
		tmp = t_0;
	} else if (y <= 3e-73) {
		tmp = t_1;
	} else if (y <= 3.6e-43) {
		tmp = t_0;
	} else if (y <= 11000000000.0) {
		tmp = -1.0;
	} else if ((y <= 1.3e+83) || !(y <= 1.8e+117)) {
		tmp = (1.0 / y) * (y - x);
	} 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) :: tmp
    t_0 = y / (y - 2.0d0)
    t_1 = x / (2.0d0 - x)
    if (y <= (-9.2d-24)) then
        tmp = t_0
    else if (y <= 3d-73) then
        tmp = t_1
    else if (y <= 3.6d-43) then
        tmp = t_0
    else if (y <= 11000000000.0d0) then
        tmp = -1.0d0
    else if ((y <= 1.3d+83) .or. (.not. (y <= 1.8d+117))) then
        tmp = (1.0d0 / y) * (y - x)
    else
        tmp = t_1
    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 (y <= -9.2e-24) {
		tmp = t_0;
	} else if (y <= 3e-73) {
		tmp = t_1;
	} else if (y <= 3.6e-43) {
		tmp = t_0;
	} else if (y <= 11000000000.0) {
		tmp = -1.0;
	} else if ((y <= 1.3e+83) || !(y <= 1.8e+117)) {
		tmp = (1.0 / y) * (y - x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (y - 2.0)
	t_1 = x / (2.0 - x)
	tmp = 0
	if y <= -9.2e-24:
		tmp = t_0
	elif y <= 3e-73:
		tmp = t_1
	elif y <= 3.6e-43:
		tmp = t_0
	elif y <= 11000000000.0:
		tmp = -1.0
	elif (y <= 1.3e+83) or not (y <= 1.8e+117):
		tmp = (1.0 / y) * (y - x)
	else:
		tmp = t_1
	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 (y <= -9.2e-24)
		tmp = t_0;
	elseif (y <= 3e-73)
		tmp = t_1;
	elseif (y <= 3.6e-43)
		tmp = t_0;
	elseif (y <= 11000000000.0)
		tmp = -1.0;
	elseif ((y <= 1.3e+83) || !(y <= 1.8e+117))
		tmp = Float64(Float64(1.0 / y) * Float64(y - x));
	else
		tmp = t_1;
	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 (y <= -9.2e-24)
		tmp = t_0;
	elseif (y <= 3e-73)
		tmp = t_1;
	elseif (y <= 3.6e-43)
		tmp = t_0;
	elseif (y <= 11000000000.0)
		tmp = -1.0;
	elseif ((y <= 1.3e+83) || ~((y <= 1.8e+117)))
		tmp = (1.0 / y) * (y - x);
	else
		tmp = t_1;
	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[y, -9.2e-24], t$95$0, If[LessEqual[y, 3e-73], t$95$1, If[LessEqual[y, 3.6e-43], t$95$0, If[LessEqual[y, 11000000000.0], -1.0, If[Or[LessEqual[y, 1.3e+83], N[Not[LessEqual[y, 1.8e+117]], $MachinePrecision]], N[(N[(1.0 / y), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -9.2 \cdot 10^{-24}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 3 \cdot 10^{-73}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 3.6 \cdot 10^{-43}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 11000000000:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{+83} \lor \neg \left(y \leq 1.8 \cdot 10^{+117}\right):\\
\;\;\;\;\frac{1}{y} \cdot \left(y - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -9.2000000000000004e-24 or 3e-73 < y < 3.5999999999999999e-43

    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 76.9%

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

    if -9.2000000000000004e-24 < y < 3e-73 or 1.3000000000000001e83 < y < 1.80000000000000006e117

    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 86.0%

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

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

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

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

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

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

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

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

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

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

    if 3.5999999999999999e-43 < y < 1.1e10

    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 79.7%

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

    if 1.1e10 < y < 1.3000000000000001e83 or 1.80000000000000006e117 < y

    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. Step-by-step derivation
      1. clear-num99.9%

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

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

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

        \[\leadsto \frac{1}{\color{blue}{y + \left(-2 + x\right)}} \cdot \left(y - x\right) \]
    6. Applied egg-rr99.7%

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

      \[\leadsto \color{blue}{\frac{1}{y}} \cdot \left(y - x\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification82.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{-24}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-73}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-43}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{elif}\;y \leq 11000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+83} \lor \neg \left(y \leq 1.8 \cdot 10^{+117}\right):\\ \;\;\;\;\frac{1}{y} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -7.2 \cdot 10^{+31}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-73}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-43}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 2000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{+83}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+118}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -7.2e+31)
     1.0
     (if (<= y 8.5e-73)
       t_0
       (if (<= y 3.3e-43)
         (* y -0.5)
         (if (<= y 2000000000.0)
           -1.0
           (if (<= y 1.16e+83) 1.0 (if (<= y 2.8e+118) t_0 1.0))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -7.2e+31) {
		tmp = 1.0;
	} else if (y <= 8.5e-73) {
		tmp = t_0;
	} else if (y <= 3.3e-43) {
		tmp = y * -0.5;
	} else if (y <= 2000000000.0) {
		tmp = -1.0;
	} else if (y <= 1.16e+83) {
		tmp = 1.0;
	} else if (y <= 2.8e+118) {
		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 <= (-7.2d+31)) then
        tmp = 1.0d0
    else if (y <= 8.5d-73) then
        tmp = t_0
    else if (y <= 3.3d-43) then
        tmp = y * (-0.5d0)
    else if (y <= 2000000000.0d0) then
        tmp = -1.0d0
    else if (y <= 1.16d+83) then
        tmp = 1.0d0
    else if (y <= 2.8d+118) 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 <= -7.2e+31) {
		tmp = 1.0;
	} else if (y <= 8.5e-73) {
		tmp = t_0;
	} else if (y <= 3.3e-43) {
		tmp = y * -0.5;
	} else if (y <= 2000000000.0) {
		tmp = -1.0;
	} else if (y <= 1.16e+83) {
		tmp = 1.0;
	} else if (y <= 2.8e+118) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -7.2e+31:
		tmp = 1.0
	elif y <= 8.5e-73:
		tmp = t_0
	elif y <= 3.3e-43:
		tmp = y * -0.5
	elif y <= 2000000000.0:
		tmp = -1.0
	elif y <= 1.16e+83:
		tmp = 1.0
	elif y <= 2.8e+118:
		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 <= -7.2e+31)
		tmp = 1.0;
	elseif (y <= 8.5e-73)
		tmp = t_0;
	elseif (y <= 3.3e-43)
		tmp = Float64(y * -0.5);
	elseif (y <= 2000000000.0)
		tmp = -1.0;
	elseif (y <= 1.16e+83)
		tmp = 1.0;
	elseif (y <= 2.8e+118)
		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 <= -7.2e+31)
		tmp = 1.0;
	elseif (y <= 8.5e-73)
		tmp = t_0;
	elseif (y <= 3.3e-43)
		tmp = y * -0.5;
	elseif (y <= 2000000000.0)
		tmp = -1.0;
	elseif (y <= 1.16e+83)
		tmp = 1.0;
	elseif (y <= 2.8e+118)
		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, -7.2e+31], 1.0, If[LessEqual[y, 8.5e-73], t$95$0, If[LessEqual[y, 3.3e-43], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2000000000.0], -1.0, If[LessEqual[y, 1.16e+83], 1.0, If[LessEqual[y, 2.8e+118], t$95$0, 1.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 8.5 \cdot 10^{-73}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 3.3 \cdot 10^{-43}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 2000000000:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 1.16 \cdot 10^{+83}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 2.8 \cdot 10^{+118}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -7.19999999999999992e31 or 2e9 < y < 1.1600000000000001e83 or 2.79999999999999986e118 < y

    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 y around inf 81.0%

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

    if -7.19999999999999992e31 < y < 8.4999999999999996e-73 or 1.1600000000000001e83 < y < 2.79999999999999986e118

    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 80.9%

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

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

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

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

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

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

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

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

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

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

    if 8.4999999999999996e-73 < y < 3.30000000000000016e-43

    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 79.3%

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

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

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

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

    if 3.30000000000000016e-43 < y < 2e9

    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 79.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{+31}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-73}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-43}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 2000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{+83}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+118}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 72.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y - 2}\\ t_1 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -6.8 \cdot 10^{-24}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-75}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-43}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1400000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+79}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+117}:\\ \;\;\;\;t\_1\\ \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 (<= y -6.8e-24)
     t_0
     (if (<= y 2.35e-75)
       t_1
       (if (<= y 3.3e-43)
         t_0
         (if (<= y 1400000000000.0)
           -1.0
           (if (<= y 3.5e+79) t_0 (if (<= y 1.6e+117) t_1 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 (y <= -6.8e-24) {
		tmp = t_0;
	} else if (y <= 2.35e-75) {
		tmp = t_1;
	} else if (y <= 3.3e-43) {
		tmp = t_0;
	} else if (y <= 1400000000000.0) {
		tmp = -1.0;
	} else if (y <= 3.5e+79) {
		tmp = t_0;
	} else if (y <= 1.6e+117) {
		tmp = t_1;
	} 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 (y <= (-6.8d-24)) then
        tmp = t_0
    else if (y <= 2.35d-75) then
        tmp = t_1
    else if (y <= 3.3d-43) then
        tmp = t_0
    else if (y <= 1400000000000.0d0) then
        tmp = -1.0d0
    else if (y <= 3.5d+79) then
        tmp = t_0
    else if (y <= 1.6d+117) then
        tmp = t_1
    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 (y <= -6.8e-24) {
		tmp = t_0;
	} else if (y <= 2.35e-75) {
		tmp = t_1;
	} else if (y <= 3.3e-43) {
		tmp = t_0;
	} else if (y <= 1400000000000.0) {
		tmp = -1.0;
	} else if (y <= 3.5e+79) {
		tmp = t_0;
	} else if (y <= 1.6e+117) {
		tmp = t_1;
	} 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 y <= -6.8e-24:
		tmp = t_0
	elif y <= 2.35e-75:
		tmp = t_1
	elif y <= 3.3e-43:
		tmp = t_0
	elif y <= 1400000000000.0:
		tmp = -1.0
	elif y <= 3.5e+79:
		tmp = t_0
	elif y <= 1.6e+117:
		tmp = t_1
	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 (y <= -6.8e-24)
		tmp = t_0;
	elseif (y <= 2.35e-75)
		tmp = t_1;
	elseif (y <= 3.3e-43)
		tmp = t_0;
	elseif (y <= 1400000000000.0)
		tmp = -1.0;
	elseif (y <= 3.5e+79)
		tmp = t_0;
	elseif (y <= 1.6e+117)
		tmp = t_1;
	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 (y <= -6.8e-24)
		tmp = t_0;
	elseif (y <= 2.35e-75)
		tmp = t_1;
	elseif (y <= 3.3e-43)
		tmp = t_0;
	elseif (y <= 1400000000000.0)
		tmp = -1.0;
	elseif (y <= 3.5e+79)
		tmp = t_0;
	elseif (y <= 1.6e+117)
		tmp = t_1;
	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[y, -6.8e-24], t$95$0, If[LessEqual[y, 2.35e-75], t$95$1, If[LessEqual[y, 3.3e-43], t$95$0, If[LessEqual[y, 1400000000000.0], -1.0, If[LessEqual[y, 3.5e+79], t$95$0, If[LessEqual[y, 1.6e+117], t$95$1, 1.0]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -6.8 \cdot 10^{-24}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 2.35 \cdot 10^{-75}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 3.3 \cdot 10^{-43}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1400000000000:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -6.79999999999999985e-24 or 2.3499999999999999e-75 < y < 3.30000000000000016e-43 or 1.4e12 < y < 3.4999999999999998e79

    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 76.0%

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

    if -6.79999999999999985e-24 < y < 2.3499999999999999e-75 or 3.4999999999999998e79 < y < 1.60000000000000002e117

    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 86.0%

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

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

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

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

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

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

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

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

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

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

    if 3.30000000000000016e-43 < y < 1.4e12

    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 79.7%

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

    if 1.60000000000000002e117 < 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 87.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-24}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-75}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-43}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{elif}\;y \leq 1400000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+117}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{+60}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-22}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-96}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-186}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-152}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 52000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -7.5e+60)
   -1.0
   (if (<= x -2e-22)
     1.0
     (if (<= x -6e-96)
       (* x 0.5)
       (if (<= x 1.2e-186)
         1.0
         (if (<= x 1.25e-152) (* x 0.5) (if (<= x 52000.0) 1.0 -1.0)))))))
double code(double x, double y) {
	double tmp;
	if (x <= -7.5e+60) {
		tmp = -1.0;
	} else if (x <= -2e-22) {
		tmp = 1.0;
	} else if (x <= -6e-96) {
		tmp = x * 0.5;
	} else if (x <= 1.2e-186) {
		tmp = 1.0;
	} else if (x <= 1.25e-152) {
		tmp = x * 0.5;
	} else if (x <= 52000.0) {
		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 <= (-7.5d+60)) then
        tmp = -1.0d0
    else if (x <= (-2d-22)) then
        tmp = 1.0d0
    else if (x <= (-6d-96)) then
        tmp = x * 0.5d0
    else if (x <= 1.2d-186) then
        tmp = 1.0d0
    else if (x <= 1.25d-152) then
        tmp = x * 0.5d0
    else if (x <= 52000.0d0) 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 <= -7.5e+60) {
		tmp = -1.0;
	} else if (x <= -2e-22) {
		tmp = 1.0;
	} else if (x <= -6e-96) {
		tmp = x * 0.5;
	} else if (x <= 1.2e-186) {
		tmp = 1.0;
	} else if (x <= 1.25e-152) {
		tmp = x * 0.5;
	} else if (x <= 52000.0) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -7.5e+60:
		tmp = -1.0
	elif x <= -2e-22:
		tmp = 1.0
	elif x <= -6e-96:
		tmp = x * 0.5
	elif x <= 1.2e-186:
		tmp = 1.0
	elif x <= 1.25e-152:
		tmp = x * 0.5
	elif x <= 52000.0:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -7.5e+60)
		tmp = -1.0;
	elseif (x <= -2e-22)
		tmp = 1.0;
	elseif (x <= -6e-96)
		tmp = Float64(x * 0.5);
	elseif (x <= 1.2e-186)
		tmp = 1.0;
	elseif (x <= 1.25e-152)
		tmp = Float64(x * 0.5);
	elseif (x <= 52000.0)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -7.5e+60)
		tmp = -1.0;
	elseif (x <= -2e-22)
		tmp = 1.0;
	elseif (x <= -6e-96)
		tmp = x * 0.5;
	elseif (x <= 1.2e-186)
		tmp = 1.0;
	elseif (x <= 1.25e-152)
		tmp = x * 0.5;
	elseif (x <= 52000.0)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -7.5e+60], -1.0, If[LessEqual[x, -2e-22], 1.0, If[LessEqual[x, -6e-96], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.2e-186], 1.0, If[LessEqual[x, 1.25e-152], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 52000.0], 1.0, -1.0]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq -6 \cdot 10^{-96}:\\
\;\;\;\;x \cdot 0.5\\

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

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-152}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 52000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.5e60 or 52000 < x

    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 inf 80.2%

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

    if -7.5e60 < x < -2.0000000000000001e-22 or -6e-96 < x < 1.20000000000000002e-186 or 1.2499999999999999e-152 < x < 52000

    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 57.1%

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

    if -2.0000000000000001e-22 < x < -6e-96 or 1.20000000000000002e-186 < x < 1.2499999999999999e-152

    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.6%

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

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

        \[\leadsto \color{blue}{\frac{x}{-\left(x - 2\right)}} \]
      3. sub-neg74.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{+60}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-22}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-96}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-186}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-152}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 52000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 62.5% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 52000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.79999999999999999e60 or 52000 < x

    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 inf 80.2%

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

    if -5.79999999999999999e60 < x < 52000

    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 51.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{+60}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 52000:\\ \;\;\;\;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 99.9%

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

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

Alternative 9: 38.5% 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 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 inf 39.6%

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

    \[\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 2024046 
(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))))