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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 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}
Derivation
  1. Initial program 100.0%

    \[\frac{x - y}{2 - \left(x + y\right)} \]
  2. Step-by-step derivation
    1. associate--r+100.0%

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

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

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

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

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

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

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

Alternative 2: 72.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \frac{x \cdot -2}{y}\\ t_1 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -7200000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-23}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-67}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ 1.0 (/ (* x -2.0) y))) (t_1 (/ x (- 2.0 x))))
   (if (<= y -7200000000.0)
     t_0
     (if (<= y -1.3e-23)
       (+ (/ y x) -1.0)
       (if (<= y -2.25e-67)
         (* y -0.5)
         (if (<= y -1.4e-160)
           t_1
           (if (<= y -4e-205)
             (/ y (+ y -2.0))
             (if (<= y 5.5e+59) t_1 t_0))))))))
double code(double x, double y) {
	double t_0 = 1.0 + ((x * -2.0) / y);
	double t_1 = x / (2.0 - x);
	double tmp;
	if (y <= -7200000000.0) {
		tmp = t_0;
	} else if (y <= -1.3e-23) {
		tmp = (y / x) + -1.0;
	} else if (y <= -2.25e-67) {
		tmp = y * -0.5;
	} else if (y <= -1.4e-160) {
		tmp = t_1;
	} else if (y <= -4e-205) {
		tmp = y / (y + -2.0);
	} else if (y <= 5.5e+59) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 + ((x * (-2.0d0)) / y)
    t_1 = x / (2.0d0 - x)
    if (y <= (-7200000000.0d0)) then
        tmp = t_0
    else if (y <= (-1.3d-23)) then
        tmp = (y / x) + (-1.0d0)
    else if (y <= (-2.25d-67)) then
        tmp = y * (-0.5d0)
    else if (y <= (-1.4d-160)) then
        tmp = t_1
    else if (y <= (-4d-205)) then
        tmp = y / (y + (-2.0d0))
    else if (y <= 5.5d+59) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 + ((x * -2.0) / y);
	double t_1 = x / (2.0 - x);
	double tmp;
	if (y <= -7200000000.0) {
		tmp = t_0;
	} else if (y <= -1.3e-23) {
		tmp = (y / x) + -1.0;
	} else if (y <= -2.25e-67) {
		tmp = y * -0.5;
	} else if (y <= -1.4e-160) {
		tmp = t_1;
	} else if (y <= -4e-205) {
		tmp = y / (y + -2.0);
	} else if (y <= 5.5e+59) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 + ((x * -2.0) / y)
	t_1 = x / (2.0 - x)
	tmp = 0
	if y <= -7200000000.0:
		tmp = t_0
	elif y <= -1.3e-23:
		tmp = (y / x) + -1.0
	elif y <= -2.25e-67:
		tmp = y * -0.5
	elif y <= -1.4e-160:
		tmp = t_1
	elif y <= -4e-205:
		tmp = y / (y + -2.0)
	elif y <= 5.5e+59:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 + Float64(Float64(x * -2.0) / y))
	t_1 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -7200000000.0)
		tmp = t_0;
	elseif (y <= -1.3e-23)
		tmp = Float64(Float64(y / x) + -1.0);
	elseif (y <= -2.25e-67)
		tmp = Float64(y * -0.5);
	elseif (y <= -1.4e-160)
		tmp = t_1;
	elseif (y <= -4e-205)
		tmp = Float64(y / Float64(y + -2.0));
	elseif (y <= 5.5e+59)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 + ((x * -2.0) / y);
	t_1 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -7200000000.0)
		tmp = t_0;
	elseif (y <= -1.3e-23)
		tmp = (y / x) + -1.0;
	elseif (y <= -2.25e-67)
		tmp = y * -0.5;
	elseif (y <= -1.4e-160)
		tmp = t_1;
	elseif (y <= -4e-205)
		tmp = y / (y + -2.0);
	elseif (y <= 5.5e+59)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7200000000.0], t$95$0, If[LessEqual[y, -1.3e-23], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, -2.25e-67], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -1.4e-160], t$95$1, If[LessEqual[y, -4e-205], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.5e+59], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.3 \cdot 10^{-23}:\\
