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

Percentage Accurate: 100.0% → 100.0%
Time: 8.1s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 70.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ t_1 := \left(y - x\right) \cdot -0.5\\ \mathbf{if}\;y \leq -0.68:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-80}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-130}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 5.9 \cdot 10^{-108}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+46} \lor \neg \left(y \leq 8.5 \cdot 10^{+91}\right) \land y \leq 8 \cdot 10^{+154}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))) (t_1 (* (- y x) -0.5)))
   (if (<= y -0.68)
     1.0
     (if (<= y -2.9e-80)
       t_1
       (if (<= y 5e-130)
         t_0
         (if (<= y 5.9e-108)
           t_1
           (if (or (<= y 6.5e+46) (and (not (<= y 8.5e+91)) (<= y 8e+154)))
             t_0
             1.0)))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double t_1 = (y - x) * -0.5;
	double tmp;
	if (y <= -0.68) {
		tmp = 1.0;
	} else if (y <= -2.9e-80) {
		tmp = t_1;
	} else if (y <= 5e-130) {
		tmp = t_0;
	} else if (y <= 5.9e-108) {
		tmp = t_1;
	} else if ((y <= 6.5e+46) || (!(y <= 8.5e+91) && (y <= 8e+154))) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x / (2.0d0 - x)
    t_1 = (y - x) * (-0.5d0)
    if (y <= (-0.68d0)) then
        tmp = 1.0d0
    else if (y <= (-2.9d-80)) then
        tmp = t_1
    else if (y <= 5d-130) then
        tmp = t_0
    else if (y <= 5.9d-108) then
        tmp = t_1
    else if ((y <= 6.5d+46) .or. (.not. (y <= 8.5d+91)) .and. (y <= 8d+154)) 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 t_1 = (y - x) * -0.5;
	double tmp;
	if (y <= -0.68) {
		tmp = 1.0;
	} else if (y <= -2.9e-80) {
		tmp = t_1;
	} else if (y <= 5e-130) {
		tmp = t_0;
	} else if (y <= 5.9e-108) {
		tmp = t_1;
	} else if ((y <= 6.5e+46) || (!(y <= 8.5e+91) && (y <= 8e+154))) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	t_1 = (y - x) * -0.5
	tmp = 0
	if y <= -0.68:
		tmp = 1.0
	elif y <= -2.9e-80:
		tmp = t_1
	elif y <= 5e-130:
		tmp = t_0
	elif y <= 5.9e-108:
		tmp = t_1
	elif (y <= 6.5e+46) or (not (y <= 8.5e+91) and (y <= 8e+154)):
		tmp = t_0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	t_1 = Float64(Float64(y - x) * -0.5)
	tmp = 0.0
	if (y <= -0.68)
		tmp = 1.0;
	elseif (y <= -2.9e-80)
		tmp = t_1;
	elseif (y <= 5e-130)
		tmp = t_0;
	elseif (y <= 5.9e-108)
		tmp = t_1;
	elseif ((y <= 6.5e+46) || (!(y <= 8.5e+91) && (y <= 8e+154)))
		tmp = t_0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	t_1 = (y - x) * -0.5;
	tmp = 0.0;
	if (y <= -0.68)
		tmp = 1.0;
	elseif (y <= -2.9e-80)
		tmp = t_1;
	elseif (y <= 5e-130)
		tmp = t_0;
	elseif (y <= 5.9e-108)
		tmp = t_1;
	elseif ((y <= 6.5e+46) || (~((y <= 8.5e+91)) && (y <= 8e+154)))
		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]}, Block[{t$95$1 = N[(N[(y - x), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[y, -0.68], 1.0, If[LessEqual[y, -2.9e-80], t$95$1, If[LessEqual[y, 5e-130], t$95$0, If[LessEqual[y, 5.9e-108], t$95$1, If[Or[LessEqual[y, 6.5e+46], And[N[Not[LessEqual[y, 8.5e+91]], $MachinePrecision], LessEqual[y, 8e+154]]], t$95$0, 1.0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
t_1 := \left(y - x\right) \cdot -0.5\\
\mathbf{if}\;y \leq -0.68:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq -2.9 \cdot 10^{-80}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 5 \cdot 10^{-130}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 5.9 \cdot 10^{-108}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 6.5 \cdot 10^{+46} \lor \neg \left(y \leq 8.5 \cdot 10^{+91}\right) \land y \leq 8 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -0.680000000000000049 or 6.50000000000000008e46 < y < 8.4999999999999995e91 or 8.0000000000000003e154 < 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 86.2%

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

    if -0.680000000000000049 < y < -2.89999999999999998e-80 or 4.9999999999999996e-130 < y < 5.89999999999999965e-108

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

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

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

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

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

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

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

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

    if -2.89999999999999998e-80 < y < 4.9999999999999996e-130 or 5.89999999999999965e-108 < y < 6.50000000000000008e46 or 8.4999999999999995e91 < y < 8.0000000000000003e154

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.68:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-80}:\\ \;\;\;\;\left(y - x\right) \cdot -0.5\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-130}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 5.9 \cdot 10^{-108}:\\ \;\;\;\;\left(y - x\right) \cdot -0.5\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+46} \lor \neg \left(y \leq 8.5 \cdot 10^{+91}\right) \land y \leq 8 \cdot 10^{+154}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 62.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y - x\right) \cdot -0.5\\ \mathbf{if}\;x \leq -7 \cdot 10^{+86}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{-128}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-193}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-62}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (- y x) -0.5)))
   (if (<= x -7e+86)
     -1.0
     (if (<= x -2.2e-128)
       1.0
       (if (<= x 5.8e-193)
         t_0
         (if (<= x 1.7e-62) 1.0 (if (<= x 2.0) t_0 -1.0)))))))
