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

Percentage Accurate: 100.0% → 100.0%
Time: 6.7s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 60.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+61}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-35}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -3.05 \cdot 10^{-145}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{-187}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-270}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-190}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-148}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3.3e+61)
   1.0
   (if (<= y -1.8e-35)
     -1.0
     (if (<= y -3.05e-145)
       (* y -0.5)
       (if (<= y -7.2e-187)
         -1.0
         (if (<= y -5.8e-270)
           (* x 0.5)
           (if (<= y 1.8e-190)
             -1.0
             (if (<= y 9.2e-148) (* x 0.5) (if (<= y 2.7e+34) -1.0 1.0)))))))))
double code(double x, double y) {
	double tmp;
	if (y <= -3.3e+61) {
		tmp = 1.0;
	} else if (y <= -1.8e-35) {
		tmp = -1.0;
	} else if (y <= -3.05e-145) {
		tmp = y * -0.5;
	} else if (y <= -7.2e-187) {
		tmp = -1.0;
	} else if (y <= -5.8e-270) {
		tmp = x * 0.5;
	} else if (y <= 1.8e-190) {
		tmp = -1.0;
	} else if (y <= 9.2e-148) {
		tmp = x * 0.5;
	} else if (y <= 2.7e+34) {
		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 <= (-3.3d+61)) then
        tmp = 1.0d0
    else if (y <= (-1.8d-35)) then
        tmp = -1.0d0
    else if (y <= (-3.05d-145)) then
        tmp = y * (-0.5d0)
    else if (y <= (-7.2d-187)) then
        tmp = -1.0d0
    else if (y <= (-5.8d-270)) then
        tmp = x * 0.5d0
    else if (y <= 1.8d-190) then
        tmp = -1.0d0
    else if (y <= 9.2d-148) then
        tmp = x * 0.5d0
    else if (y <= 2.7d+34) 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 <= -3.3e+61) {
		tmp = 1.0;
	} else if (y <= -1.8e-35) {
		tmp = -1.0;
	} else if (y <= -3.05e-145) {
		tmp = y * -0.5;
	} else if (y <= -7.2e-187) {
		tmp = -1.0;
	} else if (y <= -5.8e-270) {
		tmp = x * 0.5;
	} else if (y <= 1.8e-190) {
		tmp = -1.0;
	} else if (y <= 9.2e-148) {
		tmp = x * 0.5;
	} else if (y <= 2.7e+34) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3.3e+61:
		tmp = 1.0
	elif y <= -1.8e-35:
		tmp = -1.0
	elif y <= -3.05e-145:
		tmp = y * -0.5
	elif y <= -7.2e-187:
		tmp = -1.0
	elif y <= -5.8e-270:
		tmp = x * 0.5
	elif y <= 1.8e-190:
		tmp = -1.0
	elif y <= 9.2e-148:
		tmp = x * 0.5
	elif y <= 2.7e+34:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3.3e+61)
		tmp = 1.0;
	elseif (y <= -1.8e-35)
		tmp = -1.0;
	elseif (y <= -3.05e-145)
		tmp = Float64(y * -0.5);
	elseif (y <= -7.2e-187)
		tmp = -1.0;
	elseif (y <= -5.8e-270)
		tmp = Float64(x * 0.5);
	elseif (y <= 1.8e-190)
		tmp = -1.0;
	elseif (y <= 9.2e-148)
		tmp = Float64(x * 0.5);
	elseif (y <= 2.7e+34)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -3.3e+61)
		tmp = 1.0;
	elseif (y <= -1.8e-35)
		tmp = -1.0;
	elseif (y <= -3.05e-145)
		tmp = y * -0.5;
	elseif (y <= -7.2e-187)
		tmp = -1.0;
	elseif (y <= -5.8e-270)
		tmp = x * 0.5;
	elseif (y <= 1.8e-190)
		tmp = -1.0;
	elseif (y <= 9.2e-148)
		tmp = x * 0.5;
	elseif (y <= 2.7e+34)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -3.3e+61], 1.0, If[LessEqual[y, -1.8e-35], -1.0, If[LessEqual[y, -3.05e-145], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -7.2e-187], -1.0, If[LessEqual[y, -5.8e-270], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.8e-190], -1.0, If[LessEqual[y, 9.2e-148], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2.7e+34], -1.0, 1.0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.8 \cdot 10^{-35}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq -3.05 \cdot 10^{-145}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -7.2 \cdot 10^{-187}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq -5.8 \cdot 10^{-270}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{-190}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 9.2 \cdot 10^{-148}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.2999999999999998e61 or 2.7e34 < y

    1. Initial program 100.0%

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

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

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

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

    if -3.2999999999999998e61 < y < -1.80000000000000009e-35 or -3.05e-145 < y < -7.19999999999999989e-187 or -5.79999999999999965e-270 < y < 1.80000000000000003e-190 or 9.1999999999999999e-148 < y < 2.7e34

    1. Initial program 100.0%

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

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

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

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

    if -1.80000000000000009e-35 < y < -3.05e-145

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified63.2%

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

    if -7.19999999999999989e-187 < y < -5.79999999999999965e-270 or 1.80000000000000003e-190 < y < 9.1999999999999999e-148

    1. Initial program 99.9%

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified65.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+61}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-35}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -3.05 \cdot 10^{-145}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{-187}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-270}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-190}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-148}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 3: 62.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x - y\right) \cdot 0.5\\ t_1 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -6.5 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-41}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -1.05 \cdot 10^{-272}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-192}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-147}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+33}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (- x y) 0.5)) (t_1 (- 1.0 (/ x y))))
   (if (<= y -6.5e+70)
     t_1
     (if (<= y -2.8e-41)
       -1.0
       (if (<= y -1.05e-272)
         t_0
         (if (<= y 1.35e-192)
           -1.0
           (if (<= y 3.2e-147) t_0 (if (<= y 1.35e+33) -1.0 t_1))))))))
