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

Percentage Accurate: 100.0% → 100.0%
Time: 5.7s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 98.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -10200 \lor \neg \left(x \leq 2\right):\\ \;\;\;\;\frac{x - y}{\left(-x\right) - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -10200.0) (not (<= x 2.0)))
   (/ (- x y) (- (- x) y))
   (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
	double tmp;
	if ((x <= -10200.0) || !(x <= 2.0)) {
		tmp = (x - y) / (-x - y);
	} else {
		tmp = (x - y) / (2.0 - y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-10200.0d0)) .or. (.not. (x <= 2.0d0))) then
        tmp = (x - y) / (-x - y)
    else
        tmp = (x - y) / (2.0d0 - y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -10200.0) || !(x <= 2.0)) {
		tmp = (x - y) / (-x - y);
	} else {
		tmp = (x - y) / (2.0 - y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -10200.0) or not (x <= 2.0):
		tmp = (x - y) / (-x - y)
	else:
		tmp = (x - y) / (2.0 - y)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -10200.0) || !(x <= 2.0))
		tmp = Float64(Float64(x - y) / Float64(Float64(-x) - y));
	else
		tmp = Float64(Float64(x - y) / Float64(2.0 - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -10200.0) || ~((x <= 2.0)))
		tmp = (x - y) / (-x - y);
	else
		tmp = (x - y) / (2.0 - y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -10200.0], N[Not[LessEqual[x, 2.0]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / N[((-x) - y), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -10200 \lor \neg \left(x \leq 2\right):\\
\;\;\;\;\frac{x - y}{\left(-x\right) - y}\\

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


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

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

        \[\leadsto \frac{x - y}{\color{blue}{\frac{2 \cdot 2 - x \cdot x}{2 + x}} - y} \]
      2. div-inv46.5%

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

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

        \[\leadsto \frac{x - y}{\mathsf{fma}\left(\color{blue}{4} - x \cdot x, \frac{1}{2 + x}, -y\right)} \]
      5. +-commutative46.5%

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

      \[\leadsto \frac{x - y}{\color{blue}{\mathsf{fma}\left(4 - x \cdot x, \frac{1}{x + 2}, -y\right)}} \]
    6. Step-by-step derivation
      1. fma-neg46.5%

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

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

        \[\leadsto \frac{x - y}{\frac{\color{blue}{4 - x \cdot x}}{x + 2} - y} \]
      4. +-commutative46.7%

        \[\leadsto \frac{x - y}{\frac{4 - x \cdot x}{\color{blue}{2 + x}} - y} \]
    7. Simplified46.7%

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

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

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

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

    if -10200 < x < 2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -10200 \lor \neg \left(x \leq 2\right):\\ \;\;\;\;\frac{x - y}{\left(-x\right) - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \end{array} \]

Alternative 3: 74.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.4 \cdot 10^{+67} \lor \neg \left(x \leq 1.16 \cdot 10^{+58}\right):\\ \;\;\;\;2 \cdot \frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y + -2}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -5.4e+67) (not (<= x 1.16e+58)))
   (+ (* 2.0 (/ y x)) -1.0)
   (/ y (+ y -2.0))))
double code(double x, double y) {
	double tmp;
	if ((x <= -5.4e+67) || !(x <= 1.16e+58)) {
		tmp = (2.0 * (y / x)) + -1.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) :: tmp
    if ((x <= (-5.4d+67)) .or. (.not. (x <= 1.16d+58))) then
        tmp = (2.0d0 * (y / x)) + (-1.0d0)
    else
        tmp = y / (y + (-2.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -5.4e+67) || !(x <= 1.16e+58)) {
		tmp = (2.0 * (y / x)) + -1.0;
	} else {
		tmp = y / (y + -2.0);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -5.4e+67) or not (x <= 1.16e+58):
		tmp = (2.0 * (y / x)) + -1.0
	else:
		tmp = y / (y + -2.0)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -5.4e+67) || !(x <= 1.16e+58))
		tmp = Float64(Float64(2.0 * Float64(y / x)) + -1.0);
	else
		tmp = Float64(y / Float64(y + -2.0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -5.4e+67) || ~((x <= 1.16e+58)))
		tmp = (2.0 * (y / x)) + -1.0;
	else
		tmp = y / (y + -2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -5.4e+67], N[Not[LessEqual[x, 1.16e+58]], $MachinePrecision]], N[(N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{+67} \lor \neg \left(x \leq 1.16 \cdot 10^{+58}\right):\\
\;\;\;\;2 \cdot \frac{y}{x} + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.3999999999999998e67 or 1.1600000000000001e58 < x

    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. Step-by-step derivation
      1. flip--36.3%

        \[\leadsto \frac{x - y}{\color{blue}{\frac{2 \cdot 2 - x \cdot x}{2 + x}} - y} \]
      2. div-inv36.2%

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

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

        \[\leadsto \frac{x - y}{\mathsf{fma}\left(\color{blue}{4} - x \cdot x, \frac{1}{2 + x}, -y\right)} \]
      5. +-commutative36.2%

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

      \[\leadsto \frac{x - y}{\color{blue}{\mathsf{fma}\left(4 - x \cdot x, \frac{1}{x + 2}, -y\right)}} \]
    6. Step-by-step derivation
      1. fma-neg36.2%

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

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

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

        \[\leadsto \frac{x - y}{\frac{4 - x \cdot x}{\color{blue}{2 + x}} - y} \]
    7. Simplified36.3%

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

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

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

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

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

    if -5.3999999999999998e67 < x < 1.1600000000000001e58

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot y}{2 - y}} \]
      2. neg-mul-179.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.4 \cdot 10^{+67} \lor \neg \left(x \leq 1.16 \cdot 10^{+58}\right):\\ \;\;\;\;2 \cdot \frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y + -2}\\ \end{array} \]