\;\;\;\;\frac{y}{x} + -1\\

\mathbf{elif}\;y \leq -2.25 \cdot 10^{-67}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\
\;\;\;\;\frac{y}{y + -2}\\

\mathbf{elif}\;y \leq 5.5 \cdot 10^{+59}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -7.2e9 or 5.4999999999999999e59 < y

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+99.9%

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

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

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{x}{y}\right) - -1 \cdot \frac{2 - x}{y}} \]
    5. Step-by-step derivation
      1. associate--l+86.9%

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

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

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

        \[\leadsto 1 + \color{blue}{\frac{-1 \cdot x - -1 \cdot \left(2 - x\right)}{y}} \]
      5. cancel-sign-sub-inv86.9%

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

        \[\leadsto 1 + \frac{-1 \cdot x + \color{blue}{1} \cdot \left(2 - x\right)}{y} \]
      7. *-lft-identity86.9%

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

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

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

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

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

      \[\leadsto 1 + \frac{\color{blue}{-2 \cdot x}}{y} \]
    8. Step-by-step derivation
      1. *-commutative86.4%

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

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

    if -7.2e9 < y < -1.3e-23

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

      \[\leadsto \color{blue}{\frac{x - y}{\left(2 - x\right) - y}} \]
    4. Step-by-step derivation
      1. clear-num100.0%

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

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

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

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

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

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

    if -1.3e-23 < y < -2.25000000000000008e-67

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified86.4%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified86.4%

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

    if -2.25000000000000008e-67 < y < -1.40000000000000008e-160 or -4e-205 < y < 5.4999999999999999e59

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    if -1.40000000000000008e-160 < y < -4e-205

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified89.2%

      \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    7. Step-by-step derivation
      1. frac-2neg89.2%

        \[\leadsto \color{blue}{\frac{-\left(-y\right)}{-\left(2 - y\right)}} \]
      2. div-inv89.2%

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

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

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

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

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

        \[\leadsto y \cdot \frac{1}{-2 + \color{blue}{y}} \]
    8. Applied egg-rr89.2%

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

        \[\leadsto \color{blue}{\frac{y \cdot 1}{-2 + y}} \]
      2. *-rgt-identity89.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7200000000:\\ \;\;\;\;1 + \frac{x \cdot -2}{y}\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-23}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-67}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+59}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x \cdot -2}{y}\\ \end{array} \]

Alternative 3: 72.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y \leq -8.5 \cdot 10^{-24}:\\
\;\;\;\;\frac{y}{x} + -1\\

\mathbf{elif}\;y \leq -2.2 \cdot 10^{-73}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\
\;\;\;\;\frac{y}{y + -2}\\

\mathbf{elif}\;y \leq 5.4 \cdot 10^{+59}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if y < -1.55e10

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+99.9%

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

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

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{x}{y}\right) - -1 \cdot \frac{2 - x}{y}} \]
    5. Step-by-step derivation
      1. associate--l+81.9%

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

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

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

        \[\leadsto 1 + \color{blue}{\frac{-1 \cdot x - -1 \cdot \left(2 - x\right)}{y}} \]
      5. cancel-sign-sub-inv81.9%

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

        \[\leadsto 1 + \frac{-1 \cdot x + \color{blue}{1} \cdot \left(2 - x\right)}{y} \]
      7. *-lft-identity81.9%

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

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

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

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

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

    if -1.55e10 < y < -8.5000000000000002e-24

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

      \[\leadsto \color{blue}{\frac{x - y}{\left(2 - x\right) - y}} \]
    4. Step-by-step derivation
      1. clear-num100.0%

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

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

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

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

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

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

    if -8.5000000000000002e-24 < y < -2.2e-73

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified86.4%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified86.4%

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

    if -2.2e-73 < y < -1.40000000000000008e-160 or -4e-205 < y < 5.4000000000000002e59

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    if -1.40000000000000008e-160 < y < -4e-205

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified89.2%

      \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    7. Step-by-step derivation
      1. frac-2neg89.2%

        \[\leadsto \color{blue}{\frac{-\left(-y\right)}{-\left(2 - y\right)}} \]
      2. div-inv89.2%

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

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

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

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

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

        \[\leadsto y \cdot \frac{1}{-2 + \color{blue}{y}} \]
    8. Applied egg-rr89.2%

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

        \[\leadsto \color{blue}{\frac{y \cdot 1}{-2 + y}} \]
      2. *-rgt-identity89.2%

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

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

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

    if 5.4000000000000002e59 < y

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{x}{y}\right) - -1 \cdot \frac{2 - x}{y}} \]
    5. Step-by-step derivation
      1. associate--l+94.4%

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

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

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

        \[\leadsto 1 + \color{blue}{\frac{-1 \cdot x - -1 \cdot \left(2 - x\right)}{y}} \]
      5. cancel-sign-sub-inv94.4%

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

        \[\leadsto 1 + \frac{-1 \cdot x + \color{blue}{1} \cdot \left(2 - x\right)}{y} \]
      7. *-lft-identity94.4%

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

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

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

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

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

      \[\leadsto 1 + \frac{\color{blue}{-2 \cdot x}}{y} \]
    8. Step-by-step derivation
      1. *-commutative94.4%

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

      \[\leadsto 1 + \frac{\color{blue}{x \cdot -2}}{y} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification80.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -15500000000:\\ \;\;\;\;1 + \frac{\left(2 - x\right) - x}{y}\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-24}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-73}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+59}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x \cdot -2}{y}\\ \end{array} \]

