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

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

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.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}
Derivation
  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. div-sub100.0%

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

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

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

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

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

Alternative 2: 61.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x} + -1\\ \mathbf{if}\;x \leq -3.3 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-245}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-277}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-302}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-232}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-112}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (/ y x) -1.0)))
   (if (<= x -3.3e+37)
     t_0
     (if (<= x -4.6e-245)
       (- 1.0 (/ x y))
       (if (<= x -1.9e-277)
         (* y -0.5)
         (if (<= x 1.4e-302)
           (+ 1.0 (/ 2.0 y))
           (if (<= x 1.25e-232)
             (* y -0.5)
             (if (<= x 1.3e-112)
               1.0
               (if (<= x 5e-20) (* x 0.5) (if (<= x 5.5e+19) 1.0 t_0))))))))))
double code(double x, double y) {
	double t_0 = (y / x) + -1.0;
	double tmp;
	if (x <= -3.3e+37) {
		tmp = t_0;
	} else if (x <= -4.6e-245) {
		tmp = 1.0 - (x / y);
	} else if (x <= -1.9e-277) {
		tmp = y * -0.5;
	} else if (x <= 1.4e-302) {
		tmp = 1.0 + (2.0 / y);
	} else if (x <= 1.25e-232) {
		tmp = y * -0.5;
	} else if (x <= 1.3e-112) {
		tmp = 1.0;
	} else if (x <= 5e-20) {
		tmp = x * 0.5;
	} else if (x <= 5.5e+19) {
		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 <= (-3.3d+37)) then
        tmp = t_0
    else if (x <= (-4.6d-245)) then
        tmp = 1.0d0 - (x / y)
    else if (x <= (-1.9d-277)) then
        tmp = y * (-0.5d0)
    else if (x <= 1.4d-302) then
        tmp = 1.0d0 + (2.0d0 / y)
    else if (x <= 1.25d-232) then
        tmp = y * (-0.5d0)
    else if (x <= 1.3d-112) then
        tmp = 1.0d0
    else if (x <= 5d-20) then
        tmp = x * 0.5d0
    else if (x <= 5.5d+19) 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 <= -3.3e+37) {
		tmp = t_0;
	} else if (x <= -4.6e-245) {
		tmp = 1.0 - (x / y);
	} else if (x <= -1.9e-277) {
		tmp = y * -0.5;
	} else if (x <= 1.4e-302) {
		tmp = 1.0 + (2.0 / y);
	} else if (x <= 1.25e-232) {
		tmp = y * -0.5;
	} else if (x <= 1.3e-112) {
		tmp = 1.0;
	} else if (x <= 5e-20) {
		tmp = x * 0.5;
	} else if (x <= 5.5e+19) {
		tmp = 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y / x) + -1.0
	tmp = 0
	if x <= -3.3e+37:
		tmp = t_0
	elif x <= -4.6e-245:
		tmp = 1.0 - (x / y)
	elif x <= -1.9e-277:
		tmp = y * -0.5
	elif x <= 1.4e-302:
		tmp = 1.0 + (2.0 / y)
	elif x <= 1.25e-232:
		tmp = y * -0.5
	elif x <= 1.3e-112:
		tmp = 1.0
	elif x <= 5e-20:
		tmp = x * 0.5
	elif x <= 5.5e+19:
		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 <= -3.3e+37)
		tmp = t_0;
	elseif (x <= -4.6e-245)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (x <= -1.9e-277)
		tmp = Float64(y * -0.5);
	elseif (x <= 1.4e-302)
		tmp = Float64(1.0 + Float64(2.0 / y));
	elseif (x <= 1.25e-232)
		tmp = Float64(y * -0.5);
	elseif (x <= 1.3e-112)
		tmp = 1.0;
	elseif (x <= 5e-20)
		tmp = Float64(x * 0.5);
	elseif (x <= 5.5e+19)
		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 <= -3.3e+37)
		tmp = t_0;
	elseif (x <= -4.6e-245)
		tmp = 1.0 - (x / y);
	elseif (x <= -1.9e-277)
		tmp = y * -0.5;
	elseif (x <= 1.4e-302)
		tmp = 1.0 + (2.0 / y);
	elseif (x <= 1.25e-232)
		tmp = y * -0.5;
	elseif (x <= 1.3e-112)
		tmp = 1.0;
	elseif (x <= 5e-20)
		tmp = x * 0.5;
	elseif (x <= 5.5e+19)
		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, -3.3e+37], t$95$0, If[LessEqual[x, -4.6e-245], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.9e-277], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.4e-302], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25e-232], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.3e-112], 1.0, If[LessEqual[x, 5e-20], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 5.5e+19], 1.0, t$95$0]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq -1.9 \cdot 10^{-277}:\\