Alternative 4: 86.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{+68} \lor \neg \left(x \leq 2.35 \cdot 10^{+59}\right):\\ \;\;\;\;2 \cdot \frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -5.8e+68) (not (<= x 2.35e+59)))
   (+ (* 2.0 (/ y x)) -1.0)
   (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
	double tmp;
	if ((x <= -5.8e+68) || !(x <= 2.35e+59)) {
		tmp = (2.0 * (y / x)) + -1.0;
	} else {
		tmp = (x - y) / (2.0 - y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-5.8d+68)) .or. (.not. (x <= 2.35d+59))) then
        tmp = (2.0d0 * (y / x)) + (-1.0d0)
    else
        tmp = (x - y) / (2.0d0 - y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -5.8e+68) || !(x <= 2.35e+59)) {
		tmp = (2.0 * (y / x)) + -1.0;
	} else {
		tmp = (x - y) / (2.0 - y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -5.8e+68) or not (x <= 2.35e+59):
		tmp = (2.0 * (y / x)) + -1.0
	else:
		tmp = (x - y) / (2.0 - y)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -5.8e+68) || !(x <= 2.35e+59))
		tmp = Float64(Float64(2.0 * Float64(y / x)) + -1.0);
	else
		tmp = Float64(Float64(x - y) / Float64(2.0 - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -5.8e+68) || ~((x <= 2.35e+59)))
		tmp = (2.0 * (y / x)) + -1.0;
	else
		tmp = (x - y) / (2.0 - y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -5.8e+68], N[Not[LessEqual[x, 2.35e+59]], $MachinePrecision]], N[(N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+68} \lor \neg \left(x \leq 2.35 \cdot 10^{+59}\right):\\
\;\;\;\;2 \cdot \frac{y}{x} + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.80000000000000023e68 or 2.35e59 < x

    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. Step-by-step derivation
      1. flip--36.3%

        \[\leadsto \frac{x - y}{\color{blue}{\frac{2 \cdot 2 - x \cdot x}{2 + x}} - y} \]
      2. div-inv36.2%

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

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

        \[\leadsto \frac{x - y}{\mathsf{fma}\left(\color{blue}{4} - x \cdot x, \frac{1}{2 + x}, -y\right)} \]
      5. +-commutative36.2%

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

      \[\leadsto \frac{x - y}{\color{blue}{\mathsf{fma}\left(4 - x \cdot x, \frac{1}{x + 2}, -y\right)}} \]
    6. Step-by-step derivation
      1. fma-neg36.2%

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

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

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

        \[\leadsto \frac{x - y}{\frac{4 - x \cdot x}{\color{blue}{2 + x}} - y} \]
    7. Simplified36.3%

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

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

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

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

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

    if -5.80000000000000023e68 < x < 2.35e59

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{+68} \lor \neg \left(x \leq 2.35 \cdot 10^{+59}\right):\\ \;\;\;\;2 \cdot \frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \end{array} \]

Alternative 5: 74.2% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \leq 10^{+58}:\\
\;\;\;\;\frac{y}{y + -2}\\

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


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

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

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

        \[\leadsto \frac{x - y}{\color{blue}{-x}} \]
    6. Simplified85.6%

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

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

    if -3.69999999999999998e68 < x < 9.99999999999999944e57

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot y}{2 - y}} \]
      2. neg-mul-179.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999944e57 < x

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

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

        \[\leadsto \frac{x - y}{\color{blue}{-x}} \]
    6. Simplified82.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.7 \cdot 10^{+68}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq 10^{+58}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{-x}\\ \end{array} \]

Alternative 6: 62.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+67} \lor \neg \left(x \leq 2.75 \cdot 10^{+60}\right):\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -5.2e+67) (not (<= x 2.75e+60))) (+ (/ y x) -1.0) 1.0))
double code(double x, double y) {
	double tmp;
	if ((x <= -5.2e+67) || !(x <= 2.75e+60)) {
		tmp = (y / x) + -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-5.2d+67)) .or. (.not. (x <= 2.75d+60))) then
        tmp = (y / x) + (-1.0d0)
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -5.2e+67) || !(x <= 2.75e+60)) {
		tmp = (y / x) + -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -5.2e+67) or not (x <= 2.75e+60):
		tmp = (y / x) + -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -5.2e+67) || !(x <= 2.75e+60))
		tmp = Float64(Float64(y / x) + -1.0);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -5.2e+67) || ~((x <= 2.75e+60)))
		tmp = (y / x) + -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -5.2e+67], N[Not[LessEqual[x, 2.75e+60]], $MachinePrecision]], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+67} \lor \neg \left(x \leq 2.75 \cdot 10^{+60}\right):\\
