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

Percentage Accurate: 100.0% → 100.0%
Time: 5.2s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 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: 60.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -2.2 \cdot 10^{+114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.65 \cdot 10^{-210}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -6 \cdot 10^{-306}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-123}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-105}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2900000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -2.2e+114)
     t_0
     (if (<= y -2.65e-210)
       -1.0
       (if (<= y -6e-306)
         (* x 0.5)
         (if (<= y 2.8e-123)
           -1.0
           (if (<= y 2.3e-105) (* x 0.5) (if (<= y 2900000.0) -1.0 t_0))))))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -2.2e+114) {
		tmp = t_0;
	} else if (y <= -2.65e-210) {
		tmp = -1.0;
	} else if (y <= -6e-306) {
		tmp = x * 0.5;
	} else if (y <= 2.8e-123) {
		tmp = -1.0;
	} else if (y <= 2.3e-105) {
		tmp = x * 0.5;
	} else if (y <= 2900000.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 <= (-2.2d+114)) then
        tmp = t_0
    else if (y <= (-2.65d-210)) then
        tmp = -1.0d0
    else if (y <= (-6d-306)) then
        tmp = x * 0.5d0
    else if (y <= 2.8d-123) then
        tmp = -1.0d0
    else if (y <= 2.3d-105) then
        tmp = x * 0.5d0
    else if (y <= 2900000.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 <= -2.2e+114) {
		tmp = t_0;
	} else if (y <= -2.65e-210) {
		tmp = -1.0;
	} else if (y <= -6e-306) {
		tmp = x * 0.5;
	} else if (y <= 2.8e-123) {
		tmp = -1.0;
	} else if (y <= 2.3e-105) {
		tmp = x * 0.5;
	} else if (y <= 2900000.0) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -2.2e+114:
		tmp = t_0
	elif y <= -2.65e-210:
		tmp = -1.0
	elif y <= -6e-306:
		tmp = x * 0.5
	elif y <= 2.8e-123:
		tmp = -1.0
	elif y <= 2.3e-105:
		tmp = x * 0.5
	elif y <= 2900000.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 <= -2.2e+114)
		tmp = t_0;
	elseif (y <= -2.65e-210)
		tmp = -1.0;
	elseif (y <= -6e-306)
		tmp = Float64(x * 0.5);
	elseif (y <= 2.8e-123)
		tmp = -1.0;
	elseif (y <= 2.3e-105)
		tmp = Float64(x * 0.5);
	elseif (y <= 2900000.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 <= -2.2e+114)
		tmp = t_0;
	elseif (y <= -2.65e-210)
		tmp = -1.0;
	elseif (y <= -6e-306)
		tmp = x * 0.5;
	elseif (y <= 2.8e-123)
		tmp = -1.0;
	elseif (y <= 2.3e-105)
		tmp = x * 0.5;
	elseif (y <= 2900000.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, -2.2e+114], t$95$0, If[LessEqual[y, -2.65e-210], -1.0, If[LessEqual[y, -6e-306], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2.8e-123], -1.0, If[LessEqual[y, 2.3e-105], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2900000.0], -1.0, t$95$0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -2.65 \cdot 10^{-210}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;y \leq 2.8 \cdot 10^{-123}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 2.3 \cdot 10^{-105}:\\
\;\;\;\;x \cdot 0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.2e114 or 2.9e6 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -2.2e114 < y < -2.65e-210 or -6.00000000000000048e-306 < y < 2.7999999999999999e-123 or 2.3000000000000001e-105 < y < 2.9e6

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

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

    if -2.65e-210 < y < -6.00000000000000048e-306 or 2.7999999999999999e-123 < y < 2.3000000000000001e-105

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified55.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+114}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -2.65 \cdot 10^{-210}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -6 \cdot 10^{-306}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-123}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-105}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2900000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 3: 60.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -2.2 \cdot 10^{+112}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.45 \cdot 10^{-213}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-305}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-123}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-105}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2900000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -2.2e+112)
     t_0
     (if (<= y -2.45e-213)
       (+ (/ y x) -1.0)
       (if (<= y -1.35e-305)
         (* x 0.5)
         (if (<= y 5.4e-123)
           -1.0
           (if (<= y 2.3e-105) (* x 0.5) (if (<= y 2900000.0) -1.0 t_0))))))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -2.2e+112) {
		tmp = t_0;
	} else if (y <= -2.45e-213) {
		tmp = (y / x) + -1.0;
	} else if (y <= -1.35e-305) {
		tmp = x * 0.5;
	} else if (y <= 5.4e-123) {
		tmp = -1.0;
	} else if (y <= 2.3e-105) {
		tmp = x * 0.5;
	} else if (y <= 2900000.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 <= (-2.2d+112)) then
        tmp = t_0
    else if (y <= (-2.45d-213)) then
        tmp = (y / x) + (-1.0d0)
    else if (y <= (-1.35d-305)) then
        tmp = x * 0.5d0
    else if (y <= 5.4d-123) then
        tmp = -1.0d0
    else if (y <= 2.3d-105) then
        tmp = x * 0.5d0
    else if (y <= 2900000.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 <= -2.2e+112) {
		tmp = t_0;
	} else if (y <= -2.45e-213) {
		tmp = (y / x) + -1.0;
	} else if (y <= -1.35e-305) {
		tmp = x * 0.5;
	} else if (y <= 5.4e-123) {
		tmp = -1.0;
	} else if (y <= 2.3e-105) {
		tmp = x * 0.5;
	} else if (y <= 2900000.0) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -2.2e+112:
		tmp = t_0
	elif y <= -2.45e-213:
		tmp = (y / x) + -1.0
	elif y <= -1.35e-305:
		tmp = x * 0.5
	elif y <= 5.4e-123:
		tmp = -1.0
	elif y <= 2.3e-105:
		tmp = x * 0.5
	elif y <= 2900000.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 <= -2.2e+112)
		tmp = t_0;
	elseif (y <= -2.45e-213)
		tmp = Float64(Float64(y / x) + -1.0);
	elseif (y <= -1.35e-305)
		tmp = Float64(x * 0.5);
	elseif (y <= 5.4e-123)
		tmp = -1.0;
	elseif (y <= 2.3e-105)
		tmp = Float64(x * 0.5);
	elseif (y <= 2900000.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 <= -2.2e+112)
		tmp = t_0;
	elseif (y <= -2.45e-213)
		tmp = (y / x) + -1.0;
	elseif (y <= -1.35e-305)
		tmp = x * 0.5;
	elseif (y <= 5.4e-123)
		tmp = -1.0;
	elseif (y <= 2.3e-105)
		tmp = x * 0.5;
	elseif (y <= 2900000.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, -2.2e+112], t$95$0, If[LessEqual[y, -2.45e-213], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, -1.35e-305], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.4e-123], -1.0, If[LessEqual[y, 2.3e-105], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2900000.0], -1.0, t$95$0]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -1.35 \cdot 10^{-305}:\\