\;\;\;\;y \cdot -0.5\\

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

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-232}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-112}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-20}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 5.5 \cdot 10^{+19}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < -3.3000000000000001e37 or 5.5e19 < x

    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.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 82.2%

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

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

    if -3.3000000000000001e37 < x < -4.6000000000000003e-245

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(2 - x\right) - y}{x - y}}} \]
      2. associate-/r/99.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 54.5%

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

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

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

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

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

    if -4.6000000000000003e-245 < x < -1.89999999999999993e-277 or 1.4e-302 < x < 1.25e-232

    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 87.0%

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified62.8%

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

    if -1.89999999999999993e-277 < x < 1.4e-302

    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 100.0%

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

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

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

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

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

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

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

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

    if 1.25e-232 < x < 1.29999999999999996e-112 or 4.9999999999999999e-20 < x < 5.5e19

    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 inf 61.8%

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

    if 1.29999999999999996e-112 < x < 4.9999999999999999e-20

    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 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified57.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.3 \cdot 10^{+37}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-245}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-277}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-302}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-232}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-112}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x} + -1\\ \end{array} \]

Alternative 3: 60.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{+37}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-240}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{-277}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 6.1 \cdot 10^{-301}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-232}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{-110}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 10^{+20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -2.7e+37)
   -1.0
   (if (<= x -1.35e-240)
     1.0
     (if (<= x -3.6e-277)
       (* y -0.5)
       (if (<= x 6.1e-301)
         (+ 1.0 (/ 2.0 y))
         (if (<= x 4e-232)
           (* y -0.5)
           (if (<= x 2.05e-110)
             1.0
             (if (<= x 2.4e-20) (* x 0.5) (if (<= x 1e+20) 1.0 -1.0)))))))))
double code(double x, double y) {
	double tmp;
	if (x <= -2.7e+37) {
		tmp = -1.0;
	} else if (x <= -1.35e-240) {
		tmp = 1.0;
	} else if (x <= -3.6e-277) {
		tmp = y * -0.5;
	} else if (x <= 6.1e-301) {
		tmp = 1.0 + (2.0 / y);
	} else if (x <= 4e-232) {
		tmp = y * -0.5;
	} else if (x <= 2.05e-110) {
		tmp = 1.0;
	} else if (x <= 2.4e-20) {
		tmp = x * 0.5;
	} else if (x <= 1e+20) {
		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.7d+37)) then
        tmp = -1.0d0
    else if (x <= (-1.35d-240)) then
        tmp = 1.0d0
    else if (x <= (-3.6d-277)) then
        tmp = y * (-0.5d0)
    else if (x <= 6.1d-301) then
        tmp = 1.0d0 + (2.0d0 / y)
    else if (x <= 4d-232) then
        tmp = y * (-0.5d0)
    else if (x <= 2.05d-110) then
        tmp = 1.0d0
    else if (x <= 2.4d-20) then
        tmp = x * 0.5d0
    else if (x <= 1d+20) 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.7e+37) {
		tmp = -1.0;
	} else if (x <= -1.35e-240) {
		tmp = 1.0;
	} else if (x <= -3.6e-277) {
		tmp = y * -0.5;
	} else if (x <= 6.1e-301) {
		tmp = 1.0 + (2.0 / y);
	} else if (x <= 4e-232) {
		tmp = y * -0.5;
	} else if (x <= 2.05e-110) {
		tmp = 1.0;
	} else if (x <= 2.4e-20) {
		tmp = x * 0.5;
	} else if (x <= 1e+20) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -2.7e+37:
		tmp = -1.0
	elif x <= -1.35e-240:
		tmp = 1.0
	elif x <= -3.6e-277:
		tmp = y * -0.5
	elif x <= 6.1e-301:
		tmp = 1.0 + (2.0 / y)
	elif x <= 4e-232:
		tmp = y * -0.5
	elif x <= 2.05e-110:
		tmp = 1.0
	elif x <= 2.4e-20:
		tmp = x * 0.5
	elif x <= 1e+20:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -2.7e+37)
		tmp = -1.0;
	elseif (x <= -1.35e-240)
		tmp = 1.0;
	elseif (x <= -3.6e-277)
		tmp = Float64(y * -0.5);
	elseif (x <= 6.1e-301)
		tmp = Float64(1.0 + Float64(2.0 / y));
	elseif (x <= 4e-232)
		tmp = Float64(y * -0.5);
	elseif (x <= 2.05e-110)
		tmp = 1.0;
	elseif (x <= 2.4e-20)
		tmp = Float64(x * 0.5);
	elseif (x <= 1e+20)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -2.7e+37)
		tmp = -1.0;
	elseif (x <= -1.35e-240)
		tmp = 1.0;
	elseif (x <= -3.6e-277)
		tmp = y * -0.5;
	elseif (x <= 6.1e-301)
		tmp = 1.0 + (2.0 / y);
	elseif (x <= 4e-232)
		tmp = y * -0.5;
	elseif (x <= 2.05e-110)
		tmp = 1.0;
	elseif (x <= 2.4e-20)
		tmp = x * 0.5;
	elseif (x <= 1e+20)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -2.7e+37], -1.0, If[LessEqual[x, -1.35e-240], 1.0, If[LessEqual[x, -3.6e-277], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 6.1e-301], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4e-232], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2.05e-110], 1.0, If[LessEqual[x, 2.4e-20], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1e+20], 1.0, -1.0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.35 \cdot 10^{-240}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -3.6 \cdot 10^{-277}:\\
