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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 62.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
t_1 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -2:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -9.5 \cdot 10^{-82}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-99}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 4.8 \cdot 10^{-66}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{+42}:\\
\;\;\;\;1\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -2 < x < -9.4999999999999996e-82 or 1.6e-99 < x < 4.80000000000000052e-66

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -9.4999999999999996e-82 < x < 1.6e-99 or 4.80000000000000052e-66 < x < 7.50000000000000041e42

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-82}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-99}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-66}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]

Alternative 3: 62.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x - y\right) \cdot 0.5\\ \mathbf{if}\;x \leq -2.5:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-83}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-100}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 10^{+43}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (- x y) 0.5)))
   (if (<= x -2.5)
     -1.0
     (if (<= x -1.45e-83)
       t_0
       (if (<= x 7.2e-100)
         1.0
         (if (<= x 4.5e-66) t_0 (if (<= x 1e+43) 1.0 -1.0)))))))
double code(double x, double y) {
	double t_0 = (x - y) * 0.5;
	double tmp;
	if (x <= -2.5) {
		tmp = -1.0;
	} else if (x <= -1.45e-83) {
		tmp = t_0;
	} else if (x <= 7.2e-100) {
		tmp = 1.0;
	} else if (x <= 4.5e-66) {
		tmp = t_0;
	} else if (x <= 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) :: t_0
    real(8) :: tmp
    t_0 = (x - y) * 0.5d0
    if (x <= (-2.5d0)) then
        tmp = -1.0d0
    else if (x <= (-1.45d-83)) then
        tmp = t_0
    else if (x <= 7.2d-100) then
        tmp = 1.0d0
    else if (x <= 4.5d-66) then
        tmp = t_0
    else if (x <= 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 t_0 = (x - y) * 0.5;
	double tmp;
	if (x <= -2.5) {
		tmp = -1.0;
	} else if (x <= -1.45e-83) {
		tmp = t_0;
	} else if (x <= 7.2e-100) {
		tmp = 1.0;
	} else if (x <= 4.5e-66) {
		tmp = t_0;
	} else if (x <= 1e+43) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (x - y) * 0.5
	tmp = 0
	if x <= -2.5:
		tmp = -1.0
	elif x <= -1.45e-83:
		tmp = t_0
	elif x <= 7.2e-100:
		tmp = 1.0
	elif x <= 4.5e-66:
		tmp = t_0
	elif x <= 1e+43:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x - y) * 0.5)
	tmp = 0.0
	if (x <= -2.5)
		tmp = -1.0;
	elseif (x <= -1.45e-83)
		tmp = t_0;
	elseif (x <= 7.2e-100)
		tmp = 1.0;
	elseif (x <= 4.5e-66)
		tmp = t_0;
	elseif (x <= 1e+43)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x - y) * 0.5;
	tmp = 0.0;
	if (x <= -2.5)
		tmp = -1.0;
	elseif (x <= -1.45e-83)
		tmp = t_0;
	elseif (x <= 7.2e-100)
		tmp = 1.0;
	elseif (x <= 4.5e-66)
		tmp = t_0;
	elseif (x <= 1e+43)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -2.5], -1.0, If[LessEqual[x, -1.45e-83], t$95$0, If[LessEqual[x, 7.2e-100], 1.0, If[LessEqual[x, 4.5e-66], t$95$0, If[LessEqual[x, 1e+43], 1.0, -1.0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -2.5:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -1.45 \cdot 10^{-83}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7.2 \cdot 10^{-100}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 10^{+43}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.5 or 1.00000000000000001e43 < x

    1. Initial program 100.0%

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

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

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

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

    if -2.5 < x < -1.45e-83 or 7.1999999999999997e-100 < x < 4.4999999999999998e-66

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -1.45e-83 < x < 7.1999999999999997e-100 or 4.4999999999999998e-66 < x < 1.00000000000000001e43

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-83}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-100}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-66}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 10^{+43}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 4: 86.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - y}{2 - x}\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{+42}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.59999999999999993e-5

    1. Initial program 100.0%

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

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

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

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

    if -1.59999999999999993e-5 < x < 7.50000000000000041e42

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 7.50000000000000041e42 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+42}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]

Alternative 5: 87.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-7}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\

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

\mathbf{else}:\\
\;\;\;\;1 + \frac{\left(2 - x\right) - x}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.5000000000000001e-7

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if -9.5000000000000001e-7 < y < 4.2e9

    1. Initial program 100.0%

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

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

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

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

    if 4.2e9 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{\left(2 - x\right) - x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{-7}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\ \mathbf{elif}\;y \leq 4200000000:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\left(2 - x\right) - x}{y}\\ \end{array} \]

Alternative 6: 61.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq -5.6 \cdot 10^{-74}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 3.9 \cdot 10^{-100}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-62}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 10^{+43}:\\
\;\;\;\;1\\

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


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

    1. Initial program 100.0%

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

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

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

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

    if -2 < x < -5.59999999999999976e-74 or 3.89999999999999977e-100 < x < 3.0999999999999999e-62

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified72.4%

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

    if -5.59999999999999976e-74 < x < 3.89999999999999977e-100 or 3.0999999999999999e-62 < x < 1.00000000000000001e43

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-74}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-100}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-62}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 10^{+43}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 7: 87.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{y}{y + -2}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.5000000000000001e-7

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.5000000000000001e-7 < y < 5.99999999999999981e35

    1. Initial program 100.0%

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

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

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

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

    if 5.99999999999999981e35 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{-7}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+35}:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 8: 75.4% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.7e13 or 4.1999999999999998e35 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7e13 < y < 4.1999999999999998e35

    1. Initial program 100.0%

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

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

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

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

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

Alternative 9: 75.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{y}{y + -2}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -8.49999999999999935e-8

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.49999999999999935e-8 < y < 5.99999999999999981e35

    1. Initial program 100.0%

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

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

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

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

    if 5.99999999999999981e35 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+35}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 10: 62.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-5}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 10^{+43}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.59999999999999993e-5 or 1.00000000000000001e43 < x

    1. Initial program 100.0%

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

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

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

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

    if -1.59999999999999993e-5 < x < 1.00000000000000001e43

    1. Initial program 100.0%

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

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

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

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

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

Alternative 11: 38.2% accurate, 9.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification41.0%

    \[\leadsto -1 \]

Developer target: 100.0% accurate, 0.6× speedup?

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

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

Reproduce

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