\;\;\;\;x \cdot 0.5\\

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

\mathbf{elif}\;y \leq 2.3 \cdot 10^{-105}:\\
\;\;\;\;x \cdot 0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.1999999999999999e112 or 2.9e6 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -2.1999999999999999e112 < y < -2.4499999999999999e-213

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

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

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

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

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

    if -2.4499999999999999e-213 < y < -1.35e-305 or 5.4000000000000002e-123 < y < 2.3000000000000001e-105

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified55.1%

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

    if -1.35e-305 < y < 5.4000000000000002e-123 or 2.3000000000000001e-105 < y < 2.9e6

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+112}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -2.45 \cdot 10^{-213}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-305}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-123}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-105}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2900000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 4: 83.6% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \leq -6.6 \cdot 10^{+37}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -0.215:\\
\;\;\;\;\frac{x}{2 - x}\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{+137}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -6.39999999999999964e73

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

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

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

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

    if -6.39999999999999964e73 < x < -6.6000000000000002e37 or -0.214999999999999997 < x < 1.15e137

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

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

    if -6.6000000000000002e37 < x < -0.214999999999999997

    1. Initial program 99.8%

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

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

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

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

    if 1.15e137 < 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. Taylor expanded in x around inf 86.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.4 \cdot 10^{+73}:\\ \;\;\;\;\frac{x - y}{-x}\\ \mathbf{elif}\;x \leq -6.6 \cdot 10^{+37}:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \mathbf{elif}\;x \leq -0.215:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+137}:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]