\;\;\;\;y \cdot -0.5\\

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

\mathbf{elif}\;x \leq 4 \cdot 10^{-232}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 2.05 \cdot 10^{-110}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 2.4 \cdot 10^{-20}:\\
\;\;\;\;x \cdot 0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -2.69999999999999986e37 or 1e20 < x

    1. Initial program 99.9%

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

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

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

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

    if -2.69999999999999986e37 < x < -1.35000000000000009e-240 or 4.0000000000000001e-232 < x < 2.04999999999999991e-110 or 2.39999999999999993e-20 < x < 1e20

    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 inf 56.7%

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

    if -1.35000000000000009e-240 < x < -3.59999999999999984e-277 or 6.1000000000000001e-301 < x < 4.0000000000000001e-232

    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 87.0%

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified62.8%

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

    if -3.59999999999999984e-277 < x < 6.1000000000000001e-301

    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 100.0%

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

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

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

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

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

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

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

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

    if 2.04999999999999991e-110 < x < 2.39999999999999993e-20

    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 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified57.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{+37}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-240}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{-277}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 6.1 \cdot 10^{-301}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-232}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{-110}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 10^{+20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 4: 60.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{+36}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-242}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-273}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-303}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-232}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-110}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -9.2e+36)
   -1.0
   (if (<= x -1.05e-242)
     (- 1.0 (/ x y))
     (if (<= x -1.45e-273)
       (* y -0.5)
       (if (<= x 4.1e-303)
         (+ 1.0 (/ 2.0 y))
         (if (<= x 1.9e-232)
           (* y -0.5)
           (if (<= x 1.5e-110)
             1.0
             (if (<= x 1.95e-20) (* x 0.5) (if (<= x 1.7e+19) 1.0 -1.0)))))))))
