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

Percentage Accurate: 100.0% → 99.9%
Time: 12.0s
Alternatives: 12
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 12 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: 99.9% accurate, 0.7× speedup?

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

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

    \[\frac{x - y}{2 - \left(x + y\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-neg100.0%

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

      \[\leadsto \frac{x - y}{\color{blue}{\frac{2 \cdot 2 - \left(-\left(x + y\right)\right) \cdot \left(-\left(x + y\right)\right)}{2 - \left(-\left(x + y\right)\right)}}} \]
    3. metadata-eval56.4%

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

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

    \[\leadsto \frac{x - y}{\color{blue}{\left(-2 \cdot x + -1 \cdot y\right) - -1 \cdot \left(2 + x\right)}} \]
  6. Step-by-step derivation
    1. neg-mul-1100.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{x - y}{x \cdot -2 + \left(\left(x - y\right) + 2\right)} \]
  9. Add Preprocessing

Alternative 2: 62.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -3.8 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3 \cdot 10^{+56}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -8000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-80}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-31}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+40}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -3.8e+72)
     t_0
     (if (<= y -3e+56)
       -1.0
       (if (<= y -8000000000.0)
         (+ 1.0 (/ 2.0 y))
         (if (<= y 7.8e-80)
           -1.0
           (if (<= y 1.5e-31) (* y -0.5) (if (<= y 1.35e+40) -1.0 t_0))))))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -3.8e+72) {
		tmp = t_0;
	} else if (y <= -3e+56) {
		tmp = -1.0;
	} else if (y <= -8000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 7.8e-80) {
		tmp = -1.0;
	} else if (y <= 1.5e-31) {
		tmp = y * -0.5;
	} else if (y <= 1.35e+40) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    if (y <= (-3.8d+72)) then
        tmp = t_0
    else if (y <= (-3d+56)) then
        tmp = -1.0d0
    else if (y <= (-8000000000.0d0)) then
        tmp = 1.0d0 + (2.0d0 / y)
    else if (y <= 7.8d-80) then
        tmp = -1.0d0
    else if (y <= 1.5d-31) then
        tmp = y * (-0.5d0)
    else if (y <= 1.35d+40) then
        tmp = -1.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -3.8e+72) {
		tmp = t_0;
	} else if (y <= -3e+56) {
		tmp = -1.0;
	} else if (y <= -8000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 7.8e-80) {
		tmp = -1.0;
	} else if (y <= 1.5e-31) {
		tmp = y * -0.5;
	} else if (y <= 1.35e+40) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -3.8e+72:
		tmp = t_0
	elif y <= -3e+56:
		tmp = -1.0
	elif y <= -8000000000.0:
		tmp = 1.0 + (2.0 / y)
	elif y <= 7.8e-80:
		tmp = -1.0
	elif y <= 1.5e-31:
		tmp = y * -0.5
	elif y <= 1.35e+40:
		tmp = -1.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -3.8e+72)
		tmp = t_0;
	elseif (y <= -3e+56)
		tmp = -1.0;
	elseif (y <= -8000000000.0)
		tmp = Float64(1.0 + Float64(2.0 / y));
	elseif (y <= 7.8e-80)
		tmp = -1.0;
	elseif (y <= 1.5e-31)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.35e+40)
		tmp = -1.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -3.8e+72)
		tmp = t_0;
	elseif (y <= -3e+56)
		tmp = -1.0;
	elseif (y <= -8000000000.0)
		tmp = 1.0 + (2.0 / y);
	elseif (y <= 7.8e-80)
		tmp = -1.0;
	elseif (y <= 1.5e-31)
		tmp = y * -0.5;
	elseif (y <= 1.35e+40)
		tmp = -1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.8e+72], t$95$0, If[LessEqual[y, -3e+56], -1.0, If[LessEqual[y, -8000000000.0], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.8e-80], -1.0, If[LessEqual[y, 1.5e-31], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.35e+40], -1.0, t$95$0]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -8000000000:\\
\;\;\;\;1 + \frac{2}{y}\\

