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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.6× speedup?

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

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

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

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

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

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

Alternative 2: 60.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x} + -1\\ t_1 := 1 - \frac{x}{y}\\ \mathbf{if}\;x \leq -6.2 \cdot 10^{+50}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-125}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{-269}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-168}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 480000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (/ y x) -1.0)) (t_1 (- 1.0 (/ x y))))
   (if (<= x -6.2e+50)
     t_0
     (if (<= x -1.45e-13)
       t_1
       (if (<= x -4.6e-125)
         (* x 0.5)
         (if (<= x 2.45e-269)
           t_1
           (if (<= x 1.1e-168) (* y -0.5) (if (<= x 480000.0) 1.0 t_0))))))))
double code(double x, double y) {
	double t_0 = (y / x) + -1.0;
	double t_1 = 1.0 - (x / y);
	double tmp;
	if (x <= -6.2e+50) {
		tmp = t_0;
	} else if (x <= -1.45e-13) {
		tmp = t_1;
	} else if (x <= -4.6e-125) {
		tmp = x * 0.5;
	} else if (x <= 2.45e-269) {
		tmp = t_1;
	} else if (x <= 1.1e-168) {
		tmp = y * -0.5;
	} else if (x <= 480000.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) :: t_1
    real(8) :: tmp
    t_0 = (y / x) + (-1.0d0)
    t_1 = 1.0d0 - (x / y)
    if (x <= (-6.2d+50)) then
        tmp = t_0
    else if (x <= (-1.45d-13)) then
        tmp = t_1
    else if (x <= (-4.6d-125)) then
        tmp = x * 0.5d0
    else if (x <= 2.45d-269) then
        tmp = t_1
    else if (x <= 1.1d-168) then
        tmp = y * (-0.5d0)
    else if (x <= 480000.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 = (y / x) + -1.0;
	double t_1 = 1.0 - (x / y);
	double tmp;
	if (x <= -6.2e+50) {
		tmp = t_0;
	} else if (x <= -1.45e-13) {
		tmp = t_1;
	} else if (x <= -4.6e-125) {
		tmp = x * 0.5;
	} else if (x <= 2.45e-269) {
		tmp = t_1;
	} else if (x <= 1.1e-168) {
		tmp = y * -0.5;
	} else if (x <= 480000.0) {
		tmp = 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y / x) + -1.0
	t_1 = 1.0 - (x / y)
	tmp = 0
	if x <= -6.2e+50:
		tmp = t_0
	elif x <= -1.45e-13:
		tmp = t_1
	elif x <= -4.6e-125:
		tmp = x * 0.5
	elif x <= 2.45e-269:
		tmp = t_1
	elif x <= 1.1e-168:
		tmp = y * -0.5
	elif x <= 480000.0:
		tmp = 1.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y / x) + -1.0)
	t_1 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (x <= -6.2e+50)
		tmp = t_0;
	elseif (x <= -1.45e-13)
		tmp = t_1;
	elseif (x <= -4.6e-125)
		tmp = Float64(x * 0.5);
	elseif (x <= 2.45e-269)
		tmp = t_1;
	elseif (x <= 1.1e-168)
		tmp = Float64(y * -0.5);
	elseif (x <= 480000.0)
		tmp = 1.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y / x) + -1.0;
	t_1 = 1.0 - (x / y);
	tmp = 0.0;
	if (x <= -6.2e+50)
		tmp = t_0;
	elseif (x <= -1.45e-13)
		tmp = t_1;
	elseif (x <= -4.6e-125)
		tmp = x * 0.5;
	elseif (x <= 2.45e-269)
		tmp = t_1;
	elseif (x <= 1.1e-168)
		tmp = y * -0.5;
	elseif (x <= 480000.0)
		tmp = 1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.2e+50], t$95$0, If[LessEqual[x, -1.45e-13], t$95$1, If[LessEqual[x, -4.6e-125], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2.45e-269], t$95$1, If[LessEqual[x, 1.1e-168], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 480000.0], 1.0, t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.45 \cdot 10^{-13}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 2.45 \cdot 10^{-269}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 480000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -6.20000000000000006e50 or 4.8e5 < x

    1. Initial program 100.0%

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

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

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

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

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

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

    if -6.20000000000000006e50 < x < -1.4499999999999999e-13 or -4.5999999999999998e-125 < x < 2.45e-269

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. clear-num99.8%

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

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

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

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

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

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

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

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

    if -1.4499999999999999e-13 < x < -4.5999999999999998e-125

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    5. Simplified57.9%

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

    if 2.45e-269 < x < 1.0999999999999999e-168

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around 0 82.9%

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    4. Simplified82.9%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified57.8%

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

    if 1.0999999999999999e-168 < x < 4.8e5

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around inf 78.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{+50}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-13}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-125}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{-269}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-168}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 480000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]