Alternative 4: 71.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -136000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-23}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-67}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+59}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -136000000000.0)
     1.0
     (if (<= y -1e-23)
       (+ (/ y x) -1.0)
       (if (<= y -1.4e-67)
         (* y -0.5)
         (if (<= y -1.4e-160)
           t_0
           (if (<= y -4e-205) (* y -0.5) (if (<= y 8e+59) t_0 1.0))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -136000000000.0) {
		tmp = 1.0;
	} else if (y <= -1e-23) {
		tmp = (y / x) + -1.0;
	} else if (y <= -1.4e-67) {
		tmp = y * -0.5;
	} else if (y <= -1.4e-160) {
		tmp = t_0;
	} else if (y <= -4e-205) {
		tmp = y * -0.5;
	} else if (y <= 8e+59) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x / (2.0d0 - x)
    if (y <= (-136000000000.0d0)) then
        tmp = 1.0d0
    else if (y <= (-1d-23)) then
        tmp = (y / x) + (-1.0d0)
    else if (y <= (-1.4d-67)) then
        tmp = y * (-0.5d0)
    else if (y <= (-1.4d-160)) then
        tmp = t_0
    else if (y <= (-4d-205)) then
        tmp = y * (-0.5d0)
    else if (y <= 8d+59) then
        tmp = t_0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -136000000000.0) {
		tmp = 1.0;
	} else if (y <= -1e-23) {
		tmp = (y / x) + -1.0;
	} else if (y <= -1.4e-67) {
		tmp = y * -0.5;
	} else if (y <= -1.4e-160) {
		tmp = t_0;
	} else if (y <= -4e-205) {
		tmp = y * -0.5;
	} else if (y <= 8e+59) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -136000000000.0:
		tmp = 1.0
	elif y <= -1e-23:
		tmp = (y / x) + -1.0
	elif y <= -1.4e-67:
		tmp = y * -0.5
	elif y <= -1.4e-160:
		tmp = t_0
	elif y <= -4e-205:
		tmp = y * -0.5
	elif y <= 8e+59:
		tmp = t_0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -136000000000.0)
		tmp = 1.0;
	elseif (y <= -1e-23)
		tmp = Float64(Float64(y / x) + -1.0);
	elseif (y <= -1.4e-67)
		tmp = Float64(y * -0.5);
	elseif (y <= -1.4e-160)
		tmp = t_0;
	elseif (y <= -4e-205)
		tmp = Float64(y * -0.5);
	elseif (y <= 8e+59)
		tmp = t_0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -136000000000.0)
		tmp = 1.0;
	elseif (y <= -1e-23)
		tmp = (y / x) + -1.0;
	elseif (y <= -1.4e-67)
		tmp = y * -0.5;
	elseif (y <= -1.4e-160)
		tmp = t_0;
	elseif (y <= -4e-205)
		tmp = y * -0.5;
	elseif (y <= 8e+59)
		tmp = t_0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -136000000000.0], 1.0, If[LessEqual[y, -1e-23], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, -1.4e-67], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -1.4e-160], t$95$0, If[LessEqual[y, -4e-205], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 8e+59], t$95$0, 1.0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -136000000000:\\
