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

Percentage Accurate: 100.0% → 100.0%
Time: 5.5s
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. Final simplification100.0%

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

Alternative 2: 60.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x} + -1\\ \mathbf{if}\;y \leq -1.52 \cdot 10^{+60}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-281}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{-238}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-156}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-147}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-124}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+66}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (/ y x) -1.0)))
   (if (<= y -1.52e+60)
     1.0
     (if (<= y -1.3e-281)
       t_0
       (if (<= y 1.12e-238)
         (* x 0.5)
         (if (<= y 4.2e-156)
           -1.0
           (if (<= y 2.4e-147)
             (* x 0.5)
             (if (<= y 8.6e-124)
               (* y -0.5)
               (if (<= y 1.35e+66) t_0 1.0)))))))))
double code(double x, double y) {
	double t_0 = (y / x) + -1.0;
	double tmp;
	if (y <= -1.52e+60) {
		tmp = 1.0;
	} else if (y <= -1.3e-281) {
		tmp = t_0;
	} else if (y <= 1.12e-238) {
		tmp = x * 0.5;
	} else if (y <= 4.2e-156) {
		tmp = -1.0;
	} else if (y <= 2.4e-147) {
		tmp = x * 0.5;
	} else if (y <= 8.6e-124) {
		tmp = y * -0.5;
	} else if (y <= 1.35e+66) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (y / x) + (-1.0d0)
    if (y <= (-1.52d+60)) then
        tmp = 1.0d0
    else if (y <= (-1.3d-281)) then
        tmp = t_0
    else if (y <= 1.12d-238) then
        tmp = x * 0.5d0
    else if (y <= 4.2d-156) then
        tmp = -1.0d0
    else if (y <= 2.4d-147) then
        tmp = x * 0.5d0
    else if (y <= 8.6d-124) then
        tmp = y * (-0.5d0)
    else if (y <= 1.35d+66) then
        tmp = t_0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (y / x) + -1.0;
	double tmp;
	if (y <= -1.52e+60) {
		tmp = 1.0;
	} else if (y <= -1.3e-281) {
		tmp = t_0;
	} else if (y <= 1.12e-238) {
		tmp = x * 0.5;
	} else if (y <= 4.2e-156) {
		tmp = -1.0;
	} else if (y <= 2.4e-147) {
		tmp = x * 0.5;
	} else if (y <= 8.6e-124) {
		tmp = y * -0.5;
	} else if (y <= 1.35e+66) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y / x) + -1.0
	tmp = 0
	if y <= -1.52e+60:
		tmp = 1.0
	elif y <= -1.3e-281:
		tmp = t_0
	elif y <= 1.12e-238:
		tmp = x * 0.5
	elif y <= 4.2e-156:
		tmp = -1.0
	elif y <= 2.4e-147:
		tmp = x * 0.5
	elif y <= 8.6e-124:
		tmp = y * -0.5
	elif y <= 1.35e+66:
		tmp = t_0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y / x) + -1.0)
	tmp = 0.0
	if (y <= -1.52e+60)
		tmp = 1.0;
	elseif (y <= -1.3e-281)
		tmp = t_0;
	elseif (y <= 1.12e-238)
		tmp = Float64(x * 0.5);
	elseif (y <= 4.2e-156)
		tmp = -1.0;
	elseif (y <= 2.4e-147)
		tmp = Float64(x * 0.5);
	elseif (y <= 8.6e-124)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.35e+66)
		tmp = t_0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y / x) + -1.0;
	tmp = 0.0;
	if (y <= -1.52e+60)
		tmp = 1.0;
	elseif (y <= -1.3e-281)
		tmp = t_0;
	elseif (y <= 1.12e-238)
		tmp = x * 0.5;
	elseif (y <= 4.2e-156)
		tmp = -1.0;
	elseif (y <= 2.4e-147)
		tmp = x * 0.5;
	elseif (y <= 8.6e-124)
		tmp = y * -0.5;
	elseif (y <= 1.35e+66)
		tmp = t_0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[y, -1.52e+60], 1.0, If[LessEqual[y, -1.3e-281], t$95$0, If[LessEqual[y, 1.12e-238], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4.2e-156], -1.0, If[LessEqual[y, 2.4e-147], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 8.6e-124], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.35e+66], t$95$0, 1.0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.3 \cdot 10^{-281}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.12 \cdot 10^{-238}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 4.2 \cdot 10^{-156}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 2.4 \cdot 10^{-147}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 8.6 \cdot 10^{-124}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+66}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -1.52e60 or 1.35e66 < 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 87.4%

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

    if -1.52e60 < y < -1.30000000000000002e-281 or 8.6e-124 < y < 1.35e66

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -1.30000000000000002e-281 < y < 1.12000000000000005e-238 or 4.20000000000000025e-156 < y < 2.39999999999999998e-147

    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 0 91.6%

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

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

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

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

    if 1.12000000000000005e-238 < y < 4.20000000000000025e-156

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

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

    if 2.39999999999999998e-147 < y < 8.6e-124

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.52 \cdot 10^{+60}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-281}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{-238}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-156}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-147}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-124}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+66}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 3: 60.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{+60}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-282}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-242}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-155}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-147}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-125}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+65}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.4e+60)
   1.0
   (if (<= y -4.8e-282)
     -1.0
     (if (<= y 2.9e-242)
       (* x 0.5)
       (if (<= y 1.3e-155)
         -1.0
         (if (<= y 2.4e-147)
           (* x 0.5)
           (if (<= y 7.5e-125) (* y -0.5) (if (<= y 2.2e+65) -1.0 1.0))))))))