\mathbf{elif}\;y \leq 7.8 \cdot 10^{-80}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{-31}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+40}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.80000000000000006e72 or 1.35000000000000005e40 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if -3.80000000000000006e72 < y < -3.00000000000000006e56 or -8e9 < y < 7.7999999999999995e-80 or 1.49999999999999991e-31 < y < 1.35000000000000005e40

    1. Initial program 100.0%

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

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

    if -3.00000000000000006e56 < y < -8e9

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \left(2 + \left(x + -1 \cdot x\right)\right) - -2 \cdot x}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{2 + x \cdot -2}{y}} \]
    8. Taylor expanded in x around 0 78.1%

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

        \[\leadsto 1 + \color{blue}{\frac{2 \cdot 1}{y}} \]
      2. metadata-eval78.1%

        \[\leadsto 1 + \frac{\color{blue}{2}}{y} \]
    10. Simplified78.1%

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

    if 7.7999999999999995e-80 < y < 1.49999999999999991e-31

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-y}}{2 - y} \]
    5. Simplified68.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+72}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -3 \cdot 10^{+56}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -8000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-80}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-31}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+40}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 61.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -2.6 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+55}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -22000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-93}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-29}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.34 \cdot 10^{+39}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -2.6e+72)
     t_0
     (if (<= y -1.3e+55)
       -1.0
       (if (<= y -22000000000.0)
         (+ 1.0 (/ 2.0 y))
         (if (<= y 8.5e-93)
           (+ (/ y x) -1.0)
           (if (<= y 2.45e-29) (* y -0.5) (if (<= y 1.34e+39) -1.0 t_0))))))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -2.6e+72) {
		tmp = t_0;
	} else if (y <= -1.3e+55) {
		tmp = -1.0;
	} else if (y <= -22000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 8.5e-93) {
		tmp = (y / x) + -1.0;
	} else if (y <= 2.45e-29) {
		tmp = y * -0.5;
	} else if (y <= 1.34e+39) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    if (y <= (-2.6d+72)) then
        tmp = t_0
    else if (y <= (-1.3d+55)) then
        tmp = -1.0d0
    else if (y <= (-22000000000.0d0)) then
        tmp = 1.0d0 + (2.0d0 / y)
    else if (y <= 8.5d-93) then
        tmp = (y / x) + (-1.0d0)
    else if (y <= 2.45d-29) then
        tmp = y * (-0.5d0)
    else if (y <= 1.34d+39) then
        tmp = -1.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -2.6e+72) {
		tmp = t_0;
	} else if (y <= -1.3e+55) {
		tmp = -1.0;
	} else if (y <= -22000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 8.5e-93) {
		tmp = (y / x) + -1.0;
	} else if (y <= 2.45e-29) {
		tmp = y * -0.5;
	} else if (y <= 1.34e+39) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -2.6e+72:
		tmp = t_0
	elif y <= -1.3e+55:
		tmp = -1.0
	elif y <= -22000000000.0:
		tmp = 1.0 + (2.0 / y)
	elif y <= 8.5e-93:
		tmp = (y / x) + -1.0
	elif y <= 2.45e-29:
		tmp = y * -0.5
	elif y <= 1.34e+39:
		tmp = -1.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -2.6e+72)
		tmp = t_0;
	elseif (y <= -1.3e+55)
		tmp = -1.0;
	elseif (y <= -22000000000.0)
		tmp = Float64(1.0 + Float64(2.0 / y));
	elseif (y <= 8.5e-93)
		tmp = Float64(Float64(y / x) + -1.0);
	elseif (y <= 2.45e-29)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.34e+39)
		tmp = -1.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -2.6e+72)
		tmp = t_0;
	elseif (y <= -1.3e+55)
		tmp = -1.0;
	elseif (y <= -22000000000.0)
		tmp = 1.0 + (2.0 / y);
	elseif (y <= 8.5e-93)
		tmp = (y / x) + -1.0;
	elseif (y <= 2.45e-29)
		tmp = y * -0.5;
	elseif (y <= 1.34e+39)
		tmp = -1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.6e+72], t$95$0, If[LessEqual[y, -1.3e+55], -1.0, If[LessEqual[y, -22000000000.0], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.5e-93], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, 2.45e-29], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.34e+39], -1.0, t$95$0]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -22000000000:\\
\;\;\;\;1 + \frac{2}{y}\\

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