\;\;\;\;\frac{y}{x} + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.2000000000000001e67 or 2.75e60 < x

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

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

        \[\leadsto \frac{x - y}{\color{blue}{-x}} \]
    6. Simplified84.0%

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

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

    if -5.2000000000000001e67 < x < 2.75e60

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+67} \lor \neg \left(x \leq 2.75 \cdot 10^{+60}\right):\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 7: 75.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+37} \lor \neg \left(y \leq 6200000000000\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -8.2e+37) (not (<= y 6200000000000.0)))
   (- 1.0 (/ x y))
   (/ x (- 2.0 x))))
double code(double x, double y) {
	double tmp;
	if ((y <= -8.2e+37) || !(y <= 6200000000000.0)) {
		tmp = 1.0 - (x / y);
	} else {
		tmp = x / (2.0 - x);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-8.2d+37)) .or. (.not. (y <= 6200000000000.0d0))) then
        tmp = 1.0d0 - (x / y)
    else
        tmp = x / (2.0d0 - x)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -8.2e+37) || !(y <= 6200000000000.0)) {
		tmp = 1.0 - (x / y);
	} else {
		tmp = x / (2.0 - x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -8.2e+37) or not (y <= 6200000000000.0):
		tmp = 1.0 - (x / y)
	else:
		tmp = x / (2.0 - x)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -8.2e+37) || !(y <= 6200000000000.0))
		tmp = Float64(1.0 - Float64(x / y));
	else
		tmp = Float64(x / Float64(2.0 - x));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -8.2e+37) || ~((y <= 6200000000000.0)))
		tmp = 1.0 - (x / y);
	else
		tmp = x / (2.0 - x);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -8.2e+37], N[Not[LessEqual[y, 6200000000000.0]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+37} \lor \neg \left(y \leq 6200000000000\right):\\
\;\;\;\;1 - \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.1999999999999996e37 or 6.2e12 < 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 76.3%

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

        \[\leadsto \frac{x - y}{\color{blue}{-y}} \]
    6. Simplified76.3%

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

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

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

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    9. Simplified76.3%

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

    if -8.1999999999999996e37 < y < 6.2e12

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+37} \lor \neg \left(y \leq 6200000000000\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]

Alternative 8: 74.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+68} \lor \neg \left(x \leq 1.4 \cdot 10^{+58}\right):\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y + -2}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -1.6e+68) (not (<= x 1.4e+58)))
   (+ (/ y x) -1.0)
   (/ y (+ y -2.0))))
double code(double x, double y) {
	double tmp;
	if ((x <= -1.6e+68) || !(x <= 1.4e+58)) {
		tmp = (y / x) + -1.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) :: tmp
    if ((x <= (-1.6d+68)) .or. (.not. (x <= 1.4d+58))) then
        tmp = (y / x) + (-1.0d0)
    else
        tmp = y / (y + (-2.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -1.6e+68) || !(x <= 1.4e+58)) {
		tmp = (y / x) + -1.0;
	} else {
		tmp = y / (y + -2.0);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -1.6e+68) or not (x <= 1.4e+58):
		tmp = (y / x) + -1.0
	else:
		tmp = y / (y + -2.0)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -1.6e+68) || !(x <= 1.4e+58))
		tmp = Float64(Float64(y / x) + -1.0);
	else
		tmp = Float64(y / Float64(y + -2.0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -1.6e+68) || ~((x <= 1.4e+58)))
		tmp = (y / x) + -1.0;
	else
		tmp = y / (y + -2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -1.6e+68], N[Not[LessEqual[x, 1.4e+58]], $MachinePrecision]], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+68} \lor \neg \left(x \leq 1.4 \cdot 10^{+58}\right):\\
\;\;\;\;\frac{y}{x} + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.59999999999999997e68 or 1.3999999999999999e58 < x

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

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

        \[\leadsto \frac{x - y}{\color{blue}{-x}} \]
    6. Simplified84.0%

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

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

    if -1.59999999999999997e68 < x < 1.3999999999999999e58

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot y}{2 - y}} \]
      2. neg-mul-179.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+68} \lor \neg \left(x \leq 1.4 \cdot 10^{+58}\right):\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y + -2}\\ \end{array} \]

Alternative 9: 62.0% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 5 \cdot 10^{+58}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.1999999999999998e61 or 4.99999999999999986e58 < x

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

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

    if -9.1999999999999998e61 < x < 4.99999999999999986e58

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{+61}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+58}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

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

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

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