double code(double x, double y) {
	double t_0 = (y - x) * -0.5;
	double tmp;
	if (x <= -7e+86) {
		tmp = -1.0;
	} else if (x <= -2.2e-128) {
		tmp = 1.0;
	} else if (x <= 5.8e-193) {
		tmp = t_0;
	} else if (x <= 1.7e-62) {
		tmp = 1.0;
	} else if (x <= 2.0) {
		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 = (y - x) * (-0.5d0)
    if (x <= (-7d+86)) then
        tmp = -1.0d0
    else if (x <= (-2.2d-128)) then
        tmp = 1.0d0
    else if (x <= 5.8d-193) then
        tmp = t_0
    else if (x <= 1.7d-62) then
        tmp = 1.0d0
    else if (x <= 2.0d0) then
        tmp = t_0
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (y - x) * -0.5;
	double tmp;
	if (x <= -7e+86) {
		tmp = -1.0;
	} else if (x <= -2.2e-128) {
		tmp = 1.0;
	} else if (x <= 5.8e-193) {
		tmp = t_0;
	} else if (x <= 1.7e-62) {
		tmp = 1.0;
	} else if (x <= 2.0) {
		tmp = t_0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y - x) * -0.5
	tmp = 0
	if x <= -7e+86:
		tmp = -1.0
	elif x <= -2.2e-128:
		tmp = 1.0
	elif x <= 5.8e-193:
		tmp = t_0
	elif x <= 1.7e-62:
		tmp = 1.0
	elif x <= 2.0:
		tmp = t_0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y - x) * -0.5)
	tmp = 0.0
	if (x <= -7e+86)
		tmp = -1.0;
	elseif (x <= -2.2e-128)
		tmp = 1.0;
	elseif (x <= 5.8e-193)
		tmp = t_0;
	elseif (x <= 1.7e-62)
		tmp = 1.0;
	elseif (x <= 2.0)
		tmp = t_0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y - x) * -0.5;
	tmp = 0.0;
	if (x <= -7e+86)
		tmp = -1.0;
	elseif (x <= -2.2e-128)
		tmp = 1.0;
	elseif (x <= 5.8e-193)
		tmp = t_0;
	elseif (x <= 1.7e-62)
		tmp = 1.0;
	elseif (x <= 2.0)
		tmp = t_0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[x, -7e+86], -1.0, If[LessEqual[x, -2.2e-128], 1.0, If[LessEqual[x, 5.8e-193], t$95$0, If[LessEqual[x, 1.7e-62], 1.0, If[LessEqual[x, 2.0], t$95$0, -1.0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y - x\right) \cdot -0.5\\
\mathbf{if}\;x \leq -7 \cdot 10^{+86}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -2.2 \cdot 10^{-128}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 5.8 \cdot 10^{-193}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.7 \cdot 10^{-62}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 2:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.00000000000000038e86 or 2 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.00000000000000038e86 < x < -2.20000000000000009e-128 or 5.80000000000000013e-193 < x < 1.69999999999999994e-62

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

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

    if -2.20000000000000009e-128 < x < 5.80000000000000013e-193 or 1.69999999999999994e-62 < x < 2

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.5} \cdot \left(y - x\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification73.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+86}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{-128}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-193}:\\ \;\;\;\;\left(y - x\right) \cdot -0.5\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-62}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2:\\ \;\;\;\;\left(y - x\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 60.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-81}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-240}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-306}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+19}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.0)
   1.0
   (if (<= y -5.8e-81)
     (* y -0.5)
     (if (<= y -2.25e-240)
       -1.0
       (if (<= y 3.6e-306) (* x 0.5) (if (<= y 1.5e+19) -1.0 1.0))))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.0) {
		tmp = 1.0;
	} else if (y <= -5.8e-81) {
		tmp = y * -0.5;
	} else if (y <= -2.25e-240) {
		tmp = -1.0;
	} else if (y <= 3.6e-306) {
		tmp = x * 0.5;
	} else if (y <= 1.5e+19) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-2.0d0)) then
        tmp = 1.0d0
    else if (y <= (-5.8d-81)) then
        tmp = y * (-0.5d0)
    else if (y <= (-2.25d-240)) then
        tmp = -1.0d0
    else if (y <= 3.6d-306) then
        tmp = x * 0.5d0
    else if (y <= 1.5d+19) then
        tmp = -1.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.0) {
		tmp = 1.0;
	} else if (y <= -5.8e-81) {
		tmp = y * -0.5;
	} else if (y <= -2.25e-240) {
		tmp = -1.0;
	} else if (y <= 3.6e-306) {
		tmp = x * 0.5;
	} else if (y <= 1.5e+19) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.0:
		tmp = 1.0
	elif y <= -5.8e-81:
		tmp = y * -0.5
	elif y <= -2.25e-240:
		tmp = -1.0
	elif y <= 3.6e-306:
		tmp = x * 0.5
	elif y <= 1.5e+19:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.0)
		tmp = 1.0;
	elseif (y <= -5.8e-81)
		tmp = Float64(y * -0.5);
	elseif (y <= -2.25e-240)
		tmp = -1.0;
	elseif (y <= 3.6e-306)
		tmp = Float64(x * 0.5);
	elseif (y <= 1.5e+19)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.0)
		tmp = 1.0;
	elseif (y <= -5.8e-81)
		tmp = y * -0.5;
	elseif (y <= -2.25e-240)
		tmp = -1.0;
	elseif (y <= 3.6e-306)
		tmp = x * 0.5;
	elseif (y <= 1.5e+19)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.0], 1.0, If[LessEqual[y, -5.8e-81], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -2.25e-240], -1.0, If[LessEqual[y, 3.6e-306], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.5e+19], -1.0, 1.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq -5.8 \cdot 10^{-81}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -2.25 \cdot 10^{-240}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 3.6 \cdot 10^{-306}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{+19}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2 or 1.5e19 < 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 78.4%

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

    if -2 < y < -5.79999999999999978e-81

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

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

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

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

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

    if -5.79999999999999978e-81 < y < -2.2500000000000001e-240 or 3.59999999999999991e-306 < y < 1.5e19

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

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

    if -2.2500000000000001e-240 < y < 3.59999999999999991e-306

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    10. Simplified68.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-81}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-240}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-306}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+19}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 61.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq 1.75 \cdot 10^{+19}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{+100}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 3 \cdot 10^{+134}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.00000000000000005e26 or 1.75e19 < y < 1.5999999999999999e100 or 2.99999999999999997e134 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000005e26 < y < 1.75e19 or 1.5999999999999999e100 < y < 2.99999999999999997e134

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+26}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{+19}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+100}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+134}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 62.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+18}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-240}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-303}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+19}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.1e+18)
   1.0
   (if (<= y -2.25e-240)
     -1.0
     (if (<= y 6.5e-303) (* x 0.5) (if (<= y 1.5e+19) -1.0 1.0)))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.1e+18) {
		tmp = 1.0;
	} else if (y <= -2.25e-240) {
		tmp = -1.0;
	} else if (y <= 6.5e-303) {
		tmp = x * 0.5;
	} else if (y <= 1.5e+19) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-2.1d+18)) then
        tmp = 1.0d0
    else if (y <= (-2.25d-240)) then
        tmp = -1.0d0
    else if (y <= 6.5d-303) then
        tmp = x * 0.5d0
    else if (y <= 1.5d+19) then
        tmp = -1.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.1e+18) {
		tmp = 1.0;
	} else if (y <= -2.25e-240) {
		tmp = -1.0;
	} else if (y <= 6.5e-303) {
		tmp = x * 0.5;
	} else if (y <= 1.5e+19) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.1e+18:
		tmp = 1.0
	elif y <= -2.25e-240:
		tmp = -1.0
	elif y <= 6.5e-303:
		tmp = x * 0.5
	elif y <= 1.5e+19:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.1e+18)
		tmp = 1.0;
	elseif (y <= -2.25e-240)
		tmp = -1.0;
	elseif (y <= 6.5e-303)
		tmp = Float64(x * 0.5);
	elseif (y <= 1.5e+19)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.1e+18)
		tmp = 1.0;
	elseif (y <= -2.25e-240)
		tmp = -1.0;
	elseif (y <= 6.5e-303)
		tmp = x * 0.5;
	elseif (y <= 1.5e+19)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.1e+18], 1.0, If[LessEqual[y, -2.25e-240], -1.0, If[LessEqual[y, 6.5e-303], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.5e+19], -1.0, 1.0]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+18}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq -2.25 \cdot 10^{-240}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;y \leq 1.5 \cdot 10^{+19}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.1e18 or 1.5e19 < 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 78.4%

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

    if -2.1e18 < y < -2.2500000000000001e-240 or 6.50000000000000028e-303 < y < 1.5e19

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

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

    if -2.2500000000000001e-240 < y < 6.50000000000000028e-303

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    10. Simplified68.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+18}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-240}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-303}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+19}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 86.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+86}:\\
\;\;\;\;-1 - \frac{y}{x} \cdot -2\\

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.7999999999999995e86 < x < 0.00440000000000000027

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y - 2} + \frac{y}{y - 2}} \]
    9. Step-by-step derivation
      1. +-commutative92.3%

        \[\leadsto \color{blue}{\frac{y}{y - 2} + -1 \cdot \frac{x}{y - 2}} \]
      2. sub-neg92.3%

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

        \[\leadsto \frac{y}{y + \color{blue}{-2}} + -1 \cdot \frac{x}{y - 2} \]
      4. mul-1-neg92.3%

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

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

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

        \[\leadsto \color{blue}{\frac{y}{y + -2} - \frac{x}{y + -2}} \]
      8. div-sub92.3%

        \[\leadsto \color{blue}{\frac{y - x}{y + -2}} \]
    10. Simplified92.3%

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

    if 0.00440000000000000027 < 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 y around 0 78.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.8 \cdot 10^{+86}:\\ \;\;\;\;-1 - \frac{y}{x} \cdot -2\\ \mathbf{elif}\;x \leq 0.0044:\\ \;\;\;\;\frac{y - x}{y + -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 74.2% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.7999999999999995e86 < x < 1.55e-62

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

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

    if 1.55e-62 < 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 y around 0 78.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.8 \cdot 10^{+86}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-62}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 74.3% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+87}:\\
\;\;\;\;-1 - \frac{y}{x} \cdot -2\\

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.1e87 < x < 9.00000000000000001e-60

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

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

    if 9.00000000000000001e-60 < 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 y around 0 78.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+87}:\\ \;\;\;\;-1 - \frac{y}{x} \cdot -2\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-60}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 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 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 42.4%

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

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