\mathbf{elif}\;y \leq 2.45 \cdot 10^{-29}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.34 \cdot 10^{+39}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -2.59999999999999981e72 or 1.34000000000000005e39 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if -2.59999999999999981e72 < y < -1.3e55 or 2.4499999999999999e-29 < y < 1.34000000000000005e39

    1. Initial program 100.0%

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

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

    if -1.3e55 < y < -2.2e10

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \left(2 + \left(x + -1 \cdot x\right)\right) - -2 \cdot x}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{2 + x \cdot -2}{y}} \]
    8. Taylor expanded in x around 0 78.1%

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

        \[\leadsto 1 + \color{blue}{\frac{2 \cdot 1}{y}} \]
      2. metadata-eval78.1%

        \[\leadsto 1 + \frac{\color{blue}{2}}{y} \]
    10. Simplified78.1%

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

    if -2.2e10 < y < 8.5000000000000007e-93

    1. Initial program 100.0%

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

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

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

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

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

    if 8.5000000000000007e-93 < y < 2.4499999999999999e-29

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    8. Simplified63.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{+72}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+55}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -22000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-93}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-29}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.34 \cdot 10^{+39}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 62.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ t_1 := \frac{x}{-2 - x}\\ \mathbf{if}\;y \leq -3.15 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4 \cdot 10^{+55}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -40000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-28}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.36 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- -2.0 x))))
   (if (<= y -3.15e+72)
     t_0
     (if (<= y -4e+55)
       -1.0
       (if (<= y -40000000000.0)
         (+ 1.0 (/ 2.0 y))
         (if (<= y 1.1e-79)
           t_1
           (if (<= y 4.2e-28) (* y -0.5) (if (<= y 1.36e+42) t_1 t_0))))))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double t_1 = x / (-2.0 - x);
	double tmp;
	if (y <= -3.15e+72) {
		tmp = t_0;
	} else if (y <= -4e+55) {
		tmp = -1.0;
	} else if (y <= -40000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 1.1e-79) {
		tmp = t_1;
	} else if (y <= 4.2e-28) {
		tmp = y * -0.5;
	} else if (y <= 1.36e+42) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    t_1 = x / ((-2.0d0) - x)
    if (y <= (-3.15d+72)) then
        tmp = t_0
    else if (y <= (-4d+55)) then
        tmp = -1.0d0
    else if (y <= (-40000000000.0d0)) then
        tmp = 1.0d0 + (2.0d0 / y)
    else if (y <= 1.1d-79) then
        tmp = t_1
    else if (y <= 4.2d-28) then
        tmp = y * (-0.5d0)
    else if (y <= 1.36d+42) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double t_1 = x / (-2.0 - x);
	double tmp;
	if (y <= -3.15e+72) {
		tmp = t_0;
	} else if (y <= -4e+55) {
		tmp = -1.0;
	} else if (y <= -40000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 1.1e-79) {
		tmp = t_1;
	} else if (y <= 4.2e-28) {
		tmp = y * -0.5;
	} else if (y <= 1.36e+42) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	t_1 = x / (-2.0 - x)
	tmp = 0
	if y <= -3.15e+72:
		tmp = t_0
	elif y <= -4e+55:
		tmp = -1.0
	elif y <= -40000000000.0:
		tmp = 1.0 + (2.0 / y)
	elif y <= 1.1e-79:
		tmp = t_1
	elif y <= 4.2e-28:
		tmp = y * -0.5
	elif y <= 1.36e+42:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 - Float64(x / y))
	t_1 = Float64(x / Float64(-2.0 - x))
	tmp = 0.0
	if (y <= -3.15e+72)
		tmp = t_0;
	elseif (y <= -4e+55)
		tmp = -1.0;
	elseif (y <= -40000000000.0)
		tmp = Float64(1.0 + Float64(2.0 / y));
	elseif (y <= 1.1e-79)
		tmp = t_1;
	elseif (y <= 4.2e-28)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.36e+42)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 - (x / y);
	t_1 = x / (-2.0 - x);
	tmp = 0.0;
	if (y <= -3.15e+72)
		tmp = t_0;
	elseif (y <= -4e+55)
		tmp = -1.0;
	elseif (y <= -40000000000.0)
		tmp = 1.0 + (2.0 / y);
	elseif (y <= 1.1e-79)
		tmp = t_1;
	elseif (y <= 4.2e-28)
		tmp = y * -0.5;
	elseif (y <= 1.36e+42)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(-2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.15e+72], t$95$0, If[LessEqual[y, -4e+55], -1.0, If[LessEqual[y, -40000000000.0], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e-79], t$95$1, If[LessEqual[y, 4.2e-28], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.36e+42], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -40000000000:\\
\;\;\;\;1 + \frac{2}{y}\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-79}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 4.2 \cdot 10^{-28}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.36 \cdot 10^{+42}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -3.14999999999999981e72 or 1.35999999999999999e42 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if -3.14999999999999981e72 < y < -4.00000000000000004e55

    1. Initial program 100.0%

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

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

    if -4.00000000000000004e55 < y < -4e10

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \left(2 + \left(x + -1 \cdot x\right)\right) - -2 \cdot x}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{2 + x \cdot -2}{y}} \]
    8. Taylor expanded in x around 0 78.1%

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

        \[\leadsto 1 + \color{blue}{\frac{2 \cdot 1}{y}} \]
      2. metadata-eval78.1%

        \[\leadsto 1 + \frac{\color{blue}{2}}{y} \]
    10. Simplified78.1%

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

    if -4e10 < y < 1.0999999999999999e-79 or 4.20000000000000013e-28 < y < 1.35999999999999999e42

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{x}{2 - x}} \]
    4. Step-by-step derivation
      1. frac-2neg76.3%

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

        \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{1}{-\left(2 - x\right)}} \]
      3. add-sqr-sqrt39.6%

        \[\leadsto \color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot \frac{1}{-\left(2 - x\right)} \]
      4. sqrt-unprod23.0%

        \[\leadsto \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \cdot \frac{1}{-\left(2 - x\right)} \]
      5. sqr-neg23.0%

        \[\leadsto \sqrt{\color{blue}{x \cdot x}} \cdot \frac{1}{-\left(2 - x\right)} \]
      6. sqrt-unprod1.5%

        \[\leadsto \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot \frac{1}{-\left(2 - x\right)} \]
      7. add-sqr-sqrt3.0%

        \[\leadsto \color{blue}{x} \cdot \frac{1}{-\left(2 - x\right)} \]
      8. sub-neg3.0%

        \[\leadsto x \cdot \frac{1}{-\color{blue}{\left(2 + \left(-x\right)\right)}} \]
      9. add-sqr-sqrt1.5%

        \[\leadsto x \cdot \frac{1}{-\left(2 + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}\right)} \]
      10. sqrt-unprod15.1%

        \[\leadsto x \cdot \frac{1}{-\left(2 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}\right)} \]
      11. sqr-neg15.1%

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

        \[\leadsto x \cdot \frac{1}{-\left(2 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)} \]
      13. add-sqr-sqrt54.8%

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{-\left(2 + x\right)}} \]
    6. Step-by-step derivation
      1. neg-mul-154.8%

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

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

        \[\leadsto \frac{\color{blue}{x}}{-1 \cdot \left(2 + x\right)} \]
      4. neg-mul-155.0%

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

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

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

        \[\leadsto \frac{x}{\color{blue}{-2 - x}} \]
    7. Simplified55.0%

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

    if 1.0999999999999999e-79 < y < 4.20000000000000013e-28

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-y}}{2 - y} \]
    5. Simplified68.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.15 \cdot 10^{+72}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -4 \cdot 10^{+55}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -40000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-79}:\\ \;\;\;\;\frac{x}{-2 - x}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-28}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.36 \cdot 10^{+42}:\\ \;\;\;\;\frac{x}{-2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 73.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -2.6 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{+55}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -85000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-80}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-29}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+42}:\\ \;\;\;\;\frac{x}{-2 - x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -2.6e+72)
     t_0
     (if (<= y -1.2e+55)
       -1.0
       (if (<= y -85000000000.0)
         (+ 1.0 (/ 2.0 y))
         (if (<= y 6e-80)
           (/ x (- 2.0 x))
           (if (<= y 2.4e-29)
             (* y -0.5)
             (if (<= y 1.25e+42) (/ x (- -2.0 x)) t_0))))))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -2.6e+72) {
		tmp = t_0;
	} else if (y <= -1.2e+55) {
		tmp = -1.0;
	} else if (y <= -85000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 6e-80) {
		tmp = x / (2.0 - x);
	} else if (y <= 2.4e-29) {
		tmp = y * -0.5;
	} else if (y <= 1.25e+42) {
		tmp = x / (-2.0 - x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    if (y <= (-2.6d+72)) then
        tmp = t_0
    else if (y <= (-1.2d+55)) then
        tmp = -1.0d0
    else if (y <= (-85000000000.0d0)) then
        tmp = 1.0d0 + (2.0d0 / y)
    else if (y <= 6d-80) then
        tmp = x / (2.0d0 - x)
    else if (y <= 2.4d-29) then
        tmp = y * (-0.5d0)
    else if (y <= 1.25d+42) then
        tmp = x / ((-2.0d0) - x)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -2.6e+72) {
		tmp = t_0;
	} else if (y <= -1.2e+55) {
		tmp = -1.0;
	} else if (y <= -85000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 6e-80) {
		tmp = x / (2.0 - x);
	} else if (y <= 2.4e-29) {
		tmp = y * -0.5;
	} else if (y <= 1.25e+42) {
		tmp = x / (-2.0 - x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -2.6e+72:
		tmp = t_0
	elif y <= -1.2e+55:
		tmp = -1.0
	elif y <= -85000000000.0:
		tmp = 1.0 + (2.0 / y)
	elif y <= 6e-80:
		tmp = x / (2.0 - x)
	elif y <= 2.4e-29:
		tmp = y * -0.5
	elif y <= 1.25e+42:
		tmp = x / (-2.0 - x)
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -2.6e+72)
		tmp = t_0;
	elseif (y <= -1.2e+55)
		tmp = -1.0;
	elseif (y <= -85000000000.0)
		tmp = Float64(1.0 + Float64(2.0 / y));
	elseif (y <= 6e-80)
		tmp = Float64(x / Float64(2.0 - x));
	elseif (y <= 2.4e-29)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.25e+42)
		tmp = Float64(x / Float64(-2.0 - x));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -2.6e+72)
		tmp = t_0;
	elseif (y <= -1.2e+55)
		tmp = -1.0;
	elseif (y <= -85000000000.0)
		tmp = 1.0 + (2.0 / y);
	elseif (y <= 6e-80)
		tmp = x / (2.0 - x);
	elseif (y <= 2.4e-29)
		tmp = y * -0.5;
	elseif (y <= 1.25e+42)
		tmp = x / (-2.0 - x);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.6e+72], t$95$0, If[LessEqual[y, -1.2e+55], -1.0, If[LessEqual[y, -85000000000.0], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e-80], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e-29], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.25e+42], N[(x / N[(-2.0 - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.2 \cdot 10^{+55}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq -85000000000:\\
\;\;\;\;1 + \frac{2}{y}\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if y < -2.59999999999999981e72 or 1.25000000000000002e42 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if -2.59999999999999981e72 < y < -1.2e55

    1. Initial program 100.0%

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

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

    if -1.2e55 < y < -8.5e10

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \left(2 + \left(x + -1 \cdot x\right)\right) - -2 \cdot x}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{2 + x \cdot -2}{y}} \]
    8. Taylor expanded in x around 0 78.1%

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

        \[\leadsto 1 + \color{blue}{\frac{2 \cdot 1}{y}} \]
      2. metadata-eval78.1%

        \[\leadsto 1 + \frac{\color{blue}{2}}{y} \]
    10. Simplified78.1%

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

    if -8.5e10 < y < 6.00000000000000014e-80

    1. Initial program 100.0%

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

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

    if 6.00000000000000014e-80 < y < 2.39999999999999992e-29

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-y}}{2 - y} \]
    5. Simplified68.7%

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

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

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

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

    if 2.39999999999999992e-29 < y < 1.25000000000000002e42

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{x}{2 - x}} \]
    4. Step-by-step derivation
      1. frac-2neg77.5%

        \[\leadsto \color{blue}{\frac{-x}{-\left(2 - x\right)}} \]
      2. div-inv77.4%

        \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{1}{-\left(2 - x\right)}} \]
      3. add-sqr-sqrt53.8%

        \[\leadsto \color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot \frac{1}{-\left(2 - x\right)} \]
      4. sqrt-unprod25.1%

        \[\leadsto \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \cdot \frac{1}{-\left(2 - x\right)} \]
      5. sqr-neg25.1%

        \[\leadsto \sqrt{\color{blue}{x \cdot x}} \cdot \frac{1}{-\left(2 - x\right)} \]
      6. sqrt-unprod1.1%

        \[\leadsto \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot \frac{1}{-\left(2 - x\right)} \]
      7. add-sqr-sqrt2.4%

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

        \[\leadsto x \cdot \frac{1}{-\color{blue}{\left(2 + \left(-x\right)\right)}} \]
      9. add-sqr-sqrt1.3%

        \[\leadsto x \cdot \frac{1}{-\left(2 + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}\right)} \]
      10. sqrt-unprod3.2%

        \[\leadsto x \cdot \frac{1}{-\left(2 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}\right)} \]
      11. sqr-neg3.2%

        \[\leadsto x \cdot \frac{1}{-\left(2 + \sqrt{\color{blue}{x \cdot x}}\right)} \]
      12. sqrt-unprod23.7%

        \[\leadsto x \cdot \frac{1}{-\left(2 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)} \]
      13. add-sqr-sqrt78.0%

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{-\left(2 + x\right)}} \]
    6. Step-by-step derivation
      1. neg-mul-178.0%

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

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

        \[\leadsto \frac{\color{blue}{x}}{-1 \cdot \left(2 + x\right)} \]
      4. neg-mul-178.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{+72}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{+55}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -85000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-80}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-29}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+42}:\\ \;\;\;\;\frac{x}{-2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+72}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -8 \cdot 10^{+55}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -85000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{-82}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-29}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+43}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -7e+72)
   1.0
   (if (<= y -8e+55)
     -1.0
     (if (<= y -85000000000.0)
       1.0
       (if (<= y 2.05e-82)
         -1.0
         (if (<= y 1.8e-29) (* y -0.5) (if (<= y 3.1e+43) -1.0 1.0)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -7e+72) {
		tmp = 1.0;
	} else if (y <= -8e+55) {
		tmp = -1.0;
	} else if (y <= -85000000000.0) {
		tmp = 1.0;
	} else if (y <= 2.05e-82) {
		tmp = -1.0;
	} else if (y <= 1.8e-29) {
		tmp = y * -0.5;
	} else if (y <= 3.1e+43) {
		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 <= (-7d+72)) then
        tmp = 1.0d0
    else if (y <= (-8d+55)) then
        tmp = -1.0d0
    else if (y <= (-85000000000.0d0)) then
        tmp = 1.0d0
    else if (y <= 2.05d-82) then
        tmp = -1.0d0
    else if (y <= 1.8d-29) then
        tmp = y * (-0.5d0)
    else if (y <= 3.1d+43) 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 <= -7e+72) {
		tmp = 1.0;
	} else if (y <= -8e+55) {
		tmp = -1.0;
	} else if (y <= -85000000000.0) {
		tmp = 1.0;
	} else if (y <= 2.05e-82) {
		tmp = -1.0;
	} else if (y <= 1.8e-29) {
		tmp = y * -0.5;
	} else if (y <= 3.1e+43) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -7e+72:
		tmp = 1.0
	elif y <= -8e+55:
		tmp = -1.0
	elif y <= -85000000000.0:
		tmp = 1.0
	elif y <= 2.05e-82:
		tmp = -1.0
	elif y <= 1.8e-29:
		tmp = y * -0.5
	elif y <= 3.1e+43:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -7e+72)
		tmp = 1.0;
	elseif (y <= -8e+55)
		tmp = -1.0;
	elseif (y <= -85000000000.0)
		tmp = 1.0;
	elseif (y <= 2.05e-82)
		tmp = -1.0;
	elseif (y <= 1.8e-29)
		tmp = Float64(y * -0.5);
	elseif (y <= 3.1e+43)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -7e+72)
		tmp = 1.0;
	elseif (y <= -8e+55)
		tmp = -1.0;
	elseif (y <= -85000000000.0)
		tmp = 1.0;
	elseif (y <= 2.05e-82)
		tmp = -1.0;
	elseif (y <= 1.8e-29)
		tmp = y * -0.5;
	elseif (y <= 3.1e+43)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -7e+72], 1.0, If[LessEqual[y, -8e+55], -1.0, If[LessEqual[y, -85000000000.0], 1.0, If[LessEqual[y, 2.05e-82], -1.0, If[LessEqual[y, 1.8e-29], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.1e+43], -1.0, 1.0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -8 \cdot 10^{+55}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;y \leq 2.05 \cdot 10^{-82}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{-29}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 3.1 \cdot 10^{+43}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.0000000000000002e72 or -8.00000000000000008e55 < y < -8.5e10 or 3.1000000000000002e43 < y

    1. Initial program 99.9%

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

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

    if -7.0000000000000002e72 < y < -8.00000000000000008e55 or -8.5e10 < y < 2.04999999999999998e-82 or 1.79999999999999987e-29 < y < 3.1000000000000002e43

    1. Initial program 100.0%

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

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

    if 2.04999999999999998e-82 < y < 1.79999999999999987e-29

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-y}}{2 - y} \]
    5. Simplified68.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+72}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -8 \cdot 10^{+55}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -85000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{-82}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-29}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+43}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.4 \cdot 10^{+72}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{+56}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -22000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-86}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-31}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+42}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -4.4e+72)
   1.0
   (if (<= y -2.8e+56)
     -1.0
     (if (<= y -22000000000.0)
       (+ 1.0 (/ 2.0 y))
       (if (<= y 2.9e-86)
         -1.0
         (if (<= y 2.6e-31) (* y -0.5) (if (<= y 1.95e+42) -1.0 1.0)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -4.4e+72) {
		tmp = 1.0;
	} else if (y <= -2.8e+56) {
		tmp = -1.0;
	} else if (y <= -22000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 2.9e-86) {
		tmp = -1.0;
	} else if (y <= 2.6e-31) {
		tmp = y * -0.5;
	} else if (y <= 1.95e+42) {
		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 <= (-4.4d+72)) then
        tmp = 1.0d0
    else if (y <= (-2.8d+56)) then
        tmp = -1.0d0
    else if (y <= (-22000000000.0d0)) then
        tmp = 1.0d0 + (2.0d0 / y)
    else if (y <= 2.9d-86) then
        tmp = -1.0d0
    else if (y <= 2.6d-31) then
        tmp = y * (-0.5d0)
    else if (y <= 1.95d+42) 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 <= -4.4e+72) {
		tmp = 1.0;
	} else if (y <= -2.8e+56) {
		tmp = -1.0;
	} else if (y <= -22000000000.0) {
		tmp = 1.0 + (2.0 / y);
	} else if (y <= 2.9e-86) {
		tmp = -1.0;
	} else if (y <= 2.6e-31) {
		tmp = y * -0.5;
	} else if (y <= 1.95e+42) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -4.4e+72:
		tmp = 1.0
	elif y <= -2.8e+56:
		tmp = -1.0
	elif y <= -22000000000.0:
		tmp = 1.0 + (2.0 / y)
	elif y <= 2.9e-86:
		tmp = -1.0
	elif y <= 2.6e-31:
		tmp = y * -0.5
	elif y <= 1.95e+42:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -4.4e+72)
		tmp = 1.0;
	elseif (y <= -2.8e+56)
		tmp = -1.0;
	elseif (y <= -22000000000.0)
		tmp = Float64(1.0 + Float64(2.0 / y));
	elseif (y <= 2.9e-86)
		tmp = -1.0;
	elseif (y <= 2.6e-31)
		tmp = Float64(y * -0.5);
	elseif (y <= 1.95e+42)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -4.4e+72)
		tmp = 1.0;
	elseif (y <= -2.8e+56)
		tmp = -1.0;
	elseif (y <= -22000000000.0)
		tmp = 1.0 + (2.0 / y);
	elseif (y <= 2.9e-86)
		tmp = -1.0;
	elseif (y <= 2.6e-31)
		tmp = y * -0.5;
	elseif (y <= 1.95e+42)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -4.4e+72], 1.0, If[LessEqual[y, -2.8e+56], -1.0, If[LessEqual[y, -22000000000.0], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e-86], -1.0, If[LessEqual[y, 2.6e-31], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.95e+42], -1.0, 1.0]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -22000000000:\\