Alternative 5: 59.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+112}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{-211}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-307}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{-121}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-100}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1700000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.2e+112)
   1.0
   (if (<= y -1.22e-211)
     -1.0
     (if (<= y -8.5e-307)
       (* x 0.5)
       (if (<= y 2.15e-121)
         -1.0
         (if (<= y 1.1e-100) (* x 0.5) (if (<= y 1700000.0) -1.0 1.0)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.2e+112) {
		tmp = 1.0;
	} else if (y <= -1.22e-211) {
		tmp = -1.0;
	} else if (y <= -8.5e-307) {
		tmp = x * 0.5;
	} else if (y <= 2.15e-121) {
		tmp = -1.0;
	} else if (y <= 1.1e-100) {
		tmp = x * 0.5;
	} else if (y <= 1700000.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 <= (-2.2d+112)) then
        tmp = 1.0d0
    else if (y <= (-1.22d-211)) then
        tmp = -1.0d0
    else if (y <= (-8.5d-307)) then
        tmp = x * 0.5d0
    else if (y <= 2.15d-121) then
        tmp = -1.0d0
    else if (y <= 1.1d-100) then
        tmp = x * 0.5d0
    else if (y <= 1700000.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 <= -2.2e+112) {
		tmp = 1.0;
	} else if (y <= -1.22e-211) {
		tmp = -1.0;
	} else if (y <= -8.5e-307) {
		tmp = x * 0.5;
	} else if (y <= 2.15e-121) {
		tmp = -1.0;
	} else if (y <= 1.1e-100) {
		tmp = x * 0.5;
	} else if (y <= 1700000.0) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.2e+112:
		tmp = 1.0
	elif y <= -1.22e-211:
		tmp = -1.0
	elif y <= -8.5e-307:
		tmp = x * 0.5
	elif y <= 2.15e-121:
		tmp = -1.0
	elif y <= 1.1e-100:
		tmp = x * 0.5
	elif y <= 1700000.0:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.2e+112)
		tmp = 1.0;
	elseif (y <= -1.22e-211)
		tmp = -1.0;
	elseif (y <= -8.5e-307)
		tmp = Float64(x * 0.5);
	elseif (y <= 2.15e-121)
		tmp = -1.0;
	elseif (y <= 1.1e-100)
		tmp = Float64(x * 0.5);
	elseif (y <= 1700000.0)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.2e+112)
		tmp = 1.0;
	elseif (y <= -1.22e-211)
		tmp = -1.0;
	elseif (y <= -8.5e-307)
		tmp = x * 0.5;
	elseif (y <= 2.15e-121)
		tmp = -1.0;
	elseif (y <= 1.1e-100)
		tmp = x * 0.5;
	elseif (y <= 1700000.0)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.2e+112], 1.0, If[LessEqual[y, -1.22e-211], -1.0, If[LessEqual[y, -8.5e-307], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2.15e-121], -1.0, If[LessEqual[y, 1.1e-100], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1700000.0], -1.0, 1.0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.22 \cdot 10^{-211}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq -8.5 \cdot 10^{-307}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 2.15 \cdot 10^{-121}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-100}:\\