double code(double x, double y) {
	double tmp;
	if (x <= -9.2e+36) {
		tmp = -1.0;
	} else if (x <= -1.05e-242) {
		tmp = 1.0 - (x / y);
	} else if (x <= -1.45e-273) {
		tmp = y * -0.5;
	} else if (x <= 4.1e-303) {
		tmp = 1.0 + (2.0 / y);
	} else if (x <= 1.9e-232) {
		tmp = y * -0.5;
	} else if (x <= 1.5e-110) {
		tmp = 1.0;
	} else if (x <= 1.95e-20) {
		tmp = x * 0.5;
	} else if (x <= 1.7e+19) {
		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 <= (-9.2d+36)) then
        tmp = -1.0d0
    else if (x <= (-1.05d-242)) then
        tmp = 1.0d0 - (x / y)
    else if (x <= (-1.45d-273)) then
        tmp = y * (-0.5d0)
    else if (x <= 4.1d-303) then
        tmp = 1.0d0 + (2.0d0 / y)
    else if (x <= 1.9d-232) then
        tmp = y * (-0.5d0)
    else if (x <= 1.5d-110) then
        tmp = 1.0d0
    else if (x <= 1.95d-20) then
        tmp = x * 0.5d0
    else if (x <= 1.7d+19) 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 <= -9.2e+36) {
		tmp = -1.0;
	} else if (x <= -1.05e-242) {
		tmp = 1.0 - (x / y);
	} else if (x <= -1.45e-273) {
		tmp = y * -0.5;
	} else if (x <= 4.1e-303) {
		tmp = 1.0 + (2.0 / y);
	} else if (x <= 1.9e-232) {
		tmp = y * -0.5;
	} else if (x <= 1.5e-110) {
		tmp = 1.0;
	} else if (x <= 1.95e-20) {
		tmp = x * 0.5;
	} else if (x <= 1.7e+19) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -9.2e+36:
		tmp = -1.0
	elif x <= -1.05e-242:
		tmp = 1.0 - (x / y)
	elif x <= -1.45e-273:
		tmp = y * -0.5
	elif x <= 4.1e-303:
		tmp = 1.0 + (2.0 / y)
	elif x <= 1.9e-232:
		tmp = y * -0.5
	elif x <= 1.5e-110:
		tmp = 1.0
	elif x <= 1.95e-20:
		tmp = x * 0.5
	elif x <= 1.7e+19:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -9.2e+36)
		tmp = -1.0;
	elseif (x <= -1.05e-242)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (x <= -1.45e-273)
		tmp = Float64(y * -0.5);
	elseif (x <= 4.1e-303)
		tmp = Float64(1.0 + Float64(2.0 / y));
	elseif (x <= 1.9e-232)
		tmp = Float64(y * -0.5);
	elseif (x <= 1.5e-110)
		tmp = 1.0;
	elseif (x <= 1.95e-20)
		tmp = Float64(x * 0.5);
	elseif (x <= 1.7e+19)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -9.2e+36)
		tmp = -1.0;
	elseif (x <= -1.05e-242)
		tmp = 1.0 - (x / y);
	elseif (x <= -1.45e-273)
		tmp = y * -0.5;
	elseif (x <= 4.1e-303)
		tmp = 1.0 + (2.0 / y);
	elseif (x <= 1.9e-232)
		tmp = y * -0.5;
	elseif (x <= 1.5e-110)
		tmp = 1.0;
	elseif (x <= 1.95e-20)
		tmp = x * 0.5;
	elseif (x <= 1.7e+19)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -9.2e+36], -1.0, If[LessEqual[x, -1.05e-242], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.45e-273], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 4.1e-303], N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.9e-232], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.5e-110], 1.0, If[LessEqual[x, 1.95e-20], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.7e+19], 1.0, -1.0]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq -1.45 \cdot 10^{-273}:\\
\;\;\;\;y \cdot -0.5\\

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

\mathbf{elif}\;x \leq 1.9 \cdot 10^{-232}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-110}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 1.95 \cdot 10^{-20}:\\
\;\;\;\;x \cdot 0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < -9.19999999999999986e36 or 1.7e19 < x

    1. Initial program 99.9%

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

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

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

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

    if -9.19999999999999986e36 < x < -1.05000000000000009e-242

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(2 - x\right) - y}{x - y}}} \]
      2. associate-/r/99.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 54.5%

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

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

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

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

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

    if -1.05000000000000009e-242 < x < -1.44999999999999993e-273 or 4.10000000000000018e-303 < x < 1.9000000000000001e-232

    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 87.0%

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified62.8%

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

    if -1.44999999999999993e-273 < x < 4.10000000000000018e-303

    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 100.0%

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

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

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

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

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

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

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

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

    if 1.9000000000000001e-232 < x < 1.49999999999999993e-110 or 1.95000000000000004e-20 < x < 1.7e19

    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 inf 61.8%

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

    if 1.49999999999999993e-110 < x < 1.95000000000000004e-20

    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 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified57.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{+36}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-242}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-273}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-303}:\\ \;\;\;\;1 + \frac{2}{y}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-232}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-110}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 5: 61.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+37}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.95 \cdot 10^{-244}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{-272}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-111}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1e+37)
   -1.0
   (if (<= x -1.95e-244)
     1.0
     (if (<= x -1.2e-272)
       (* y -0.5)
       (if (<= x 3.8e-111)
         1.0
         (if (<= x 1e-20) (* x 0.5) (if (<= x 2.3e+19) 1.0 -1.0)))))))
