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

Percentage Accurate: 100.0% → 100.0%
Time: 5.7s
Alternatives: 8
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 8 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: 61.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -1.55 \cdot 10^{+41}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-49}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-134}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 58:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -1.55e+41)
     t_0
     (if (<= y -9.5e-49)
       -1.0
       (if (<= y -2.9e-134) (* y -0.5) (if (<= y 58.0) -1.0 t_0))))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -1.55e+41) {
		tmp = t_0;
	} else if (y <= -9.5e-49) {
		tmp = -1.0;
	} else if (y <= -2.9e-134) {
		tmp = y * -0.5;
	} else if (y <= 58.0) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    if (y <= (-1.55d+41)) then
        tmp = t_0
    else if (y <= (-9.5d-49)) then
        tmp = -1.0d0
    else if (y <= (-2.9d-134)) then
        tmp = y * (-0.5d0)
    else if (y <= 58.0d0) then
        tmp = -1.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -1.55e+41) {
		tmp = t_0;
	} else if (y <= -9.5e-49) {
		tmp = -1.0;
	} else if (y <= -2.9e-134) {
		tmp = y * -0.5;
	} else if (y <= 58.0) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -1.55e+41:
		tmp = t_0
	elif y <= -9.5e-49:
		tmp = -1.0
	elif y <= -2.9e-134:
		tmp = y * -0.5
	elif y <= 58.0:
		tmp = -1.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -1.55e+41)
		tmp = t_0;
	elseif (y <= -9.5e-49)
		tmp = -1.0;
	elseif (y <= -2.9e-134)
		tmp = Float64(y * -0.5);
	elseif (y <= 58.0)
		tmp = -1.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -1.55e+41)
		tmp = t_0;
	elseif (y <= -9.5e-49)
		tmp = -1.0;
	elseif (y <= -2.9e-134)
		tmp = y * -0.5;
	elseif (y <= 58.0)
		tmp = -1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.55e+41], t$95$0, If[LessEqual[y, -9.5e-49], -1.0, If[LessEqual[y, -2.9e-134], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 58.0], -1.0, t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -1.55 \cdot 10^{+41}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -9.5 \cdot 10^{-49}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq -2.9 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.55e41 or 58 < 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. Step-by-step derivation
      1. clear-num99.9%

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

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

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

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

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

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

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

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

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

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

    if -1.55e41 < y < -9.50000000000000006e-49 or -2.89999999999999993e-134 < y < 58

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

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

    if -9.50000000000000006e-49 < y < -2.89999999999999993e-134

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{+41}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-49}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-134}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 58:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq -1.6 \cdot 10^{-101}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 58:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.69999999999999988e42 or 58 < 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. Step-by-step derivation
      1. clear-num99.9%

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

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

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

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

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

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

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

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

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

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

    if -1.69999999999999988e42 < y < -1.59999999999999989e-101 or -6.69999999999999996e-134 < y < 58

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999989e-101 < y < -6.69999999999999996e-134

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{+42}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-101}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 58:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -3.1 \cdot 10^{+41}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-102}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-7}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - 2}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -3.1e+41)
     (- 1.0 (/ x y))
     (if (<= y -8.5e-102)
       t_0
       (if (<= y -6.7e-134)
         (* y -0.5)
         (if (<= y 1.15e-7) t_0 (/ y (- y 2.0))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -3.1e+41) {
		tmp = 1.0 - (x / y);
	} else if (y <= -8.5e-102) {
		tmp = t_0;
	} else if (y <= -6.7e-134) {
		tmp = y * -0.5;
	} else if (y <= 1.15e-7) {
		tmp = t_0;
	} else {
		tmp = y / (y - 2.0);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x / (2.0d0 - x)
    if (y <= (-3.1d+41)) then
        tmp = 1.0d0 - (x / y)
    else if (y <= (-8.5d-102)) then
        tmp = t_0
    else if (y <= (-6.7d-134)) then
        tmp = y * (-0.5d0)
    else if (y <= 1.15d-7) then
        tmp = t_0
    else
        tmp = y / (y - 2.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 <= -3.1e+41) {
		tmp = 1.0 - (x / y);
	} else if (y <= -8.5e-102) {
		tmp = t_0;
	} else if (y <= -6.7e-134) {
		tmp = y * -0.5;
	} else if (y <= 1.15e-7) {
		tmp = t_0;
	} else {
		tmp = y / (y - 2.0);
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -3.1e+41:
		tmp = 1.0 - (x / y)
	elif y <= -8.5e-102:
		tmp = t_0
	elif y <= -6.7e-134:
		tmp = y * -0.5
	elif y <= 1.15e-7:
		tmp = t_0
	else:
		tmp = y / (y - 2.0)
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -3.1e+41)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (y <= -8.5e-102)
		tmp = t_0;
	elseif (y <= -6.7e-134)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.15e-7)
		tmp = t_0;
	else
		tmp = Float64(y / Float64(y - 2.0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -3.1e+41)
		tmp = 1.0 - (x / y);
	elseif (y <= -8.5e-102)
		tmp = t_0;
	elseif (y <= -6.7e-134)
		tmp = y * -0.5;
	elseif (y <= 1.15e-7)
		tmp = t_0;
	else
		tmp = y / (y - 2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.1e+41], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -8.5e-102], t$95$0, If[LessEqual[y, -6.7e-134], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.15e-7], t$95$0, N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.15 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.1e41

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

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

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

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

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

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

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

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

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

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

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

    if -3.1e41 < y < -8.49999999999999973e-102 or -6.69999999999999996e-134 < y < 1.14999999999999997e-7

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

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

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

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

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

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

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

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

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

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

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

    if -8.49999999999999973e-102 < y < -6.69999999999999996e-134

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

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

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

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

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

    if 1.14999999999999997e-7 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{+41}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-102}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - 2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 73.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -1 \cdot 10^{+41}:\\ \;\;\;\;1 + \frac{x \cdot -2}{y}\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-102}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-9}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - 2}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -1e+41)
     (+ 1.0 (/ (* x -2.0) y))
     (if (<= y -4.5e-102)
       t_0
       (if (<= y -6.7e-134)
         (* y -0.5)
         (if (<= y 1.9e-9) t_0 (/ y (- y 2.0))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -1e+41) {
		tmp = 1.0 + ((x * -2.0) / y);
	} else if (y <= -4.5e-102) {
		tmp = t_0;
	} else if (y <= -6.7e-134) {
		tmp = y * -0.5;
	} else if (y <= 1.9e-9) {
		tmp = t_0;
	} else {
		tmp = y / (y - 2.0);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x / (2.0d0 - x)
    if (y <= (-1d+41)) then
        tmp = 1.0d0 + ((x * (-2.0d0)) / y)
    else if (y <= (-4.5d-102)) then
        tmp = t_0
    else if (y <= (-6.7d-134)) then
        tmp = y * (-0.5d0)
    else if (y <= 1.9d-9) then
        tmp = t_0
    else
        tmp = y / (y - 2.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 <= -1e+41) {
		tmp = 1.0 + ((x * -2.0) / y);
	} else if (y <= -4.5e-102) {
		tmp = t_0;
	} else if (y <= -6.7e-134) {
		tmp = y * -0.5;
	} else if (y <= 1.9e-9) {
		tmp = t_0;
	} else {
		tmp = y / (y - 2.0);
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -1e+41:
		tmp = 1.0 + ((x * -2.0) / y)
	elif y <= -4.5e-102:
		tmp = t_0
	elif y <= -6.7e-134:
		tmp = y * -0.5
	elif y <= 1.9e-9:
		tmp = t_0
	else:
		tmp = y / (y - 2.0)
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -1e+41)
		tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y));
	elseif (y <= -4.5e-102)
		tmp = t_0;
	elseif (y <= -6.7e-134)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.9e-9)
		tmp = t_0;
	else
		tmp = Float64(y / Float64(y - 2.0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -1e+41)
		tmp = 1.0 + ((x * -2.0) / y);
	elseif (y <= -4.5e-102)
		tmp = t_0;
	elseif (y <= -6.7e-134)
		tmp = y * -0.5;
	elseif (y <= 1.9e-9)
		tmp = t_0;
	else
		tmp = y / (y - 2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1e+41], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -4.5e-102], t$95$0, If[LessEqual[y, -6.7e-134], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.9e-9], t$95$0, N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -4.5 \cdot 10^{-102}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.9 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.00000000000000001e41

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000001e41 < y < -4.49999999999999999e-102 or -6.69999999999999996e-134 < y < 1.90000000000000006e-9

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

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

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

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

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

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

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

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

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

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

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

    if -4.49999999999999999e-102 < y < -6.69999999999999996e-134

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

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

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

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

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

    if 1.90000000000000006e-9 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+41}:\\ \;\;\;\;1 + \frac{x \cdot -2}{y}\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-102}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - 2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.6% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;y \leq -3.5 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.00000000000000022e41 or 58 < 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 76.4%

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

    if -5.00000000000000022e41 < y < -2.9999999999999999e-48 or -3.4999999999999998e-134 < y < 58

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

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

    if -2.9999999999999999e-48 < y < -3.4999999999999998e-134

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+41}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-48}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -3.5 \cdot 10^{-134}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 58:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 62.5% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.50000000000000014e42 or 58 < 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 76.4%

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

    if -1.50000000000000014e42 < y < 58

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 58:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 38.3% 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 40.3%

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

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