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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 62.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x} + -1\\ \mathbf{if}\;x \leq -1 \cdot 10^{+14}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-54}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -5.7 \cdot 10^{-92}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+54}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (/ y x) -1.0)))
   (if (<= x -1e+14)
     t_0
     (if (<= x -4e-54)
       (- 1.0 (/ x y))
       (if (<= x -5.7e-92) (* x 0.5) (if (<= x 1.7e+54) 1.0 t_0))))))
double code(double x, double y) {
	double t_0 = (y / x) + -1.0;
	double tmp;
	if (x <= -1e+14) {
		tmp = t_0;
	} else if (x <= -4e-54) {
		tmp = 1.0 - (x / y);
	} else if (x <= -5.7e-92) {
		tmp = x * 0.5;
	} else if (x <= 1.7e+54) {
		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 = (y / x) + (-1.0d0)
    if (x <= (-1d+14)) then
        tmp = t_0
    else if (x <= (-4d-54)) then
        tmp = 1.0d0 - (x / y)
    else if (x <= (-5.7d-92)) then
        tmp = x * 0.5d0
    else if (x <= 1.7d+54) then
        tmp = 1.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (y / x) + -1.0;
	double tmp;
	if (x <= -1e+14) {
		tmp = t_0;
	} else if (x <= -4e-54) {
		tmp = 1.0 - (x / y);
	} else if (x <= -5.7e-92) {
		tmp = x * 0.5;
	} else if (x <= 1.7e+54) {
		tmp = 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y / x) + -1.0
	tmp = 0
	if x <= -1e+14:
		tmp = t_0
	elif x <= -4e-54:
		tmp = 1.0 - (x / y)
	elif x <= -5.7e-92:
		tmp = x * 0.5
	elif x <= 1.7e+54:
		tmp = 1.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y / x) + -1.0)
	tmp = 0.0
	if (x <= -1e+14)
		tmp = t_0;
	elseif (x <= -4e-54)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (x <= -5.7e-92)
		tmp = Float64(x * 0.5);
	elseif (x <= 1.7e+54)
		tmp = 1.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y / x) + -1.0;
	tmp = 0.0;
	if (x <= -1e+14)
		tmp = t_0;
	elseif (x <= -4e-54)
		tmp = 1.0 - (x / y);
	elseif (x <= -5.7e-92)
		tmp = x * 0.5;
	elseif (x <= 1.7e+54)
		tmp = 1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -1e+14], t$95$0, If[LessEqual[x, -4e-54], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.7e-92], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.7e+54], 1.0, t$95$0]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq -5.7 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 1.7 \cdot 10^{+54}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1e14 or 1.7e54 < x

    1. Initial program 99.9%

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

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

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

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

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

    if -1e14 < x < -4.0000000000000001e-54

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -4.0000000000000001e-54 < x < -5.70000000000000009e-92

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    6. Simplified61.4%

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

    if -5.70000000000000009e-92 < x < 1.7e54

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+14}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-54}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -5.7 \cdot 10^{-92}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+54}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 62.0% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq -3.8 \cdot 10^{-54}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -2.5 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 2.7 \cdot 10^{+44}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.5e13 or 2.7e44 < x

    1. Initial program 99.9%

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

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

    if -7.5e13 < x < -3.8000000000000002e-54 or -2.50000000000000006e-92 < x < 2.7e44

    1. Initial program 100.0%

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

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

    if -3.8000000000000002e-54 < x < -2.50000000000000006e-92

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    6. Simplified61.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -75000000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-54}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-92}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{+44}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 62.0% accurate, 0.4× speedup?

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

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

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

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

\mathbf{elif}\;x \leq 6 \cdot 10^{+45}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.72e13 or 6.00000000000000021e45 < x

    1. Initial program 99.9%

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

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

    if -1.72e13 < x < -1.7e-53

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto 1 + \frac{\color{blue}{2}}{y} \]
    6. Simplified61.8%

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

    if -1.7e-53 < x < -5.6e-92

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    6. Simplified61.4%

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

    if -5.6e-92 < x < 6.00000000000000021e45

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -17200000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-53}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-92}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+45}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 62.1% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;x \leq -3 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 2 \cdot 10^{+40}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -3.2e13 or 2.00000000000000006e40 < x

    1. Initial program 99.9%

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

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

    if -3.2e13 < x < -6.20000000000000031e-53

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -6.20000000000000031e-53 < x < -3.00000000000000013e-92

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    6. Simplified61.4%

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

    if -3.00000000000000013e-92 < x < 2.00000000000000006e40

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -32000000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-53}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-92}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+40}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 86.5% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.70000000000000007e-10 < y < 5.1e16

    1. Initial program 100.0%

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

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

    if 5.1e16 < y

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x - y}{4 - {\left(x + y\right)}^{2}} \cdot \left(2 + \left(x + y\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative39.7%

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

        \[\leadsto \color{blue}{\frac{\left(2 + \left(x + y\right)\right) \cdot \left(x - y\right)}{4 - {\left(x + y\right)}^{2}}} \]
      3. associate-+r+37.8%

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

        \[\leadsto \frac{\color{blue}{\left(y + \left(2 + x\right)\right)} \cdot \left(x - y\right)}{4 - {\left(x + y\right)}^{2}} \]
      5. +-commutative37.8%

        \[\leadsto \frac{\left(y + \left(2 + x\right)\right) \cdot \left(x - y\right)}{4 - {\color{blue}{\left(y + x\right)}}^{2}} \]
    6. Simplified37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{-10}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{+16}:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{2 + x \cdot -2}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 86.4% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.70000000000000007e-10 < y < 2.4e17

    1. Initial program 100.0%

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

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

    if 2.4e17 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{-10}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+17}:\\ \;\;\;\;\frac{x - y}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 74.1% accurate, 0.6× speedup?

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -1.49999999999999992e69 < y < 3.5e14

    1. Initial program 100.0%

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

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

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

Alternative 9: 74.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-12} \lor \neg \left(y \leq 8 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{y}{y + -2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.0000000000000003e-12 or 7.9999999999999998e-19 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.0000000000000003e-12 < y < 7.9999999999999998e-19

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{-12} \lor \neg \left(y \leq 8 \cdot 10^{-19}\right):\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 62.4% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 7 \cdot 10^{+40}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.35e14 or 6.9999999999999998e40 < x

    1. Initial program 99.9%

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

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

    if -2.35e14 < x < 6.9999999999999998e40

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.35 \cdot 10^{+14}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+40}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 38.2% accurate, 9.0× speedup?

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

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

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

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

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

Developer target: 100.0% accurate, 0.6× speedup?

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

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

Reproduce

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

  :herbie-target
  (- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))

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