double code(double x, double y) {
	double tmp;
	if (y <= -1.4e+60) {
		tmp = 1.0;
	} else if (y <= -4.8e-282) {
		tmp = -1.0;
	} else if (y <= 2.9e-242) {
		tmp = x * 0.5;
	} else if (y <= 1.3e-155) {
		tmp = -1.0;
	} else if (y <= 2.4e-147) {
		tmp = x * 0.5;
	} else if (y <= 7.5e-125) {
		tmp = y * -0.5;
	} else if (y <= 2.2e+65) {
		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.4d+60)) then
        tmp = 1.0d0
    else if (y <= (-4.8d-282)) then
        tmp = -1.0d0
    else if (y <= 2.9d-242) then
        tmp = x * 0.5d0
    else if (y <= 1.3d-155) then
        tmp = -1.0d0
    else if (y <= 2.4d-147) then
        tmp = x * 0.5d0
    else if (y <= 7.5d-125) then
        tmp = y * (-0.5d0)
    else if (y <= 2.2d+65) 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.4e+60) {
		tmp = 1.0;
	} else if (y <= -4.8e-282) {
		tmp = -1.0;
	} else if (y <= 2.9e-242) {
		tmp = x * 0.5;
	} else if (y <= 1.3e-155) {
		tmp = -1.0;
	} else if (y <= 2.4e-147) {
		tmp = x * 0.5;
	} else if (y <= 7.5e-125) {
		tmp = y * -0.5;
	} else if (y <= 2.2e+65) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.4e+60:
		tmp = 1.0
	elif y <= -4.8e-282:
		tmp = -1.0
	elif y <= 2.9e-242:
		tmp = x * 0.5
	elif y <= 1.3e-155:
		tmp = -1.0
	elif y <= 2.4e-147:
		tmp = x * 0.5
	elif y <= 7.5e-125:
		tmp = y * -0.5
	elif y <= 2.2e+65:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.4e+60)
		tmp = 1.0;
	elseif (y <= -4.8e-282)
		tmp = -1.0;
	elseif (y <= 2.9e-242)
		tmp = Float64(x * 0.5);
	elseif (y <= 1.3e-155)
		tmp = -1.0;
	elseif (y <= 2.4e-147)
		tmp = Float64(x * 0.5);
	elseif (y <= 7.5e-125)
		tmp = Float64(y * -0.5);
	elseif (y <= 2.2e+65)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.4e+60)
		tmp = 1.0;
	elseif (y <= -4.8e-282)
		tmp = -1.0;
	elseif (y <= 2.9e-242)
		tmp = x * 0.5;
	elseif (y <= 1.3e-155)
		tmp = -1.0;
	elseif (y <= 2.4e-147)
		tmp = x * 0.5;
	elseif (y <= 7.5e-125)
		tmp = y * -0.5;
	elseif (y <= 2.2e+65)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.4e+60], 1.0, If[LessEqual[y, -4.8e-282], -1.0, If[LessEqual[y, 2.9e-242], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.3e-155], -1.0, If[LessEqual[y, 2.4e-147], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 7.5e-125], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2.2e+65], -1.0, 1.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -4.8 \cdot 10^{-282}:\\