double code(double x, double y) {
	double tmp;
	if (x <= -1e+37) {
		tmp = -1.0;
	} else if (x <= -1.95e-244) {
		tmp = 1.0;
	} else if (x <= -1.2e-272) {
		tmp = y * -0.5;
	} else if (x <= 3.8e-111) {
		tmp = 1.0;
	} else if (x <= 1e-20) {
		tmp = x * 0.5;
	} else if (x <= 2.3e+19) {
		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 <= (-1d+37)) then
        tmp = -1.0d0
    else if (x <= (-1.95d-244)) then
        tmp = 1.0d0
    else if (x <= (-1.2d-272)) then
        tmp = y * (-0.5d0)
    else if (x <= 3.8d-111) then
        tmp = 1.0d0
    else if (x <= 1d-20) then
        tmp = x * 0.5d0
    else if (x <= 2.3d+19) 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 <= -1e+37) {
		tmp = -1.0;
	} else if (x <= -1.95e-244) {
		tmp = 1.0;
	} else if (x <= -1.2e-272) {
		tmp = y * -0.5;
	} else if (x <= 3.8e-111) {
		tmp = 1.0;
	} else if (x <= 1e-20) {
		tmp = x * 0.5;
	} else if (x <= 2.3e+19) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1e+37:
		tmp = -1.0
	elif x <= -1.95e-244:
		tmp = 1.0
	elif x <= -1.2e-272:
		tmp = y * -0.5
	elif x <= 3.8e-111:
		tmp = 1.0
	elif x <= 1e-20:
		tmp = x * 0.5
	elif x <= 2.3e+19:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1e+37)
		tmp = -1.0;
	elseif (x <= -1.95e-244)
		tmp = 1.0;
	elseif (x <= -1.2e-272)
		tmp = Float64(y * -0.5);
	elseif (x <= 3.8e-111)
		tmp = 1.0;
	elseif (x <= 1e-20)
		tmp = Float64(x * 0.5);
	elseif (x <= 2.3e+19)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1e+37)
		tmp = -1.0;
	elseif (x <= -1.95e-244)
		tmp = 1.0;
	elseif (x <= -1.2e-272)
		tmp = y * -0.5;
	elseif (x <= 3.8e-111)
		tmp = 1.0;
	elseif (x <= 1e-20)
		tmp = x * 0.5;
	elseif (x <= 2.3e+19)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1e+37], -1.0, If[LessEqual[x, -1.95e-244], 1.0, If[LessEqual[x, -1.2e-272], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 3.8e-111], 1.0, If[LessEqual[x, 1e-20], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2.3e+19], 1.0, -1.0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.95 \cdot 10^{-244}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -1.2 \cdot 10^{-272}:\\
\;\;\;\;y \cdot -0.5\\

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

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

\mathbf{elif}\;x \leq 2.3 \cdot 10^{+19}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -9.99999999999999954e36 or 2.3e19 < x

    1. Initial program 99.9%

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

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

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

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

    if -9.99999999999999954e36 < x < -1.9499999999999999e-244 or -1.19999999999999995e-272 < x < 3.80000000000000022e-111 or 9.99999999999999945e-21 < x < 2.3e19

    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 inf 55.1%

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

    if -1.9499999999999999e-244 < x < -1.19999999999999995e-272

    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 78.5%

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified78.5%

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

    if 3.80000000000000022e-111 < x < 9.99999999999999945e-21

    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 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified57.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+37}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq -1.95 \cdot 10^{-244}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{-272}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-111}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 6: 75.3% 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 -1.3 \cdot 10^{+25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5.9 \cdot 10^{-62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-79}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 32000:\\ \;\;\;\;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 -1.3e+25)
     t_0
     (if (<= y -5.9e-62)
       t_1
       (if (<= y -1.35e-79) (* y -0.5) (if (<= y 32000.0) 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 <= -1.3e+25) {
		tmp = t_0;
	} else if (y <= -5.9e-62) {
		tmp = t_1;
	} else if (y <= -1.35e-79) {
		tmp = y * -0.5;
	} else if (y <= 32000.0) {
		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 <= (-1.3d+25)) then
        tmp = t_0
    else if (y <= (-5.9d-62)) then
        tmp = t_1
    else if (y <= (-1.35d-79)) then
        tmp = y * (-0.5d0)
    else if (y <= 32000.0d0) 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 <= -1.3e+25) {
		tmp = t_0;
	} else if (y <= -5.9e-62) {
		tmp = t_1;
	} else if (y <= -1.35e-79) {
		tmp = y * -0.5;
	} else if (y <= 32000.0) {
		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 <= -1.3e+25:
		tmp = t_0
	elif y <= -5.9e-62:
		tmp = t_1
	elif y <= -1.35e-79:
		tmp = y * -0.5
	elif y <= 32000.0:
		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 <= -1.3e+25)
		tmp = t_0;
	elseif (y <= -5.9e-62)
		tmp = t_1;
	elseif (y <= -1.35e-79)
		tmp = Float64(y * -0.5);
	elseif (y <= 32000.0)
		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 <= -1.3e+25)
		tmp = t_0;
	elseif (y <= -5.9e-62)
		tmp = t_1;
	elseif (y <= -1.35e-79)
		tmp = y * -0.5;
	elseif (y <= 32000.0)
		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, -1.3e+25], t$95$0, If[LessEqual[y, -5.9e-62], t$95$1, If[LessEqual[y, -1.35e-79], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 32000.0], 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 -1.3 \cdot 10^{+25}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -5.9 \cdot 10^{-62}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.35 \cdot 10^{-79}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 32000:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.2999999999999999e25 or 32000 < y

    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.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 y around inf 72.5%

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

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

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

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

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

    if -1.2999999999999999e25 < y < -5.9000000000000004e-62 or -1.3500000000000001e-79 < y < 32000

    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 75.7%

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

    if -5.9000000000000004e-62 < y < -1.3500000000000001e-79

    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 95.3%

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    9. Simplified95.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+25}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -5.9 \cdot 10^{-62}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-79}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 32000:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 7: 86.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+37} \lor \neg \left(x \leq 6.8 \cdot 10^{+18}\right):\\ \;\;\;\;\frac{x - y}{-x}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -1.2e+37) (not (<= x 6.8e+18)))
   (/ (- x y) (- x))
   (* (- x y) (/ 1.0 (- 2.0 y)))))