\;\;\;\;1\\

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

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

\mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 8 \cdot 10^{+59}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.36e11 or 7.99999999999999977e59 < y

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+99.9%

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

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

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

    if -1.36e11 < y < -9.9999999999999996e-24

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

      \[\leadsto \color{blue}{\frac{x - y}{\left(2 - x\right) - y}} \]
    4. Step-by-step derivation
      1. clear-num100.0%

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

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

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

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

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

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

    if -9.9999999999999996e-24 < y < -1.40000000000000005e-67 or -1.40000000000000008e-160 < y < -4e-205

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified87.7%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified87.7%

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

    if -1.40000000000000005e-67 < y < -1.40000000000000008e-160 or -4e-205 < y < 7.99999999999999977e59

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -136000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-23}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-67}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+59}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 5: 71.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y + -2}\\ t_1 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -1860000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.06 \cdot 10^{-24}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -5.9 \cdot 10^{-68}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+63}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ y -2.0))) (t_1 (/ x (- 2.0 x))))
   (if (<= y -1860000000.0)
     t_0
     (if (<= y -1.06e-24)
       (+ (/ y x) -1.0)
       (if (<= y -5.9e-68)
         (* y -0.5)
         (if (<= y -1.4e-160)
           t_1
           (if (<= y -4e-205) t_0 (if (<= y 1.25e+63) t_1 1.0))))))))
