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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
    10. neg-sub0100.0%

      \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
    11. associate--r-100.0%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. expm1-log1p-u22.6%

      \[\leadsto \frac{y - x}{x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y + -2\right)\right)}} \]
    2. expm1-undefine22.6%

      \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
  6. Applied egg-rr22.6%

    \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
  7. Step-by-step derivation
    1. sub-neg22.6%

      \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} + \left(-1\right)\right)}} \]
    2. metadata-eval22.6%

      \[\leadsto \frac{y - x}{x + \left(e^{\mathsf{log1p}\left(y + -2\right)} + \color{blue}{-1}\right)} \]
    3. +-commutative22.6%

      \[\leadsto \frac{y - x}{x + \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(y + -2\right)}\right)}} \]
    4. log1p-undefine22.6%

      \[\leadsto \frac{y - x}{x + \left(-1 + e^{\color{blue}{\log \left(1 + \left(y + -2\right)\right)}}\right)} \]
    5. rem-exp-log100.0%

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

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

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

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

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

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

Alternative 2: 62.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -0.0096:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -7.8 \cdot 10^{-67}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 7.4 \cdot 10^{+64}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -0.0096)
     t_0
     (if (<= y -7.8e-67) (* y -0.5) (if (<= y 7.4e+64) -1.0 t_0)))))
double code(double x, double y) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -0.0096) {
		tmp = t_0;
	} else if (y <= -7.8e-67) {
		tmp = y * -0.5;
	} else if (y <= 7.4e+64) {
		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 <= (-0.0096d0)) then
        tmp = t_0
    else if (y <= (-7.8d-67)) then
        tmp = y * (-0.5d0)
    else if (y <= 7.4d+64) 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 <= -0.0096) {
		tmp = t_0;
	} else if (y <= -7.8e-67) {
		tmp = y * -0.5;
	} else if (y <= 7.4e+64) {
		tmp = -1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -0.0096:
		tmp = t_0
	elif y <= -7.8e-67:
		tmp = y * -0.5
	elif y <= 7.4e+64:
		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 <= -0.0096)
		tmp = t_0;
	elseif (y <= -7.8e-67)
		tmp = Float64(y * -0.5);
	elseif (y <= 7.4e+64)
		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 <= -0.0096)
		tmp = t_0;
	elseif (y <= -7.8e-67)
		tmp = y * -0.5;
	elseif (y <= 7.4e+64)
		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, -0.0096], t$95$0, If[LessEqual[y, -7.8e-67], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 7.4e+64], -1.0, t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -0.0096:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -7.8 \cdot 10^{-67}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 7.4 \cdot 10^{+64}:\\
\;\;\;\;-1\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -0.00959999999999999916 or 7.39999999999999966e64 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. expm1-log1p-u42.5%

        \[\leadsto \frac{y - x}{x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y + -2\right)\right)}} \]
      2. expm1-undefine42.5%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    6. Applied egg-rr42.5%

      \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    7. Step-by-step derivation
      1. sub-neg42.5%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} + \left(-1\right)\right)}} \]
      2. metadata-eval42.5%

        \[\leadsto \frac{y - x}{x + \left(e^{\mathsf{log1p}\left(y + -2\right)} + \color{blue}{-1}\right)} \]
      3. +-commutative42.5%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(y + -2\right)}\right)}} \]
      4. log1p-undefine42.5%

        \[\leadsto \frac{y - x}{x + \left(-1 + e^{\color{blue}{\log \left(1 + \left(y + -2\right)\right)}}\right)} \]
      5. rem-exp-log99.9%

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

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

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

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

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

      \[\leadsto \frac{y - x}{\color{blue}{y}} \]
    10. Taylor expanded in y around inf 79.2%

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

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

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

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

    if -0.00959999999999999916 < y < -7.7999999999999997e-67

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.7999999999999997e-67 < y < 7.39999999999999966e64

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 86.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+41}:\\
\;\;\;\;\frac{y}{x + \left(y + -2\right)}\\

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.79999999999999977e41 < y < 6.50000000000000007e64

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

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

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

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

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

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

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

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

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

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

    if 6.50000000000000007e64 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y - x}{\color{blue}{y - 2}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 86.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+41}:\\
\;\;\;\;\frac{y}{x + \left(y + -2\right)}\\

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1e41 < y < 7.5000000000000005e64

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

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

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

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

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

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

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

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

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

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

    if 7.5000000000000005e64 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. expm1-log1p-u91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y + -2\right)\right)}} \]
      2. expm1-undefine91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    6. Applied egg-rr91.1%

      \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    7. Step-by-step derivation
      1. sub-neg91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} + \left(-1\right)\right)}} \]
      2. metadata-eval91.1%

        \[\leadsto \frac{y - x}{x + \left(e^{\mathsf{log1p}\left(y + -2\right)} + \color{blue}{-1}\right)} \]
      3. +-commutative91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(y + -2\right)}\right)}} \]
      4. log1p-undefine91.1%

        \[\leadsto \frac{y - x}{x + \left(-1 + e^{\color{blue}{\log \left(1 + \left(y + -2\right)\right)}}\right)} \]
      5. rem-exp-log99.9%

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

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

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

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

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

      \[\leadsto \frac{y - x}{\color{blue}{y}} \]
    10. Taylor expanded in y around inf 83.9%

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

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

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

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