\;\;\;\;x \cdot 0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.1999999999999999e112 or 1.7e6 < y

    1. Initial program 100.0%

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

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

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

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

    if -2.1999999999999999e112 < y < -1.21999999999999996e-211 or -8.4999999999999995e-307 < y < 2.14999999999999983e-121 or 1.09999999999999995e-100 < y < 1.7e6

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

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

    if -1.21999999999999996e-211 < y < -8.4999999999999995e-307 or 2.14999999999999983e-121 < y < 1.09999999999999995e-100

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified55.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+112}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{-211}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-307}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{-121}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-100}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1700000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 72.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+112}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-97}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-y}{2 - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.2e+112)
   (- 1.0 (/ x y))
   (if (<= y 3.6e-97) (/ x (- 2.0 x)) (/ (- y) (- 2.0 y)))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.2e+112) {
		tmp = 1.0 - (x / y);
	} else if (y <= 3.6e-97) {
		tmp = x / (2.0 - x);
	} else {
		tmp = -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 (y <= (-2.2d+112)) then
        tmp = 1.0d0 - (x / y)
    else if (y <= 3.6d-97) then
        tmp = x / (2.0d0 - x)
    else
        tmp = -y / (2.0d0 - y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.2e+112) {
		tmp = 1.0 - (x / y);
	} else if (y <= 3.6e-97) {
		tmp = x / (2.0 - x);
	} else {
		tmp = -y / (2.0 - y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.2e+112:
		tmp = 1.0 - (x / y)
	elif y <= 3.6e-97:
		tmp = x / (2.0 - x)
	else:
		tmp = -y / (2.0 - y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.2e+112)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (y <= 3.6e-97)
		tmp = Float64(x / Float64(2.0 - x));
	else
		tmp = Float64(Float64(-y) / Float64(2.0 - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.2e+112)
		tmp = 1.0 - (x / y);
	elseif (y <= 3.6e-97)
		tmp = x / (2.0 - x);
	else
		tmp = -y / (2.0 - y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.2e+112], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e-97], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[((-y) / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.1999999999999999e112

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

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

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

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

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

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

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

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

    if -2.1999999999999999e112 < y < 3.59999999999999997e-97

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

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

    if 3.59999999999999997e-97 < y

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{\frac{x - y}{\left(2 - x\right) - y}} \]
    4. Taylor expanded in 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}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+112}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-97}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-y}{2 - y}\\ \end{array} \]

Alternative 7: 73.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+112} \lor \neg \left(y \leq 1900000000\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -2.2e+112) (not (<= y 1900000000.0)))
   (- 1.0 (/ x y))
   (/ x (- 2.0 x))))
double code(double x, double y) {
	double tmp;
	if ((y <= -2.2e+112) || !(y <= 1900000000.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 <= (-2.2d+112)) .or. (.not. (y <= 1900000000.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 <= -2.2e+112) || !(y <= 1900000000.0)) {
		tmp = 1.0 - (x / y);
	} else {
		tmp = x / (2.0 - x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -2.2e+112) or not (y <= 1900000000.0):
		tmp = 1.0 - (x / y)
	else:
		tmp = x / (2.0 - x)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -2.2e+112) || !(y <= 1900000000.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 <= -2.2e+112) || ~((y <= 1900000000.0)))
		tmp = 1.0 - (x / y);
	else
		tmp = x / (2.0 - x);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -2.2e+112], N[Not[LessEqual[y, 1900000000.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 -2.2 \cdot 10^{+112} \lor \neg \left(y \leq 1900000000\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 < -2.1999999999999999e112 or 1.9e9 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -2.1999999999999999e112 < y < 1.9e9

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

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

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

Alternative 8: 61.0% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.3500000000000002e116 or 7.8e7 < y

    1. Initial program 100.0%

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

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

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

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

    if -2.3500000000000002e116 < y < 7.8e7

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

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

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

Alternative 9: 38.1% accurate, 9.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
	return -1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = -1.0d0
end function
public static double code(double x, double y) {
	return -1.0;
}
def code(x, y):
	return -1.0
function code(x, y)
	return -1.0
end
function tmp = code(x, y)
	tmp = -1.0;
end
code[x_, y_] := -1.0
\begin{array}{l}

\\
-1
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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