double code(double x, double y) {
	double t_0 = y / (y + -2.0);
	double t_1 = x / (2.0 - x);
	double tmp;
	if (y <= -1860000000.0) {
		tmp = t_0;
	} else if (y <= -1.06e-24) {
		tmp = (y / x) + -1.0;
	} else if (y <= -5.9e-68) {
		tmp = y * -0.5;
	} else if (y <= -1.4e-160) {
		tmp = t_1;
	} else if (y <= -4e-205) {
		tmp = t_0;
	} else if (y <= 1.25e+63) {
		tmp = t_1;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y / (y + (-2.0d0))
    t_1 = x / (2.0d0 - x)
    if (y <= (-1860000000.0d0)) then
        tmp = t_0
    else if (y <= (-1.06d-24)) then
        tmp = (y / x) + (-1.0d0)
    else if (y <= (-5.9d-68)) then
        tmp = y * (-0.5d0)
    else if (y <= (-1.4d-160)) then
        tmp = t_1
    else if (y <= (-4d-205)) then
        tmp = t_0
    else if (y <= 1.25d+63) then
        tmp = t_1
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y / (y + -2.0);
	double t_1 = x / (2.0 - x);
	double tmp;
	if (y <= -1860000000.0) {
		tmp = t_0;
	} else if (y <= -1.06e-24) {
		tmp = (y / x) + -1.0;
	} else if (y <= -5.9e-68) {
		tmp = y * -0.5;
	} else if (y <= -1.4e-160) {
		tmp = t_1;
	} else if (y <= -4e-205) {
		tmp = t_0;
	} else if (y <= 1.25e+63) {
		tmp = t_1;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (y + -2.0)
	t_1 = x / (2.0 - x)
	tmp = 0
	if y <= -1860000000.0:
		tmp = t_0
	elif y <= -1.06e-24:
		tmp = (y / x) + -1.0
	elif y <= -5.9e-68:
		tmp = y * -0.5
	elif y <= -1.4e-160:
		tmp = t_1
	elif y <= -4e-205:
		tmp = t_0
	elif y <= 1.25e+63:
		tmp = t_1
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(y + -2.0))
	t_1 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -1860000000.0)
		tmp = t_0;
	elseif (y <= -1.06e-24)
		tmp = Float64(Float64(y / x) + -1.0);
	elseif (y <= -5.9e-68)
		tmp = Float64(y * -0.5);
	elseif (y <= -1.4e-160)
		tmp = t_1;
	elseif (y <= -4e-205)
		tmp = t_0;
	elseif (y <= 1.25e+63)
		tmp = t_1;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (y + -2.0);
	t_1 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -1860000000.0)
		tmp = t_0;
	elseif (y <= -1.06e-24)
		tmp = (y / x) + -1.0;
	elseif (y <= -5.9e-68)
		tmp = y * -0.5;
	elseif (y <= -1.4e-160)
		tmp = t_1;
	elseif (y <= -4e-205)
		tmp = t_0;
	elseif (y <= 1.25e+63)
		tmp = t_1;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1860000000.0], t$95$0, If[LessEqual[y, -1.06e-24], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, -5.9e-68], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -1.4e-160], t$95$1, If[LessEqual[y, -4e-205], t$95$0, If[LessEqual[y, 1.25e+63], t$95$1, 1.0]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{y + -2}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -1860000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -1.06 \cdot 10^{-24}:\\
\;\;\;\;\frac{y}{x} + -1\\

\mathbf{elif}\;y \leq -5.9 \cdot 10^{-68}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.25 \cdot 10^{+63}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -1.86e9 or -1.40000000000000008e-160 < y < -4e-205

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+99.9%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified82.0%

      \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    7. Step-by-step derivation
      1. frac-2neg82.0%

        \[\leadsto \color{blue}{\frac{-\left(-y\right)}{-\left(2 - y\right)}} \]
      2. div-inv81.8%

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

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

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

        \[\leadsto y \cdot \frac{1}{\color{blue}{\left(-2\right) + \left(-\left(-y\right)\right)}} \]
      6. metadata-eval81.8%

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

        \[\leadsto y \cdot \frac{1}{-2 + \color{blue}{y}} \]
    8. Applied egg-rr81.8%

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

        \[\leadsto \color{blue}{\frac{y \cdot 1}{-2 + y}} \]
      2. *-rgt-identity82.0%

        \[\leadsto \frac{\color{blue}{y}}{-2 + y} \]
      3. +-commutative82.0%

        \[\leadsto \frac{y}{\color{blue}{y + -2}} \]
    10. Simplified82.0%

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

    if -1.86e9 < y < -1.0599999999999999e-24

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

      \[\leadsto \color{blue}{\frac{x - y}{\left(2 - x\right) - y}} \]
    4. Step-by-step derivation
      1. clear-num100.0%

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

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

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

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

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

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

    if -1.0599999999999999e-24 < y < -5.9e-68

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified86.4%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified86.4%

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

    if -5.9e-68 < y < -1.40000000000000008e-160 or -4e-205 < y < 1.25000000000000003e63

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    if 1.25000000000000003e63 < y

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1860000000:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq -1.06 \cdot 10^{-24}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -5.9 \cdot 10^{-68}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-160}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-205}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+63}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 59.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -95000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -8 \cdot 10^{-24}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-205}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-303}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+59}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -95000000000.0)
   1.0
   (if (<= y -8e-24)
     -1.0
     (if (<= y -3.9e-205)
       (* y -0.5)
       (if (<= y -4.8e-303) (* x 0.5) (if (<= y 5.4e+59) -1.0 1.0))))))