double code(double x, double y) {
	double t_0 = (x - y) * 0.5;
	double t_1 = 1.0 - (x / y);
	double tmp;
	if (y <= -6.5e+70) {
		tmp = t_1;
	} else if (y <= -2.8e-41) {
		tmp = -1.0;
	} else if (y <= -1.05e-272) {
		tmp = t_0;
	} else if (y <= 1.35e-192) {
		tmp = -1.0;
	} else if (y <= 3.2e-147) {
		tmp = t_0;
	} else if (y <= 1.35e+33) {
		tmp = -1.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x - y) * 0.5d0
    t_1 = 1.0d0 - (x / y)
    if (y <= (-6.5d+70)) then
        tmp = t_1
    else if (y <= (-2.8d-41)) then
        tmp = -1.0d0
    else if (y <= (-1.05d-272)) then
        tmp = t_0
    else if (y <= 1.35d-192) then
        tmp = -1.0d0
    else if (y <= 3.2d-147) then
        tmp = t_0
    else if (y <= 1.35d+33) then
        tmp = -1.0d0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (x - y) * 0.5;
	double t_1 = 1.0 - (x / y);
	double tmp;
	if (y <= -6.5e+70) {
		tmp = t_1;
	} else if (y <= -2.8e-41) {
		tmp = -1.0;
	} else if (y <= -1.05e-272) {
		tmp = t_0;
	} else if (y <= 1.35e-192) {
		tmp = -1.0;
	} else if (y <= 3.2e-147) {
		tmp = t_0;
	} else if (y <= 1.35e+33) {
		tmp = -1.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = (x - y) * 0.5
	t_1 = 1.0 - (x / y)
	tmp = 0
	if y <= -6.5e+70:
		tmp = t_1
	elif y <= -2.8e-41:
		tmp = -1.0
	elif y <= -1.05e-272:
		tmp = t_0
	elif y <= 1.35e-192:
		tmp = -1.0
	elif y <= 3.2e-147:
		tmp = t_0
	elif y <= 1.35e+33:
		tmp = -1.0
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x - y) * 0.5)
	t_1 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -6.5e+70)
		tmp = t_1;
	elseif (y <= -2.8e-41)
		tmp = -1.0;
	elseif (y <= -1.05e-272)
		tmp = t_0;
	elseif (y <= 1.35e-192)
		tmp = -1.0;
	elseif (y <= 3.2e-147)
		tmp = t_0;
	elseif (y <= 1.35e+33)
		tmp = -1.0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x - y) * 0.5;
	t_1 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -6.5e+70)
		tmp = t_1;
	elseif (y <= -2.8e-41)
		tmp = -1.0;
	elseif (y <= -1.05e-272)
		tmp = t_0;
	elseif (y <= 1.35e-192)
		tmp = -1.0;
	elseif (y <= 3.2e-147)
		tmp = t_0;
	elseif (y <= 1.35e+33)
		tmp = -1.0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.5e+70], t$95$1, If[LessEqual[y, -2.8e-41], -1.0, If[LessEqual[y, -1.05e-272], t$95$0, If[LessEqual[y, 1.35e-192], -1.0, If[LessEqual[y, 3.2e-147], t$95$0, If[LessEqual[y, 1.35e+33], -1.0, t$95$1]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -1.05 \cdot 10^{-272}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 3.2 \cdot 10^{-147}:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.49999999999999978e70 or 1.34999999999999996e33 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.49999999999999978e70 < y < -2.8000000000000002e-41 or -1.04999999999999993e-272 < y < 1.34999999999999996e-192 or 3.19999999999999979e-147 < y < 1.34999999999999996e33

    1. Initial program 100.0%

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

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

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

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

    if -2.8000000000000002e-41 < y < -1.04999999999999993e-272 or 1.34999999999999996e-192 < y < 3.19999999999999979e-147

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5} \cdot \left(x - y\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+70}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-41}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -1.05 \cdot 10^{-272}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-192}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-147}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+33}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 4: 62.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x - y\right) \cdot 0.5\\ \mathbf{if}\;y \leq -1.9 \cdot 10^{+61}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.56 \cdot 10^{-40}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -2.05 \cdot 10^{-271}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-192}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-148}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 10^{+33}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (- x y) 0.5)))
   (if (<= y -1.9e+61)
     1.0
     (if (<= y -1.56e-40)
       -1.0
       (if (<= y -2.05e-271)
         t_0
         (if (<= y 1.1e-192)
           -1.0
           (if (<= y 7.6e-148) t_0 (if (<= y 1e+33) -1.0 1.0))))))))