\;\;\;\;1 + \frac{2}{y}\\

\mathbf{elif}\;y \leq 2.9 \cdot 10^{-86}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{-31}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 1.95 \cdot 10^{+42}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.4e72 or 1.94999999999999985e42 < y

    1. Initial program 99.9%

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

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

    if -4.4e72 < y < -2.80000000000000008e56 or -2.2e10 < y < 2.8999999999999999e-86 or 2.59999999999999995e-31 < y < 1.94999999999999985e42

    1. Initial program 100.0%

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

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

    if -2.80000000000000008e56 < y < -2.2e10

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \left(2 + \left(x + -1 \cdot x\right)\right) - -2 \cdot x}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{2 + x \cdot -2}{y}} \]
    8. Taylor expanded in x around 0 78.1%

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

        \[\leadsto 1 + \color{blue}{\frac{2 \cdot 1}{y}} \]
      2. metadata-eval78.1%

        \[\leadsto 1 + \frac{\color{blue}{2}}{y} \]
    10. Simplified78.1%

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

    if 2.8999999999999999e-86 < y < 2.59999999999999995e-31

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-y}}{2 - y} \]
    5. Simplified68.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.4 \cdot 10^{+72}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{+56}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -22000000000:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-86}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-31}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+42}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 74.5% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;x \leq -5.1 \cdot 10^{-42}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 8.5 \cdot 10^{+48}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 8.2 \cdot 10^{+80}:\\