double code(double x, double y) {
	double tmp;
	if (y <= -95000000000.0) {
		tmp = 1.0;
	} else if (y <= -8e-24) {
		tmp = -1.0;
	} else if (y <= -3.9e-205) {
		tmp = y * -0.5;
	} else if (y <= -4.8e-303) {
		tmp = x * 0.5;
	} else if (y <= 5.4e+59) {
		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 <= (-95000000000.0d0)) then
        tmp = 1.0d0
    else if (y <= (-8d-24)) then
        tmp = -1.0d0
    else if (y <= (-3.9d-205)) then
        tmp = y * (-0.5d0)
    else if (y <= (-4.8d-303)) then
        tmp = x * 0.5d0
    else if (y <= 5.4d+59) 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 <= -95000000000.0) {
		tmp = 1.0;
	} else if (y <= -8e-24) {
		tmp = -1.0;
	} else if (y <= -3.9e-205) {
		tmp = y * -0.5;
	} else if (y <= -4.8e-303) {
		tmp = x * 0.5;
	} else if (y <= 5.4e+59) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -95000000000.0:
		tmp = 1.0
	elif y <= -8e-24:
		tmp = -1.0
	elif y <= -3.9e-205:
		tmp = y * -0.5
	elif y <= -4.8e-303:
		tmp = x * 0.5
	elif y <= 5.4e+59:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -95000000000.0)
		tmp = 1.0;
	elseif (y <= -8e-24)
		tmp = -1.0;
	elseif (y <= -3.9e-205)
		tmp = Float64(y * -0.5);
	elseif (y <= -4.8e-303)
		tmp = Float64(x * 0.5);
	elseif (y <= 5.4e+59)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -95000000000.0)
		tmp = 1.0;
	elseif (y <= -8e-24)
		tmp = -1.0;
	elseif (y <= -3.9e-205)
		tmp = y * -0.5;
	elseif (y <= -4.8e-303)
		tmp = x * 0.5;
	elseif (y <= 5.4e+59)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -95000000000.0], 1.0, If[LessEqual[y, -8e-24], -1.0, If[LessEqual[y, -3.9e-205], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -4.8e-303], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.4e+59], -1.0, 1.0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -8 \cdot 10^{-24}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq -3.9 \cdot 10^{-205}:\\
\;\;\;\;y \cdot -0.5\\

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

\mathbf{elif}\;y \leq 5.4 \cdot 10^{+59}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -9.5e10 or 5.4000000000000002e59 < y

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+99.9%

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

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

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

    if -9.5e10 < y < -7.99999999999999939e-24 or -4.8000000000000002e-303 < y < 5.4000000000000002e59

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    if -7.99999999999999939e-24 < y < -3.90000000000000018e-205

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified61.1%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified61.1%

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

    if -3.90000000000000018e-205 < y < -4.8000000000000002e-303

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified64.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -95000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -8 \cdot 10^{-24}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-205}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-303}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+59}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 7: 59.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -240000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{-24}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-205}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{-302}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+59}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -240000000000.0)
   1.0
   (if (<= y -2.7e-24)
     (+ (/ y x) -1.0)
     (if (<= y -3.3e-205)
       (* y -0.5)
       (if (<= y -4.6e-302) (* x 0.5) (if (<= y 5.5e+59) -1.0 1.0))))))
double code(double x, double y) {
	double tmp;
	if (y <= -240000000000.0) {
		tmp = 1.0;
	} else if (y <= -2.7e-24) {
		tmp = (y / x) + -1.0;
	} else if (y <= -3.3e-205) {
		tmp = y * -0.5;
	} else if (y <= -4.6e-302) {
		tmp = x * 0.5;
	} else if (y <= 5.5e+59) {
		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 <= (-240000000000.0d0)) then
        tmp = 1.0d0
    else if (y <= (-2.7d-24)) then
        tmp = (y / x) + (-1.0d0)
    else if (y <= (-3.3d-205)) then
        tmp = y * (-0.5d0)
    else if (y <= (-4.6d-302)) then
        tmp = x * 0.5d0
    else if (y <= 5.5d+59) 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 <= -240000000000.0) {
		tmp = 1.0;
	} else if (y <= -2.7e-24) {
		tmp = (y / x) + -1.0;
	} else if (y <= -3.3e-205) {
		tmp = y * -0.5;
	} else if (y <= -4.6e-302) {
		tmp = x * 0.5;
	} else if (y <= 5.5e+59) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -240000000000.0:
		tmp = 1.0
	elif y <= -2.7e-24:
		tmp = (y / x) + -1.0
	elif y <= -3.3e-205:
		tmp = y * -0.5
	elif y <= -4.6e-302:
		tmp = x * 0.5
	elif y <= 5.5e+59:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -240000000000.0)
		tmp = 1.0;
	elseif (y <= -2.7e-24)
		tmp = Float64(Float64(y / x) + -1.0);
	elseif (y <= -3.3e-205)
		tmp = Float64(y * -0.5);
	elseif (y <= -4.6e-302)
		tmp = Float64(x * 0.5);
	elseif (y <= 5.5e+59)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -240000000000.0)
		tmp = 1.0;
	elseif (y <= -2.7e-24)
		tmp = (y / x) + -1.0;
	elseif (y <= -3.3e-205)
		tmp = y * -0.5;
	elseif (y <= -4.6e-302)
		tmp = x * 0.5;
	elseif (y <= 5.5e+59)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -240000000000.0], 1.0, If[LessEqual[y, -2.7e-24], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, -3.3e-205], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -4.6e-302], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.5e+59], -1.0, 1.0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -2.7 \cdot 10^{-24}:\\