\;\;\;\;-1\\

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

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

\mathbf{elif}\;y \leq 2.4 \cdot 10^{-147}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 7.5 \cdot 10^{-125}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 2.2 \cdot 10^{+65}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.4e60 or 2.1999999999999998e65 < 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 87.4%

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

    if -1.4e60 < y < -4.79999999999999994e-282 or 2.9000000000000001e-242 < y < 1.30000000000000004e-155 or 7.5e-125 < y < 2.1999999999999998e65

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

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

    if -4.79999999999999994e-282 < y < 2.9000000000000001e-242 or 1.30000000000000004e-155 < y < 2.39999999999999998e-147

    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 0 91.6%

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

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

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

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

    if 2.39999999999999998e-147 < y < 7.5e-125

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{+60}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-282}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-242}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-155}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-147}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-125}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+65}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 4: 74.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+60} \lor \neg \left(y \leq 2.2 \cdot 10^{+65}\right):\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.1000000000000001e60 or 2.1999999999999998e65 < 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 88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1000000000000001e60 < y < 2.1999999999999998e65

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

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

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

Alternative 5: 60.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{+60}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{-282}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-236}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+66}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3e+60)
   1.0
   (if (<= y -3.2e-282)
     -1.0
     (if (<= y 8.2e-236) (* x 0.5) (if (<= y 4e+66) -1.0 1.0)))))
double code(double x, double y) {
	double tmp;
	if (y <= -3e+60) {
		tmp = 1.0;
	} else if (y <= -3.2e-282) {
		tmp = -1.0;
	} else if (y <= 8.2e-236) {
		tmp = x * 0.5;
	} else if (y <= 4e+66) {
		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 <= (-3d+60)) then
        tmp = 1.0d0
    else if (y <= (-3.2d-282)) then
        tmp = -1.0d0
    else if (y <= 8.2d-236) then
        tmp = x * 0.5d0
    else if (y <= 4d+66) 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 <= -3e+60) {
		tmp = 1.0;
	} else if (y <= -3.2e-282) {
		tmp = -1.0;
	} else if (y <= 8.2e-236) {
		tmp = x * 0.5;
	} else if (y <= 4e+66) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3e+60:
		tmp = 1.0
	elif y <= -3.2e-282:
		tmp = -1.0
	elif y <= 8.2e-236:
		tmp = x * 0.5
	elif y <= 4e+66:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3e+60)
		tmp = 1.0;
	elseif (y <= -3.2e-282)
		tmp = -1.0;
	elseif (y <= 8.2e-236)
		tmp = Float64(x * 0.5);
	elseif (y <= 4e+66)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -3e+60)
		tmp = 1.0;
	elseif (y <= -3.2e-282)
		tmp = -1.0;
	elseif (y <= 8.2e-236)
		tmp = x * 0.5;
	elseif (y <= 4e+66)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -3e+60], 1.0, If[LessEqual[y, -3.2e-282], -1.0, If[LessEqual[y, 8.2e-236], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4e+66], -1.0, 1.0]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -3.2 \cdot 10^{-282}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 8.2 \cdot 10^{-236}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 4 \cdot 10^{+66}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.9999999999999998e60 or 3.99999999999999978e66 < 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 87.4%

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

    if -2.9999999999999998e60 < y < -3.19999999999999983e-282 or 8.2000000000000006e-236 < y < 3.99999999999999978e66

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

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

    if -3.19999999999999983e-282 < y < 8.2000000000000006e-236

    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 0 94.8%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified67.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{+60}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{-282}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-236}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+66}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 73.5% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.3500000000000001e61 or 6.20000000000000037e66 < 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 87.4%

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

    if -1.3500000000000001e61 < y < 6.20000000000000037e66

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{+61}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+66}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 7: 61.6% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;y \leq 4 \cdot 10^{+65}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.49999999999999931e60 or 4e65 < 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 87.4%

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

    if -6.49999999999999931e60 < y < 4e65

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+60}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+65}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 38.0% 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 37.9%

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

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