Alternative 3: 60.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+52}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-14}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{-125}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-269}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-168}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 600000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -9e+52)
   -1.0
   (if (<= x -2.3e-14)
     1.0
     (if (<= x -1.8e-125)
       (* x 0.5)
       (if (<= x 3.4e-269)
         1.0
         (if (<= x 1.1e-168) (* y -0.5) (if (<= x 600000.0) 1.0 -1.0)))))))
double code(double x, double y) {
	double tmp;
	if (x <= -9e+52) {
		tmp = -1.0;
	} else if (x <= -2.3e-14) {
		tmp = 1.0;
	} else if (x <= -1.8e-125) {
		tmp = x * 0.5;
	} else if (x <= 3.4e-269) {
		tmp = 1.0;
	} else if (x <= 1.1e-168) {
		tmp = y * -0.5;
	} else if (x <= 600000.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 (x <= (-9d+52)) then
        tmp = -1.0d0
    else if (x <= (-2.3d-14)) then
        tmp = 1.0d0
    else if (x <= (-1.8d-125)) then
        tmp = x * 0.5d0
    else if (x <= 3.4d-269) then
        tmp = 1.0d0
    else if (x <= 1.1d-168) then
        tmp = y * (-0.5d0)
    else if (x <= 600000.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 (x <= -9e+52) {
		tmp = -1.0;
	} else if (x <= -2.3e-14) {
		tmp = 1.0;
	} else if (x <= -1.8e-125) {
		tmp = x * 0.5;
	} else if (x <= 3.4e-269) {
		tmp = 1.0;
	} else if (x <= 1.1e-168) {
		tmp = y * -0.5;
	} else if (x <= 600000.0) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -9e+52:
		tmp = -1.0
	elif x <= -2.3e-14:
		tmp = 1.0
	elif x <= -1.8e-125:
		tmp = x * 0.5
	elif x <= 3.4e-269:
		tmp = 1.0
	elif x <= 1.1e-168:
		tmp = y * -0.5
	elif x <= 600000.0:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -9e+52)
		tmp = -1.0;
	elseif (x <= -2.3e-14)
		tmp = 1.0;
	elseif (x <= -1.8e-125)
		tmp = Float64(x * 0.5);
	elseif (x <= 3.4e-269)
		tmp = 1.0;
	elseif (x <= 1.1e-168)
		tmp = Float64(y * -0.5);
	elseif (x <= 600000.0)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -9e+52)
		tmp = -1.0;
	elseif (x <= -2.3e-14)
		tmp = 1.0;
	elseif (x <= -1.8e-125)
		tmp = x * 0.5;
	elseif (x <= 3.4e-269)
		tmp = 1.0;
	elseif (x <= 1.1e-168)
		tmp = y * -0.5;
	elseif (x <= 600000.0)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -9e+52], -1.0, If[LessEqual[x, -2.3e-14], 1.0, If[LessEqual[x, -1.8e-125], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3.4e-269], 1.0, If[LessEqual[x, 1.1e-168], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 600000.0], 1.0, -1.0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.3 \cdot 10^{-14}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -1.8 \cdot 10^{-125}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 3.4 \cdot 10^{-269}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 600000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -8.9999999999999999e52 or 6e5 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around inf 75.2%

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

    if -8.9999999999999999e52 < x < -2.29999999999999998e-14 or -1.8000000000000001e-125 < x < 3.3999999999999997e-269 or 1.0999999999999999e-168 < x < 6e5

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around inf 61.7%

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

    if -2.29999999999999998e-14 < x < -1.8000000000000001e-125

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    5. Simplified57.9%

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

    if 3.3999999999999997e-269 < x < 1.0999999999999999e-168

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around 0 82.9%

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    4. Simplified82.9%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified57.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+52}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-14}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{-125}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-269}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-168}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 600000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 4: 60.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;x \leq -2.2 \cdot 10^{+48}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-128}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-269}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-165}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 550000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= x -2.2e+48)
     -1.0
     (if (<= x -4.5e-16)
       t_0
       (if (<= x -4.8e-128)
         (* x 0.5)
         (if (<= x 1.4e-269)
           t_0
           (if (<= x 1.7e-165) (* y -0.5) (if (<= x 550000.0) 1.0 -1.0))))))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (x <= -2.2e+48) {
		tmp = -1.0;
	} else if (x <= -4.5e-16) {
		tmp = t_0;
	} else if (x <= -4.8e-128) {
		tmp = x * 0.5;
	} else if (x <= 1.4e-269) {
		tmp = t_0;
	} else if (x <= 1.7e-165) {
		tmp = y * -0.5;
	} else if (x <= 550000.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) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    if (x <= (-2.2d+48)) then
        tmp = -1.0d0
    else if (x <= (-4.5d-16)) then
        tmp = t_0
    else if (x <= (-4.8d-128)) then
        tmp = x * 0.5d0
    else if (x <= 1.4d-269) then
        tmp = t_0
    else if (x <= 1.7d-165) then
        tmp = y * (-0.5d0)
    else if (x <= 550000.0d0) then
        tmp = 1.0d0
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (x <= -2.2e+48) {
		tmp = -1.0;
	} else if (x <= -4.5e-16) {
		tmp = t_0;
	} else if (x <= -4.8e-128) {
		tmp = x * 0.5;
	} else if (x <= 1.4e-269) {
		tmp = t_0;
	} else if (x <= 1.7e-165) {
		tmp = y * -0.5;
	} else if (x <= 550000.0) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if x <= -2.2e+48:
		tmp = -1.0
	elif x <= -4.5e-16:
		tmp = t_0
	elif x <= -4.8e-128:
		tmp = x * 0.5
	elif x <= 1.4e-269:
		tmp = t_0
	elif x <= 1.7e-165:
		tmp = y * -0.5
	elif x <= 550000.0:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (x <= -2.2e+48)
		tmp = -1.0;
	elseif (x <= -4.5e-16)
		tmp = t_0;
	elseif (x <= -4.8e-128)
		tmp = Float64(x * 0.5);
	elseif (x <= 1.4e-269)
		tmp = t_0;
	elseif (x <= 1.7e-165)
		tmp = Float64(y * -0.5);
	elseif (x <= 550000.0)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (x <= -2.2e+48)
		tmp = -1.0;
	elseif (x <= -4.5e-16)
		tmp = t_0;
	elseif (x <= -4.8e-128)
		tmp = x * 0.5;
	elseif (x <= 1.4e-269)
		tmp = t_0;
	elseif (x <= 1.7e-165)
		tmp = y * -0.5;
	elseif (x <= 550000.0)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.2e+48], -1.0, If[LessEqual[x, -4.5e-16], t$95$0, If[LessEqual[x, -4.8e-128], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.4e-269], t$95$0, If[LessEqual[x, 1.7e-165], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 550000.0], 1.0, -1.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -4.5 \cdot 10^{-16}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-269}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.7 \cdot 10^{-165}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 550000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -2.1999999999999999e48 or 5.5e5 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around inf 75.2%

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

    if -2.1999999999999999e48 < x < -4.5000000000000002e-16 or -4.7999999999999996e-128 < x < 1.39999999999999997e-269

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Step-by-step derivation
      1. clear-num99.8%

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

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

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

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

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

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

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

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

    if -4.5000000000000002e-16 < x < -4.7999999999999996e-128

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    5. Simplified57.9%

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

    if 1.39999999999999997e-269 < x < 1.7e-165

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around 0 82.9%

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    4. Simplified82.9%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    7. Simplified57.8%

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

    if 1.7e-165 < x < 5.5e5

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around inf 78.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.2 \cdot 10^{+48}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-16}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-128}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-269}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-165}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 550000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 5: 74.8% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;x \leq -1.9 \cdot 10^{-31}:\\
\;\;\;\;x \cdot 0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -2.0999999999999998e48

    1. Initial program 100.0%

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

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

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

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

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

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

    if -2.0999999999999998e48 < x < -8.60000000000000046e-17

    1. Initial program 99.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    7. Simplified63.5%

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

    if -8.60000000000000046e-17 < x < -1.9e-31

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 79.6%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    5. Simplified79.6%

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

    if -1.9e-31 < x < 4.30000000000000014e-10

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around 0 82.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.30000000000000014e-10 < x

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 71.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{+48}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq -8.6 \cdot 10^{-17}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-31}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{-10}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]