\;\;\;\;\frac{y}{x} + -1\\

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

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

\mathbf{elif}\;y \leq 5.5 \cdot 10^{+59}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -2.4e11 or 5.4999999999999999e59 < y

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+99.9%

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

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

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

    if -2.4e11 < y < -2.70000000000000007e-24

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

      \[\leadsto \color{blue}{\frac{x - y}{\left(2 - x\right) - y}} \]
    4. Step-by-step derivation
      1. clear-num100.0%

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

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

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

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

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

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

    if -2.70000000000000007e-24 < y < -3.2999999999999999e-205

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    6. Simplified61.1%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified61.1%

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

    if -3.2999999999999999e-205 < y < -4.60000000000000004e-302

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified64.4%

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

    if -4.60000000000000004e-302 < y < 5.4999999999999999e59

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -240000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{-24}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-205}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{-302}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+59}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 60.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -230000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-155}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{-304}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+59}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -230000000000.0)
   1.0
   (if (<= y -1.75e-155)
     -1.0
     (if (<= y -7.2e-304) (* x 0.5) (if (<= y 5.4e+59) -1.0 1.0)))))
double code(double x, double y) {
	double tmp;
	if (y <= -230000000000.0) {
		tmp = 1.0;
	} else if (y <= -1.75e-155) {
		tmp = -1.0;
	} else if (y <= -7.2e-304) {
		tmp = x * 0.5;
	} else if (y <= 5.4e+59) {
		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 <= (-230000000000.0d0)) then
        tmp = 1.0d0
    else if (y <= (-1.75d-155)) then
        tmp = -1.0d0
    else if (y <= (-7.2d-304)) then
        tmp = x * 0.5d0
    else if (y <= 5.4d+59) 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 <= -230000000000.0) {
		tmp = 1.0;
	} else if (y <= -1.75e-155) {
		tmp = -1.0;
	} else if (y <= -7.2e-304) {
		tmp = x * 0.5;
	} else if (y <= 5.4e+59) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -230000000000.0:
		tmp = 1.0
	elif y <= -1.75e-155:
		tmp = -1.0
	elif y <= -7.2e-304:
		tmp = x * 0.5
	elif y <= 5.4e+59:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -230000000000.0)
		tmp = 1.0;
	elseif (y <= -1.75e-155)
		tmp = -1.0;
	elseif (y <= -7.2e-304)
		tmp = Float64(x * 0.5);
	elseif (y <= 5.4e+59)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -230000000000.0)
		tmp = 1.0;
	elseif (y <= -1.75e-155)
		tmp = -1.0;
	elseif (y <= -7.2e-304)
		tmp = x * 0.5;
	elseif (y <= 5.4e+59)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -230000000000.0], 1.0, If[LessEqual[y, -1.75e-155], -1.0, If[LessEqual[y, -7.2e-304], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.4e+59], -1.0, 1.0]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -7.2 \cdot 10^{-304}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 5.4 \cdot 10^{+59}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.3e11 or 5.4000000000000002e59 < y

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+99.9%

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

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

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

    if -2.3e11 < y < -1.75000000000000008e-155 or -7.2000000000000003e-304 < y < 5.4000000000000002e59

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    if -1.75000000000000008e-155 < y < -7.2000000000000003e-304

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified50.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -230000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-155}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{-304}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+59}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 9: 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. Final simplification100.0%

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

Alternative 10: 62.1% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;y \leq 6 \cdot 10^{+59}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.8e9 or 6.0000000000000001e59 < y

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+99.9%

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

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

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

    if -8.8e9 < y < 6.0000000000000001e59

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. associate--r+100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8800000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+59}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 11: 38.1% 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. associate--r+100.0%

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

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification32.1%

    \[\leadsto -1 \]

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

  :herbie-target
  (- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))

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