double code(double x, double y) {
	double tmp;
	if ((x <= -1.2e+37) || !(x <= 6.8e+18)) {
		tmp = (x - y) / -x;
	} else {
		tmp = (x - y) * (1.0 / (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 ((x <= (-1.2d+37)) .or. (.not. (x <= 6.8d+18))) then
        tmp = (x - y) / -x
    else
        tmp = (x - y) * (1.0d0 / (2.0d0 - y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -1.2e+37) || !(x <= 6.8e+18)) {
		tmp = (x - y) / -x;
	} else {
		tmp = (x - y) * (1.0 / (2.0 - y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -1.2e+37) or not (x <= 6.8e+18):
		tmp = (x - y) / -x
	else:
		tmp = (x - y) * (1.0 / (2.0 - y))
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -1.2e+37) || !(x <= 6.8e+18))
		tmp = Float64(Float64(x - y) / Float64(-x));
	else
		tmp = Float64(Float64(x - y) * Float64(1.0 / Float64(2.0 - y)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -1.2e+37) || ~((x <= 6.8e+18)))
		tmp = (x - y) / -x;
	else
		tmp = (x - y) * (1.0 / (2.0 - y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -1.2e+37], N[Not[LessEqual[x, 6.8e+18]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(1.0 / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+37} \lor \neg \left(x \leq 6.8 \cdot 10^{+18}\right):\\
\;\;\;\;\frac{x - y}{-x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.2e37 or 6.8e18 < x

    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.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 82.2%

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

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

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

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

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

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

    if -1.2e37 < x < 6.8e18

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(2 - x\right) - y}{x - y}}} \]
      2. associate-/r/99.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 94.5%

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

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

Alternative 8: 73.8% accurate, 0.9× speedup?

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

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

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

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


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

    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.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 83.9%

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

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

    if -2.49999999999999988e36 < x < 8.19999999999999987e-79

    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 80.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{2 - y}} \]
    5. 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} \]
    6. Simplified80.1%

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

    if 8.19999999999999987e-79 < x

    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 73.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+36}:\\ \;\;\;\;\frac{y}{x} + -1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-79}:\\ \;\;\;\;\frac{-y}{2 - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]