Alternative 6: 74.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+48}:\\
\;\;\;\;\frac{x - y}{-x}\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -2.0999999999999998e48

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-1}{x} \cdot x + \frac{-1}{x} \cdot \left(-y\right)} \]
    7. Step-by-step derivation
      1. distribute-lft-out81.2%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(x - y\right)}{x}} \]
      4. remove-double-neg81.5%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-\left(-\left(x - y\right)\right)\right)}}{x} \]
      5. neg-mul-181.5%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \left(-\left(x - y\right)\right)\right)}}{x} \]
      6. associate-*r*81.5%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot -1\right) \cdot \left(-\left(x - y\right)\right)}}{x} \]
      7. metadata-eval81.5%

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-\left(x - y\right)\right)}{x} \]
      8. associate-*l/81.2%

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

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

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{x}\right)} \cdot \left(-\left(x - y\right)\right) \]
      11. associate-*l*81.2%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \left(\frac{1}{x} \cdot \left(-\left(x - y\right)\right)\right) \]
      13. associate-*l/81.5%

        \[\leadsto \frac{-1}{-1} \cdot \color{blue}{\frac{1 \cdot \left(-\left(x - y\right)\right)}{x}} \]
      14. metadata-eval81.5%

        \[\leadsto \frac{-1}{-1} \cdot \frac{\color{blue}{\left(--1\right)} \cdot \left(-\left(x - y\right)\right)}{x} \]
      15. distribute-lft-neg-in81.5%

        \[\leadsto \frac{-1}{-1} \cdot \frac{\color{blue}{--1 \cdot \left(-\left(x - y\right)\right)}}{x} \]
      16. neg-mul-181.5%

        \[\leadsto \frac{-1}{-1} \cdot \frac{-\color{blue}{\left(-\left(-\left(x - y\right)\right)\right)}}{x} \]
      17. remove-double-neg81.5%

        \[\leadsto \frac{-1}{-1} \cdot \frac{-\color{blue}{\left(x - y\right)}}{x} \]
      18. times-frac81.5%

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-\left(x - y\right)\right)}{-1 \cdot x}} \]
      19. neg-mul-181.5%

        \[\leadsto \frac{\color{blue}{-\left(-\left(x - y\right)\right)}}{-1 \cdot x} \]
      20. remove-double-neg81.5%

        \[\leadsto \frac{\color{blue}{x - y}}{-1 \cdot x} \]
      21. neg-mul-181.5%

        \[\leadsto \frac{x - y}{\color{blue}{-x}} \]
    8. Simplified81.5%

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

    if -2.0999999999999998e48 < x < -3.29999999999999988e-16

    1. Initial program 99.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    7. Simplified63.5%

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

    if -3.29999999999999988e-16 < x < -1.10000000000000005e-31

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 79.6%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    5. Simplified79.6%

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

    if -1.10000000000000005e-31 < x < 3e-10

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around 0 82.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3e-10 < x

    1. Initial program 99.9%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 71.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{+48}:\\ \;\;\;\;\frac{x - y}{-x}\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-16}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-31}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-10}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]

Alternative 7: 61.0% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq -2 \cdot 10^{-16}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -7 \cdot 10^{-127}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 600000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.99999999999999994e59 or 6e5 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around inf 75.2%

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

    if -1.99999999999999994e59 < x < -2e-16 or -6.99999999999999979e-127 < x < 6e5

    1. Initial program 100.0%

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

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

    if -2e-16 < x < -6.99999999999999979e-127

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    5. Simplified57.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+59}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-16}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-127}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 600000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 8: 75.5% accurate, 1.0× speedup?

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    7. Simplified78.5%

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

    if -5.1e17 < y < 1.65000000000000013e30

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around 0 69.5%

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

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

Alternative 9: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 10: 62.6% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 600000:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.12000000000000005e49 or 6e5 < x

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in x around inf 75.2%

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

    if -1.12000000000000005e49 < x < 6e5

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Taylor expanded in y around inf 52.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.12 \cdot 10^{+49}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 600000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 11: 38.8% 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. Taylor expanded in x around inf 34.9%

    \[\leadsto \color{blue}{-1} \]
  3. Final simplification34.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 2023322 
(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))))