Alternative 5: 62.0% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2 or 9.9999999999999999e64 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2 < y < -7.5000000000000005e-67

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.5000000000000005e-67 < y < 9.9999999999999999e64

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 74.7% accurate, 0.6× speedup?

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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. expm1-log1p-u45.6%

        \[\leadsto \frac{y - x}{x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y + -2\right)\right)}} \]
      2. expm1-undefine45.6%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    6. Applied egg-rr45.6%

      \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    7. Step-by-step derivation
      1. sub-neg45.6%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} + \left(-1\right)\right)}} \]
      2. metadata-eval45.6%

        \[\leadsto \frac{y - x}{x + \left(e^{\mathsf{log1p}\left(y + -2\right)} + \color{blue}{-1}\right)} \]
      3. +-commutative45.6%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(y + -2\right)}\right)}} \]
      4. log1p-undefine45.6%

        \[\leadsto \frac{y - x}{x + \left(-1 + e^{\color{blue}{\log \left(1 + \left(y + -2\right)\right)}}\right)} \]
      5. rem-exp-log99.9%

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

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

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

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

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

      \[\leadsto \frac{y - x}{\color{blue}{y}} \]
    10. Taylor expanded in y around inf 82.0%

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

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

        \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    12. Simplified82.0%

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

    if -4.5999999999999997e41 < y < 3.25000000000000015e65

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{x}{x - 2}} \]
      2. distribute-neg-frac271.8%

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

        \[\leadsto \frac{x}{\color{blue}{0 - \left(x - 2\right)}} \]
      4. associate-+l-71.8%

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

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

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

        \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
    7. Simplified71.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+41} \lor \neg \left(y \leq 3.25 \cdot 10^{+65}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 74.2% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.4999999999999997e-67 < y < 6.0000000000000004e64

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{x}{x - 2}} \]
      2. distribute-neg-frac279.8%

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

        \[\leadsto \frac{x}{\color{blue}{0 - \left(x - 2\right)}} \]
      4. associate-+l-79.8%

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

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

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

        \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
    7. Simplified79.8%

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

    if 6.0000000000000004e64 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. expm1-log1p-u91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y + -2\right)\right)}} \]
      2. expm1-undefine91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    6. Applied egg-rr91.1%

      \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    7. Step-by-step derivation
      1. sub-neg91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} + \left(-1\right)\right)}} \]
      2. metadata-eval91.1%

        \[\leadsto \frac{y - x}{x + \left(e^{\mathsf{log1p}\left(y + -2\right)} + \color{blue}{-1}\right)} \]
      3. +-commutative91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(y + -2\right)}\right)}} \]
      4. log1p-undefine91.1%

        \[\leadsto \frac{y - x}{x + \left(-1 + e^{\color{blue}{\log \left(1 + \left(y + -2\right)\right)}}\right)} \]
      5. rem-exp-log99.9%

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

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

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

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

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

      \[\leadsto \frac{y - x}{\color{blue}{y}} \]
    10. Taylor expanded in y around inf 83.9%

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

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

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

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

Alternative 8: 74.0% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.7999999999999997e-67 < y < 1.2000000000000001e65

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{x}{x - 2}} \]
      2. distribute-neg-frac279.8%

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

        \[\leadsto \frac{x}{\color{blue}{0 - \left(x - 2\right)}} \]
      4. associate-+l-79.8%

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

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

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

        \[\leadsto \frac{x}{\color{blue}{2 - x}} \]
    7. Simplified79.8%

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

    if 1.2000000000000001e65 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{x + \left(y + -2\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. expm1-log1p-u91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y + -2\right)\right)}} \]
      2. expm1-undefine91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    6. Applied egg-rr91.1%

      \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} - 1\right)}} \]
    7. Step-by-step derivation
      1. sub-neg91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(e^{\mathsf{log1p}\left(y + -2\right)} + \left(-1\right)\right)}} \]
      2. metadata-eval91.1%

        \[\leadsto \frac{y - x}{x + \left(e^{\mathsf{log1p}\left(y + -2\right)} + \color{blue}{-1}\right)} \]
      3. +-commutative91.1%

        \[\leadsto \frac{y - x}{x + \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(y + -2\right)}\right)}} \]
      4. log1p-undefine91.1%

        \[\leadsto \frac{y - x}{x + \left(-1 + e^{\color{blue}{\log \left(1 + \left(y + -2\right)\right)}}\right)} \]
      5. rem-exp-log99.9%

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

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

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

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

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

      \[\leadsto \frac{y - x}{\color{blue}{y}} \]
    10. Taylor expanded in y around inf 83.9%

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

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

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

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

Alternative 9: 62.7% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;y \leq 6.5 \cdot 10^{+64}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.2999999999999997e41 or 6.50000000000000007e64 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2999999999999997e41 < y < 6.50000000000000007e64

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
      10. neg-sub0100.0%

        \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
      11. associate--r-100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 100.0% accurate, 1.0× speedup?

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

\\
\frac{x - y}{2 - \left(y + x\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(y + x\right)} \]
  4. Add Preprocessing

Alternative 11: 38.1% accurate, 9.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{y - x}}{-\left(2 - \left(y + x\right)\right)} \]
    10. neg-sub0100.0%

      \[\leadsto \frac{y - x}{\color{blue}{0 - \left(2 - \left(y + x\right)\right)}} \]
    11. associate--r-100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  6. Add Preprocessing

Developer Target 1: 100.0% accurate, 0.6× speedup?

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

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

Reproduce

?
herbie shell --seed 2024191 
(FPCore (x y)
  :name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
  :precision binary64

  :alt
  (! :herbie-platform default (- (/ x (- 2 (+ x y))) (/ y (- 2 (+ x y)))))

  (/ (- x y) (- 2.0 (+ x y))))