\;\;\;\;1 + \frac{2}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -5.1e-42 or 1.4500000000000001e-34 < x < 8.5000000000000001e48

    1. Initial program 99.9%

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

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

    if -5.1e-42 < x < 1.4500000000000001e-34

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.5000000000000001e48 < x < 8.20000000000000003e80

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \left(2 + \left(x + -1 \cdot x\right)\right) - -2 \cdot x}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{2 + x \cdot -2}{y}} \]
    8. Taylor expanded in x around 0 68.1%

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

        \[\leadsto 1 + \color{blue}{\frac{2 \cdot 1}{y}} \]
      2. metadata-eval68.1%

        \[\leadsto 1 + \frac{\color{blue}{2}}{y} \]
    10. Simplified68.1%

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

    if 8.20000000000000003e80 < x

    1. Initial program 99.9%

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

      \[\leadsto \frac{x - y}{\color{blue}{-1 \cdot x}} \]
    4. Step-by-step derivation
      1. mul-1-neg87.0%

        \[\leadsto \frac{x - y}{\color{blue}{-x}} \]
    5. Simplified87.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.1 \cdot 10^{-42}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-34}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+48}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{+80}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 85.5% accurate, 0.4× speedup?

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

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

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

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

\mathbf{elif}\;x \leq 8 \cdot 10^{+80}:\\
\;\;\;\;1 + \frac{2}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -6.20000000000000023e76 or 8e80 < x

    1. Initial program 99.9%

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

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

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

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

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

    if -6.20000000000000023e76 < x < 0.320000000000000007

    1. Initial program 100.0%

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

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

    if 0.320000000000000007 < x < 2.9999999999999998e50

    1. Initial program 100.0%

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

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

    if 2.9999999999999998e50 < x < 8e80

    1. Initial program 100.0%

      \[\frac{x - y}{2 - \left(x + y\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \left(2 + \left(x + -1 \cdot x\right)\right) - -2 \cdot x}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{2 + x \cdot -2}{y}} \]
    8. Taylor expanded in x around 0 68.1%

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

        \[\leadsto 1 + \color{blue}{\frac{2 \cdot 1}{y}} \]
      2. metadata-eval68.1%

        \[\leadsto 1 + \frac{\color{blue}{2}}{y} \]
    10. Simplified68.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{+76}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq 0.32:\\ \;\;\;\;\frac{x - y}{2 - y}\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+50}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+80}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 62.1% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq -2 \cdot 10^{+56}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;y \leq 5 \cdot 10^{+42}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.99999999999999992e72 or -2.00000000000000018e56 < y < -8e10 or 5.00000000000000007e42 < y

    1. Initial program 99.9%

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

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

    if -4.99999999999999992e72 < y < -2.00000000000000018e56 or -8e10 < y < 5.00000000000000007e42

    1. Initial program 100.0%

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

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

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

Alternative 11: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 12: 38.6% 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. Add Preprocessing
  3. Taylor expanded in x around inf 38.3%

    \[\leadsto \color{blue}{-1} \]
  4. Final simplification38.3%

    \[\leadsto -1 \]
  5. Add Preprocessing

Developer target: 100.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024019 
(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))))