Alternative 9: 73.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+37}:\\
\;\;\;\;\frac{x - y}{-x}\\

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

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


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

    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.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 83.9%

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

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

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

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

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

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

    if -4.8e37 < x < 5.60000000000000023e-79

    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 80.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{2 - y}} \]
    5. 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} \]
    6. Simplified80.1%

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

    if 5.60000000000000023e-79 < x

    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 73.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{+37}:\\ \;\;\;\;\frac{x - y}{-x}\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-79}:\\ \;\;\;\;\frac{-y}{2 - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2 - x}\\ \end{array} \]

Alternative 10: 61.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{+36}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-111}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+18}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -6e+36)
   -1.0
   (if (<= x 2.6e-111)
     1.0
     (if (<= x 8.5e-20) (* x 0.5) (if (<= x 8.5e+18) 1.0 -1.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -6e+36) {
		tmp = -1.0;
	} else if (x <= 2.6e-111) {
		tmp = 1.0;
	} else if (x <= 8.5e-20) {
		tmp = x * 0.5;
	} else if (x <= 8.5e+18) {
		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 <= (-6d+36)) then
        tmp = -1.0d0
    else if (x <= 2.6d-111) then
        tmp = 1.0d0
    else if (x <= 8.5d-20) then
        tmp = x * 0.5d0
    else if (x <= 8.5d+18) 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 <= -6e+36) {
		tmp = -1.0;
	} else if (x <= 2.6e-111) {
		tmp = 1.0;
	} else if (x <= 8.5e-20) {
		tmp = x * 0.5;
	} else if (x <= 8.5e+18) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -6e+36:
		tmp = -1.0
	elif x <= 2.6e-111:
		tmp = 1.0
	elif x <= 8.5e-20:
		tmp = x * 0.5
	elif x <= 8.5e+18:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -6e+36)
		tmp = -1.0;
	elseif (x <= 2.6e-111)
		tmp = 1.0;
	elseif (x <= 8.5e-20)
		tmp = Float64(x * 0.5);
	elseif (x <= 8.5e+18)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -6e+36)
		tmp = -1.0;
	elseif (x <= 2.6e-111)
		tmp = 1.0;
	elseif (x <= 8.5e-20)
		tmp = x * 0.5;
	elseif (x <= 8.5e+18)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -6e+36], -1.0, If[LessEqual[x, 2.6e-111], 1.0, If[LessEqual[x, 8.5e-20], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 8.5e+18], 1.0, -1.0]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 2.6 \cdot 10^{-111}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-20}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{+18}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6e36 or 8.5e18 < x

    1. Initial program 99.9%

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

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

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

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

    if -6e36 < x < 2.59999999999999982e-111 or 8.5000000000000005e-20 < x < 8.5e18

    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 inf 52.5%

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

    if 2.59999999999999982e-111 < x < 8.5000000000000005e-20

    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 57.9%

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    7. Simplified57.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{+36}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-111}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-20}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+18}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 11: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 12: 62.6% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 2.6 \cdot 10^{+19}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.49999999999999988e36 or 2.6e19 < x

    1. Initial program 99.9%

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

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

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

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

    if -2.49999999999999988e36 < x < 2.6e19

    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 inf 49.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+36}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 13: 37.5% 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 99.9%

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

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

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification39.3%

    \[\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 2023287 
(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))))