double code(double x, double y) {
	double t_0 = (x - y) * 0.5;
	double tmp;
	if (y <= -1.9e+61) {
		tmp = 1.0;
	} else if (y <= -1.56e-40) {
		tmp = -1.0;
	} else if (y <= -2.05e-271) {
		tmp = t_0;
	} else if (y <= 1.1e-192) {
		tmp = -1.0;
	} else if (y <= 7.6e-148) {
		tmp = t_0;
	} else if (y <= 1e+33) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x - y) * 0.5d0
    if (y <= (-1.9d+61)) then
        tmp = 1.0d0
    else if (y <= (-1.56d-40)) then
        tmp = -1.0d0
    else if (y <= (-2.05d-271)) then
        tmp = t_0
    else if (y <= 1.1d-192) then
        tmp = -1.0d0
    else if (y <= 7.6d-148) then
        tmp = t_0
    else if (y <= 1d+33) then
        tmp = -1.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (x - y) * 0.5;
	double tmp;
	if (y <= -1.9e+61) {
		tmp = 1.0;
	} else if (y <= -1.56e-40) {
		tmp = -1.0;
	} else if (y <= -2.05e-271) {
		tmp = t_0;
	} else if (y <= 1.1e-192) {
		tmp = -1.0;
	} else if (y <= 7.6e-148) {
		tmp = t_0;
	} else if (y <= 1e+33) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (x - y) * 0.5
	tmp = 0
	if y <= -1.9e+61:
		tmp = 1.0
	elif y <= -1.56e-40:
		tmp = -1.0
	elif y <= -2.05e-271:
		tmp = t_0
	elif y <= 1.1e-192:
		tmp = -1.0
	elif y <= 7.6e-148:
		tmp = t_0
	elif y <= 1e+33:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x - y) * 0.5)
	tmp = 0.0
	if (y <= -1.9e+61)
		tmp = 1.0;
	elseif (y <= -1.56e-40)
		tmp = -1.0;
	elseif (y <= -2.05e-271)
		tmp = t_0;
	elseif (y <= 1.1e-192)
		tmp = -1.0;
	elseif (y <= 7.6e-148)
		tmp = t_0;
	elseif (y <= 1e+33)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x - y) * 0.5;
	tmp = 0.0;
	if (y <= -1.9e+61)
		tmp = 1.0;
	elseif (y <= -1.56e-40)
		tmp = -1.0;
	elseif (y <= -2.05e-271)
		tmp = t_0;
	elseif (y <= 1.1e-192)
		tmp = -1.0;
	elseif (y <= 7.6e-148)
		tmp = t_0;
	elseif (y <= 1e+33)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[y, -1.9e+61], 1.0, If[LessEqual[y, -1.56e-40], -1.0, If[LessEqual[y, -2.05e-271], t$95$0, If[LessEqual[y, 1.1e-192], -1.0, If[LessEqual[y, 7.6e-148], t$95$0, If[LessEqual[y, 1e+33], -1.0, 1.0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;y \leq -1.9 \cdot 10^{+61}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;y \leq -2.05 \cdot 10^{-271}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-192}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 7.6 \cdot 10^{-148}:\\
\;\;\;\;t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.89999999999999998e61 or 9.9999999999999995e32 < y

    1. Initial program 100.0%

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

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

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

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

    if -1.89999999999999998e61 < y < -1.55999999999999996e-40 or -2.0500000000000001e-271 < y < 1.10000000000000003e-192 or 7.60000000000000028e-148 < y < 9.9999999999999995e32

    1. Initial program 100.0%

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

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

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

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

    if -1.55999999999999996e-40 < y < -2.0500000000000001e-271 or 1.10000000000000003e-192 < y < 7.60000000000000028e-148

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5} \cdot \left(x - y\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification75.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+61}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.56 \cdot 10^{-40}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -2.05 \cdot 10^{-271}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-192}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-148}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 10^{+33}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 5: 61.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+74}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{-187}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -1.65 \cdot 10^{-269}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-190}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-150}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+32}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1e+74)
   1.0
   (if (<= y -7.2e-187)
     -1.0
     (if (<= y -1.65e-269)
       (* x 0.5)
       (if (<= y 4.6e-190)
         -1.0
         (if (<= y 1.65e-150) (* x 0.5) (if (<= y 5.5e+32) -1.0 1.0)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -1e+74) {
		tmp = 1.0;
	} else if (y <= -7.2e-187) {
		tmp = -1.0;
	} else if (y <= -1.65e-269) {
		tmp = x * 0.5;
	} else if (y <= 4.6e-190) {
		tmp = -1.0;
	} else if (y <= 1.65e-150) {
		tmp = x * 0.5;
	} else if (y <= 5.5e+32) {
		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 <= (-1d+74)) then
        tmp = 1.0d0
    else if (y <= (-7.2d-187)) then
        tmp = -1.0d0
    else if (y <= (-1.65d-269)) then
        tmp = x * 0.5d0
    else if (y <= 4.6d-190) then
        tmp = -1.0d0
    else if (y <= 1.65d-150) then
        tmp = x * 0.5d0
    else if (y <= 5.5d+32) 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 <= -1e+74) {
		tmp = 1.0;
	} else if (y <= -7.2e-187) {
		tmp = -1.0;
	} else if (y <= -1.65e-269) {
		tmp = x * 0.5;
	} else if (y <= 4.6e-190) {
		tmp = -1.0;
	} else if (y <= 1.65e-150) {
		tmp = x * 0.5;
	} else if (y <= 5.5e+32) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1e+74:
		tmp = 1.0
	elif y <= -7.2e-187:
		tmp = -1.0
	elif y <= -1.65e-269:
		tmp = x * 0.5
	elif y <= 4.6e-190:
		tmp = -1.0
	elif y <= 1.65e-150:
		tmp = x * 0.5
	elif y <= 5.5e+32:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1e+74)
		tmp = 1.0;
	elseif (y <= -7.2e-187)
		tmp = -1.0;
	elseif (y <= -1.65e-269)
		tmp = Float64(x * 0.5);
	elseif (y <= 4.6e-190)
		tmp = -1.0;
	elseif (y <= 1.65e-150)
		tmp = Float64(x * 0.5);
	elseif (y <= 5.5e+32)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1e+74)
		tmp = 1.0;
	elseif (y <= -7.2e-187)
		tmp = -1.0;
	elseif (y <= -1.65e-269)
		tmp = x * 0.5;
	elseif (y <= 4.6e-190)
		tmp = -1.0;
	elseif (y <= 1.65e-150)
		tmp = x * 0.5;
	elseif (y <= 5.5e+32)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1e+74], 1.0, If[LessEqual[y, -7.2e-187], -1.0, If[LessEqual[y, -1.65e-269], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4.6e-190], -1.0, If[LessEqual[y, 1.65e-150], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.5e+32], -1.0, 1.0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -7.2 \cdot 10^{-187}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq -1.65 \cdot 10^{-269}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 4.6 \cdot 10^{-190}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \leq 1.65 \cdot 10^{-150}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 5.5 \cdot 10^{+32}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.99999999999999952e73 or 5.49999999999999984e32 < y

    1. Initial program 100.0%

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

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

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

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

    if -9.99999999999999952e73 < y < -7.19999999999999989e-187 or -1.65e-269 < y < 4.59999999999999984e-190 or 1.6500000000000001e-150 < y < 5.49999999999999984e32

    1. Initial program 100.0%

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

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

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

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

    if -7.19999999999999989e-187 < y < -1.65e-269 or 4.59999999999999984e-190 < y < 1.6500000000000001e-150

    1. Initial program 99.9%

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified65.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+74}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{-187}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq -1.65 \cdot 10^{-269}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-190}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-150}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+32}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 73.4% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;y \leq -2.2 \cdot 10^{-41}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.75 \cdot 10^{-146}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\

\mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.39999999999999989e71 or 2.7e34 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.39999999999999989e71 < y < -2.2e-41 or -1.7500000000000001e-146 < y < 2.7e34

    1. Initial program 100.0%

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

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

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

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

    if -2.2e-41 < y < -1.7500000000000001e-146

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5} \cdot \left(x - y\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.4 \cdot 10^{+71}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-41}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-146}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 7: 73.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -7.5 \cdot 10^{+70}:\\ \;\;\;\;\frac{y - x}{y}\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{-41}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-145}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 5.7 \cdot 10^{+32}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -7.5e+70)
     (/ (- y x) y)
     (if (<= y -8.2e-41)
       t_0
       (if (<= y -3.9e-145)
         (* (- x y) 0.5)
         (if (<= y 5.7e+32) t_0 (- 1.0 (/ x y))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -7.5e+70) {
		tmp = (y - x) / y;
	} else if (y <= -8.2e-41) {
		tmp = t_0;
	} else if (y <= -3.9e-145) {
		tmp = (x - y) * 0.5;
	} else if (y <= 5.7e+32) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = x / (2.0d0 - x)
    if (y <= (-7.5d+70)) then
        tmp = (y - x) / y
    else if (y <= (-8.2d-41)) then
        tmp = t_0
    else if (y <= (-3.9d-145)) then
        tmp = (x - y) * 0.5d0
    else if (y <= 5.7d+32) then
        tmp = t_0
    else
        tmp = 1.0d0 - (x / y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -7.5e+70) {
		tmp = (y - x) / y;
	} else if (y <= -8.2e-41) {
		tmp = t_0;
	} else if (y <= -3.9e-145) {
		tmp = (x - y) * 0.5;
	} else if (y <= 5.7e+32) {
		tmp = t_0;
	} else {
		tmp = 1.0 - (x / y);
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -7.5e+70:
		tmp = (y - x) / y
	elif y <= -8.2e-41:
		tmp = t_0
	elif y <= -3.9e-145:
		tmp = (x - y) * 0.5
	elif y <= 5.7e+32:
		tmp = t_0
	else:
		tmp = 1.0 - (x / y)
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -7.5e+70)
		tmp = Float64(Float64(y - x) / y);
	elseif (y <= -8.2e-41)
		tmp = t_0;
	elseif (y <= -3.9e-145)
		tmp = Float64(Float64(x - y) * 0.5);
	elseif (y <= 5.7e+32)
		tmp = t_0;
	else
		tmp = Float64(1.0 - Float64(x / y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -7.5e+70)
		tmp = (y - x) / y;
	elseif (y <= -8.2e-41)
		tmp = t_0;
	elseif (y <= -3.9e-145)
		tmp = (x - y) * 0.5;
	elseif (y <= 5.7e+32)
		tmp = t_0;
	else
		tmp = 1.0 - (x / y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.5e+70], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, -8.2e-41], t$95$0, If[LessEqual[y, -3.9e-145], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 5.7e+32], t$95$0, N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -8.2 \cdot 10^{-41}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -3.9 \cdot 10^{-145}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\

\mathbf{elif}\;y \leq 5.7 \cdot 10^{+32}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -7.50000000000000031e70

    1. Initial program 99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-1}{y}} \cdot \left(x - y\right) \]
    7. Step-by-step derivation
      1. *-commutative91.8%

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

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

        \[\leadsto \left(x - y\right) \cdot \frac{\color{blue}{1}}{-y} \]
      4. un-div-inv92.1%

        \[\leadsto \color{blue}{\frac{x - y}{-y}} \]
    8. Applied egg-rr92.1%

      \[\leadsto \color{blue}{\frac{x - y}{-y}} \]
    9. Step-by-step derivation
      1. frac-2neg92.1%

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

        \[\leadsto \color{blue}{\left(-\left(x - y\right)\right) \cdot \frac{1}{-\left(-y\right)}} \]
      3. sub-neg91.8%

        \[\leadsto \left(-\color{blue}{\left(x + \left(-y\right)\right)}\right) \cdot \frac{1}{-\left(-y\right)} \]
      4. distribute-neg-in91.8%

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

        \[\leadsto \left(\color{blue}{-1 \cdot x} + \left(-\left(-y\right)\right)\right) \cdot \frac{1}{-\left(-y\right)} \]
      6. remove-double-neg91.8%

        \[\leadsto \left(-1 \cdot x + \color{blue}{y}\right) \cdot \frac{1}{-\left(-y\right)} \]
      7. fma-def91.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1, x, y\right)} \cdot \frac{1}{-\left(-y\right)} \]
      8. remove-double-neg91.8%

        \[\leadsto \mathsf{fma}\left(-1, x, y\right) \cdot \frac{1}{\color{blue}{y}} \]
    10. Applied egg-rr91.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, x, y\right) \cdot \frac{1}{y}} \]
    11. Step-by-step derivation
      1. associate-*r/92.1%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, x, y\right) \cdot 1}{y}} \]
      2. *-rgt-identity92.1%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-1, x, y\right)}}{y} \]
      3. fma-udef92.1%

        \[\leadsto \frac{\color{blue}{-1 \cdot x + y}}{y} \]
      4. neg-mul-192.1%

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

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

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

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

    if -7.50000000000000031e70 < y < -8.20000000000000028e-41 or -3.90000000000000029e-145 < y < 5.7e32

    1. Initial program 100.0%

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

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

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

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

    if -8.20000000000000028e-41 < y < -3.90000000000000029e-145

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 5.7e32 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{+70}:\\ \;\;\;\;\frac{y - x}{y}\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{-41}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-145}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 5.7 \cdot 10^{+32}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 8: 85.6% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -9.5e15

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -9.5e15 < x < 2.69999999999999989e99

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 2.69999999999999989e99 < x

    1. Initial program 100.0%

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

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

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

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

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

Alternative 9: 63.2% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;y \leq 5.2 \cdot 10^{+32}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.89999999999999998e61 or 5.2000000000000004e32 < y

    1. Initial program 100.0%

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

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

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

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

    if -1.89999999999999998e61 < y < 5.2000000000000004e32

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+61}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+32}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 10: 38.4% accurate, 9.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification35.6%

    \[\leadsto -1 \]

Developer target: 100.0% accurate, 0.6× speedup?

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

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

Reproduce

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