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

Percentage Accurate: 100.0% → 100.0%
Time: 11.7s
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, 1.0× speedup?

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

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

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

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

Alternative 2: 71.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -3.1 \cdot 10^{+57}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-150}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-81}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{+58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+147}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+177}:\\ \;\;\;\;-1 + \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -3.1e+57)
     1.0
     (if (<= y 1.6e-150)
       t_0
       (if (<= y 1.9e-81)
         (* (- x y) 0.5)
         (if (<= y 2.35e+58)
           t_0
           (if (<= y 1.9e+147)
             1.0
             (if (<= y 1.2e+177) (+ -1.0 (/ y x)) 1.0))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -3.1e+57) {
		tmp = 1.0;
	} else if (y <= 1.6e-150) {
		tmp = t_0;
	} else if (y <= 1.9e-81) {
		tmp = (x - y) * 0.5;
	} else if (y <= 2.35e+58) {
		tmp = t_0;
	} else if (y <= 1.9e+147) {
		tmp = 1.0;
	} else if (y <= 1.2e+177) {
		tmp = -1.0 + (y / x);
	} 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 / (2.0d0 - x)
    if (y <= (-3.1d+57)) then
        tmp = 1.0d0
    else if (y <= 1.6d-150) then
        tmp = t_0
    else if (y <= 1.9d-81) then
        tmp = (x - y) * 0.5d0
    else if (y <= 2.35d+58) then
        tmp = t_0
    else if (y <= 1.9d+147) then
        tmp = 1.0d0
    else if (y <= 1.2d+177) then
        tmp = (-1.0d0) + (y / x)
    else
        tmp = 1.0d0
    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 <= -3.1e+57) {
		tmp = 1.0;
	} else if (y <= 1.6e-150) {
		tmp = t_0;
	} else if (y <= 1.9e-81) {
		tmp = (x - y) * 0.5;
	} else if (y <= 2.35e+58) {
		tmp = t_0;
	} else if (y <= 1.9e+147) {
		tmp = 1.0;
	} else if (y <= 1.2e+177) {
		tmp = -1.0 + (y / x);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -3.1e+57:
		tmp = 1.0
	elif y <= 1.6e-150:
		tmp = t_0
	elif y <= 1.9e-81:
		tmp = (x - y) * 0.5
	elif y <= 2.35e+58:
		tmp = t_0
	elif y <= 1.9e+147:
		tmp = 1.0
	elif y <= 1.2e+177:
		tmp = -1.0 + (y / x)
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -3.1e+57)
		tmp = 1.0;
	elseif (y <= 1.6e-150)
		tmp = t_0;
	elseif (y <= 1.9e-81)
		tmp = Float64(Float64(x - y) * 0.5);
	elseif (y <= 2.35e+58)
		tmp = t_0;
	elseif (y <= 1.9e+147)
		tmp = 1.0;
	elseif (y <= 1.2e+177)
		tmp = Float64(-1.0 + Float64(y / x));
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -3.1e+57)
		tmp = 1.0;
	elseif (y <= 1.6e-150)
		tmp = t_0;
	elseif (y <= 1.9e-81)
		tmp = (x - y) * 0.5;
	elseif (y <= 2.35e+58)
		tmp = t_0;
	elseif (y <= 1.9e+147)
		tmp = 1.0;
	elseif (y <= 1.2e+177)
		tmp = -1.0 + (y / x);
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.1e+57], 1.0, If[LessEqual[y, 1.6e-150], t$95$0, If[LessEqual[y, 1.9e-81], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 2.35e+58], t$95$0, If[LessEqual[y, 1.9e+147], 1.0, If[LessEqual[y, 1.2e+177], N[(-1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision], 1.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 1.6 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 2.35 \cdot 10^{+58}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.9 \cdot 10^{+147}:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.10000000000000013e57 or 2.34999999999999986e58 < y < 1.89999999999999985e147 or 1.2e177 < y

    1. Initial program 100.0%

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

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

    if -3.10000000000000013e57 < y < 1.5999999999999999e-150 or 1.8999999999999999e-81 < y < 2.34999999999999986e58

    1. Initial program 99.9%

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

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

    if 1.5999999999999999e-150 < y < 1.8999999999999999e-81

    1. Initial program 100.0%

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

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

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

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

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

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

    if 1.89999999999999985e147 < y < 1.2e177

    1. Initial program 100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{+57}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-150}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-81}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{+58}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+147}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+177}:\\ \;\;\;\;-1 + \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{-16}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{-81}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+58}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{2 - x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -1.15e-16)
     (/ y (+ y -2.0))
     (if (<= y 4.9e-150)
       t_0
       (if (<= y 2.05e-81)
         (* (- x y) 0.5)
         (if (<= y 1.3e+58) t_0 (+ 1.0 (/ (- 2.0 x) y))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -1.15e-16) {
		tmp = y / (y + -2.0);
	} else if (y <= 4.9e-150) {
		tmp = t_0;
	} else if (y <= 2.05e-81) {
		tmp = (x - y) * 0.5;
	} else if (y <= 1.3e+58) {
		tmp = t_0;
	} else {
		tmp = 1.0 + ((2.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 <= (-1.15d-16)) then
        tmp = y / (y + (-2.0d0))
    else if (y <= 4.9d-150) then
        tmp = t_0
    else if (y <= 2.05d-81) then
        tmp = (x - y) * 0.5d0
    else if (y <= 1.3d+58) then
        tmp = t_0
    else
        tmp = 1.0d0 + ((2.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 <= -1.15e-16) {
		tmp = y / (y + -2.0);
	} else if (y <= 4.9e-150) {
		tmp = t_0;
	} else if (y <= 2.05e-81) {
		tmp = (x - y) * 0.5;
	} else if (y <= 1.3e+58) {
		tmp = t_0;
	} else {
		tmp = 1.0 + ((2.0 - x) / y);
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -1.15e-16:
		tmp = y / (y + -2.0)
	elif y <= 4.9e-150:
		tmp = t_0
	elif y <= 2.05e-81:
		tmp = (x - y) * 0.5
	elif y <= 1.3e+58:
		tmp = t_0
	else:
		tmp = 1.0 + ((2.0 - x) / y)
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -1.15e-16)
		tmp = Float64(y / Float64(y + -2.0));
	elseif (y <= 4.9e-150)
		tmp = t_0;
	elseif (y <= 2.05e-81)
		tmp = Float64(Float64(x - y) * 0.5);
	elseif (y <= 1.3e+58)
		tmp = t_0;
	else
		tmp = Float64(1.0 + Float64(Float64(2.0 - x) / y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -1.15e-16)
		tmp = y / (y + -2.0);
	elseif (y <= 4.9e-150)
		tmp = t_0;
	elseif (y <= 2.05e-81)
		tmp = (x - y) * 0.5;
	elseif (y <= 1.3e+58)
		tmp = t_0;
	else
		tmp = 1.0 + ((2.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, -1.15e-16], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.9e-150], t$95$0, If[LessEqual[y, 2.05e-81], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 1.3e+58], t$95$0, N[(1.0 + N[(N[(2.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 1.3 \cdot 10^{+58}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.15e-16

    1. Initial program 99.9%

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{2 - y}\right)} - 1 \]
      4. sqrt-unprod31.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{2 - y}\right)} - 1 \]
      5. sqr-neg31.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{y \cdot y}}}{2 - y}\right)} - 1 \]
      6. sqrt-unprod0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{2 - y}\right)} - 1 \]
      7. add-sqr-sqrt19.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{y}}{2 - y}\right)} - 1 \]
      8. frac-2neg19.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{-y}{-\left(2 - y\right)}}\right)} - 1 \]
      9. add-sqr-sqrt12.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{-\left(2 - y\right)}\right)} - 1 \]
      10. sqrt-unprod12.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{-\left(2 - y\right)}\right)} - 1 \]
      11. sqr-neg12.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{y \cdot y}}}{-\left(2 - y\right)}\right)} - 1 \]
      12. sqrt-unprod0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{-\left(2 - y\right)}\right)} - 1 \]
      13. add-sqr-sqrt76.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{y}}{-\left(2 - y\right)}\right)} - 1 \]
      14. sub-neg76.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{y}{-\color{blue}{\left(2 + \left(-y\right)\right)}}\right)} - 1 \]
      15. distribute-neg-in76.6%

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{y}{\color{blue}{-2} + \left(-\left(-y\right)\right)}\right)} - 1 \]
      17. remove-double-neg76.6%

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

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

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

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

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

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

    if -1.15e-16 < y < 4.8999999999999995e-150 or 2.04999999999999992e-81 < y < 1.29999999999999994e58

    1. Initial program 100.0%

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

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

    if 4.8999999999999995e-150 < y < 2.04999999999999992e-81

    1. Initial program 100.0%

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

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

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

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

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

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

    if 1.29999999999999994e58 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.15 \cdot 10^{-16}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{-81}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+58}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{2 - x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -3.1 \cdot 10^{-16}:\\ \;\;\;\;\frac{1}{\frac{y + -2}{y}}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-81}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+58}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{2 - x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -3.1e-16)
     (/ 1.0 (/ (+ y -2.0) y))
     (if (<= y 4.9e-150)
       t_0
       (if (<= y 2.1e-81)
         (* (- x y) 0.5)
         (if (<= y 5.8e+58) t_0 (+ 1.0 (/ (- 2.0 x) y))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -3.1e-16) {
		tmp = 1.0 / ((y + -2.0) / y);
	} else if (y <= 4.9e-150) {
		tmp = t_0;
	} else if (y <= 2.1e-81) {
		tmp = (x - y) * 0.5;
	} else if (y <= 5.8e+58) {
		tmp = t_0;
	} else {
		tmp = 1.0 + ((2.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 <= (-3.1d-16)) then
        tmp = 1.0d0 / ((y + (-2.0d0)) / y)
    else if (y <= 4.9d-150) then
        tmp = t_0
    else if (y <= 2.1d-81) then
        tmp = (x - y) * 0.5d0
    else if (y <= 5.8d+58) then
        tmp = t_0
    else
        tmp = 1.0d0 + ((2.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 <= -3.1e-16) {
		tmp = 1.0 / ((y + -2.0) / y);
	} else if (y <= 4.9e-150) {
		tmp = t_0;
	} else if (y <= 2.1e-81) {
		tmp = (x - y) * 0.5;
	} else if (y <= 5.8e+58) {
		tmp = t_0;
	} else {
		tmp = 1.0 + ((2.0 - x) / y);
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -3.1e-16:
		tmp = 1.0 / ((y + -2.0) / y)
	elif y <= 4.9e-150:
		tmp = t_0
	elif y <= 2.1e-81:
		tmp = (x - y) * 0.5
	elif y <= 5.8e+58:
		tmp = t_0
	else:
		tmp = 1.0 + ((2.0 - x) / y)
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -3.1e-16)
		tmp = Float64(1.0 / Float64(Float64(y + -2.0) / y));
	elseif (y <= 4.9e-150)
		tmp = t_0;
	elseif (y <= 2.1e-81)
		tmp = Float64(Float64(x - y) * 0.5);
	elseif (y <= 5.8e+58)
		tmp = t_0;
	else
		tmp = Float64(1.0 + Float64(Float64(2.0 - x) / y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -3.1e-16)
		tmp = 1.0 / ((y + -2.0) / y);
	elseif (y <= 4.9e-150)
		tmp = t_0;
	elseif (y <= 2.1e-81)
		tmp = (x - y) * 0.5;
	elseif (y <= 5.8e+58)
		tmp = t_0;
	else
		tmp = 1.0 + ((2.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, -3.1e-16], N[(1.0 / N[(N[(y + -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.9e-150], t$95$0, If[LessEqual[y, 2.1e-81], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 5.8e+58], t$95$0, N[(1.0 + N[(N[(2.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 5.8 \cdot 10^{+58}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.1000000000000001e-16

    1. Initial program 99.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{2 - y}{-y}}} \]
      2. inv-pow78.7%

        \[\leadsto \color{blue}{{\left(\frac{2 - y}{-y}\right)}^{-1}} \]
      3. frac-2neg78.7%

        \[\leadsto {\color{blue}{\left(\frac{-\left(2 - y\right)}{-\left(-y\right)}\right)}}^{-1} \]
      4. sub-neg78.7%

        \[\leadsto {\left(\frac{-\color{blue}{\left(2 + \left(-y\right)\right)}}{-\left(-y\right)}\right)}^{-1} \]
      5. distribute-neg-in78.7%

        \[\leadsto {\left(\frac{\color{blue}{\left(-2\right) + \left(-\left(-y\right)\right)}}{-\left(-y\right)}\right)}^{-1} \]
      6. metadata-eval78.7%

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

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

        \[\leadsto {\left(\frac{-2 + y}{\color{blue}{y}}\right)}^{-1} \]
    7. Applied egg-rr78.7%

      \[\leadsto \color{blue}{{\left(\frac{-2 + y}{y}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-178.7%

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

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

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

    if -3.1000000000000001e-16 < y < 4.8999999999999995e-150 or 2.0999999999999999e-81 < y < 5.80000000000000004e58

    1. Initial program 100.0%

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

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

    if 4.8999999999999995e-150 < y < 2.0999999999999999e-81

    1. Initial program 100.0%

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

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

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

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

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

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

    if 5.80000000000000004e58 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{-16}:\\ \;\;\;\;\frac{1}{\frac{y + -2}{y}}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-81}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+58}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{2 - x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 73.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -2.8 \cdot 10^{-16}:\\ \;\;\;\;\frac{1}{\frac{-2}{y} - -1}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-81}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{+58}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{2 - x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (- 2.0 x))))
   (if (<= y -2.8e-16)
     (/ 1.0 (- (/ (- 2.0) y) -1.0))
     (if (<= y 4.9e-150)
       t_0
       (if (<= y 2e-81)
         (* (- x y) 0.5)
         (if (<= y 1.65e+58) t_0 (+ 1.0 (/ (- 2.0 x) y))))))))
double code(double x, double y) {
	double t_0 = x / (2.0 - x);
	double tmp;
	if (y <= -2.8e-16) {
		tmp = 1.0 / ((-2.0 / y) - -1.0);
	} else if (y <= 4.9e-150) {
		tmp = t_0;
	} else if (y <= 2e-81) {
		tmp = (x - y) * 0.5;
	} else if (y <= 1.65e+58) {
		tmp = t_0;
	} else {
		tmp = 1.0 + ((2.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 <= (-2.8d-16)) then
        tmp = 1.0d0 / ((-2.0d0 / y) - (-1.0d0))
    else if (y <= 4.9d-150) then
        tmp = t_0
    else if (y <= 2d-81) then
        tmp = (x - y) * 0.5d0
    else if (y <= 1.65d+58) then
        tmp = t_0
    else
        tmp = 1.0d0 + ((2.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 <= -2.8e-16) {
		tmp = 1.0 / ((-2.0 / y) - -1.0);
	} else if (y <= 4.9e-150) {
		tmp = t_0;
	} else if (y <= 2e-81) {
		tmp = (x - y) * 0.5;
	} else if (y <= 1.65e+58) {
		tmp = t_0;
	} else {
		tmp = 1.0 + ((2.0 - x) / y);
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (2.0 - x)
	tmp = 0
	if y <= -2.8e-16:
		tmp = 1.0 / ((-2.0 / y) - -1.0)
	elif y <= 4.9e-150:
		tmp = t_0
	elif y <= 2e-81:
		tmp = (x - y) * 0.5
	elif y <= 1.65e+58:
		tmp = t_0
	else:
		tmp = 1.0 + ((2.0 - x) / y)
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(2.0 - x))
	tmp = 0.0
	if (y <= -2.8e-16)
		tmp = Float64(1.0 / Float64(Float64(Float64(-2.0) / y) - -1.0));
	elseif (y <= 4.9e-150)
		tmp = t_0;
	elseif (y <= 2e-81)
		tmp = Float64(Float64(x - y) * 0.5);
	elseif (y <= 1.65e+58)
		tmp = t_0;
	else
		tmp = Float64(1.0 + Float64(Float64(2.0 - x) / y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (2.0 - x);
	tmp = 0.0;
	if (y <= -2.8e-16)
		tmp = 1.0 / ((-2.0 / y) - -1.0);
	elseif (y <= 4.9e-150)
		tmp = t_0;
	elseif (y <= 2e-81)
		tmp = (x - y) * 0.5;
	elseif (y <= 1.65e+58)
		tmp = t_0;
	else
		tmp = 1.0 + ((2.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, -2.8e-16], N[(1.0 / N[(N[((-2.0) / y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.9e-150], t$95$0, If[LessEqual[y, 2e-81], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[y, 1.65e+58], t$95$0, N[(1.0 + N[(N[(2.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 1.65 \cdot 10^{+58}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.8000000000000001e-16

    1. Initial program 99.9%

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{2 - \left(x + y\right)}{x - y}\right)}^{-1}} \]
    5. Step-by-step derivation
      1. unpow-199.9%

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

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

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

        \[\leadsto \frac{1}{\color{blue}{-\frac{2 - y}{y}}} \]
      2. div-sub78.8%

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

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

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

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

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

        \[\leadsto \frac{1}{-\left(\frac{\color{blue}{2}}{y} + \left(-\frac{y}{y}\right)\right)} \]
      8. *-inverses78.8%

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

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

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

    if -2.8000000000000001e-16 < y < 4.8999999999999995e-150 or 1.9999999999999999e-81 < y < 1.64999999999999991e58

    1. Initial program 100.0%

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

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

    if 4.8999999999999995e-150 < y < 1.9999999999999999e-81

    1. Initial program 100.0%

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

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

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

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

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

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

    if 1.64999999999999991e58 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{-16}:\\ \;\;\;\;\frac{1}{\frac{-2}{y} - -1}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-150}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-81}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{+58}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{2 - x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 74.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y + -2}\\ \mathbf{if}\;x \leq -4.1 \cdot 10^{-54}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{-197}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-185}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{+29}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{-x}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ y -2.0))))
   (if (<= x -4.1e-54)
     (/ x (- 2.0 x))
     (if (<= x 8.6e-197)
       t_0
       (if (<= x 3.9e-185)
         (* (- x y) 0.5)
         (if (<= x 4.2e+29) t_0 (/ (- x y) (- x))))))))
double code(double x, double y) {
	double t_0 = y / (y + -2.0);
	double tmp;
	if (x <= -4.1e-54) {
		tmp = x / (2.0 - x);
	} else if (x <= 8.6e-197) {
		tmp = t_0;
	} else if (x <= 3.9e-185) {
		tmp = (x - y) * 0.5;
	} else if (x <= 4.2e+29) {
		tmp = t_0;
	} else {
		tmp = (x - y) / -x;
	}
	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 / (y + (-2.0d0))
    if (x <= (-4.1d-54)) then
        tmp = x / (2.0d0 - x)
    else if (x <= 8.6d-197) then
        tmp = t_0
    else if (x <= 3.9d-185) then
        tmp = (x - y) * 0.5d0
    else if (x <= 4.2d+29) then
        tmp = t_0
    else
        tmp = (x - y) / -x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y / (y + -2.0);
	double tmp;
	if (x <= -4.1e-54) {
		tmp = x / (2.0 - x);
	} else if (x <= 8.6e-197) {
		tmp = t_0;
	} else if (x <= 3.9e-185) {
		tmp = (x - y) * 0.5;
	} else if (x <= 4.2e+29) {
		tmp = t_0;
	} else {
		tmp = (x - y) / -x;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (y + -2.0)
	tmp = 0
	if x <= -4.1e-54:
		tmp = x / (2.0 - x)
	elif x <= 8.6e-197:
		tmp = t_0
	elif x <= 3.9e-185:
		tmp = (x - y) * 0.5
	elif x <= 4.2e+29:
		tmp = t_0
	else:
		tmp = (x - y) / -x
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(y + -2.0))
	tmp = 0.0
	if (x <= -4.1e-54)
		tmp = Float64(x / Float64(2.0 - x));
	elseif (x <= 8.6e-197)
		tmp = t_0;
	elseif (x <= 3.9e-185)
		tmp = Float64(Float64(x - y) * 0.5);
	elseif (x <= 4.2e+29)
		tmp = t_0;
	else
		tmp = Float64(Float64(x - y) / Float64(-x));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (y + -2.0);
	tmp = 0.0;
	if (x <= -4.1e-54)
		tmp = x / (2.0 - x);
	elseif (x <= 8.6e-197)
		tmp = t_0;
	elseif (x <= 3.9e-185)
		tmp = (x - y) * 0.5;
	elseif (x <= 4.2e+29)
		tmp = t_0;
	else
		tmp = (x - y) / -x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.1e-54], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.6e-197], t$95$0, If[LessEqual[x, 3.9e-185], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 4.2e+29], t$95$0, N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 8.6 \cdot 10^{-197}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 4.2 \cdot 10^{+29}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.1000000000000001e-54

    1. Initial program 100.0%

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

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

    if -4.1000000000000001e-54 < x < 8.6000000000000001e-197 or 3.8999999999999999e-185 < x < 4.2000000000000003e29

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{2 - y}\right)} - 1 \]
      5. sqr-neg17.6%

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{2 - y}\right)} - 1 \]
      7. add-sqr-sqrt2.6%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{-y}{-\left(2 - y\right)}}\right)} - 1 \]
      9. add-sqr-sqrt1.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{-\left(2 - y\right)}\right)} - 1 \]
      10. sqrt-unprod13.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{-\left(2 - y\right)}\right)} - 1 \]
      11. sqr-neg13.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{y \cdot y}}}{-\left(2 - y\right)}\right)} - 1 \]
      12. sqrt-unprod27.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{-\left(2 - y\right)}\right)} - 1 \]
      13. add-sqr-sqrt63.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{y}}{-\left(2 - y\right)}\right)} - 1 \]
      14. sub-neg63.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{y}{-\color{blue}{\left(2 + \left(-y\right)\right)}}\right)} - 1 \]
      15. distribute-neg-in63.1%

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{y}{\color{blue}{-2} + \left(-\left(-y\right)\right)}\right)} - 1 \]
      17. remove-double-neg63.1%

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

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

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

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

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

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

    if 8.6000000000000001e-197 < x < 3.8999999999999999e-185

    1. Initial program 100.0%

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

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

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

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

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

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

    if 4.2000000000000003e29 < x

    1. Initial program 99.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-1}{x}} \cdot \left(x - y\right) \]
    6. Step-by-step derivation
      1. expm1-log1p-u76.5%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\left(x - y\right) \cdot \frac{\color{blue}{1}}{-x}\right)} - 1 \]
      6. un-div-inv76.6%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x - y}{-x}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def76.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.1 \cdot 10^{-54}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{-197}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-185}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{+29}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{-x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 63.1% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq 2.5 \cdot 10^{-277}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 8 \cdot 10^{+25}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.4e15 or 8.00000000000000072e25 < x

    1. Initial program 100.0%

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

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

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

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

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

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

    if -4.4e15 < x < 2.5e-277 or 1.60000000000000002e-118 < x < 8.00000000000000072e25

    1. Initial program 99.9%

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

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

    if 2.5e-277 < x < 1.60000000000000002e-118

    1. Initial program 100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{+15}:\\ \;\;\;\;-1 + \frac{y}{x}\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-277}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-118}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+25}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1 + \frac{y}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 74.3% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq 8.6 \cdot 10^{-197}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 6 \cdot 10^{+29}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -7.99999999999999996e-55

    1. Initial program 100.0%

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

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

    if -7.99999999999999996e-55 < x < 8.6000000000000001e-197 or 3.8999999999999999e-185 < x < 5.9999999999999998e29

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{2 - y}\right)} - 1 \]
      5. sqr-neg17.6%

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{2 - y}\right)} - 1 \]
      7. add-sqr-sqrt2.6%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{-y}{-\left(2 - y\right)}}\right)} - 1 \]
      9. add-sqr-sqrt1.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{-\left(2 - y\right)}\right)} - 1 \]
      10. sqrt-unprod13.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{-\left(2 - y\right)}\right)} - 1 \]
      11. sqr-neg13.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{y \cdot y}}}{-\left(2 - y\right)}\right)} - 1 \]
      12. sqrt-unprod27.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{-\left(2 - y\right)}\right)} - 1 \]
      13. add-sqr-sqrt63.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{y}}{-\left(2 - y\right)}\right)} - 1 \]
      14. sub-neg63.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{y}{-\color{blue}{\left(2 + \left(-y\right)\right)}}\right)} - 1 \]
      15. distribute-neg-in63.1%

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{y}{\color{blue}{-2} + \left(-\left(-y\right)\right)}\right)} - 1 \]
      17. remove-double-neg63.1%

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

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

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

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

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

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

    if 8.6000000000000001e-197 < x < 3.8999999999999999e-185

    1. Initial program 100.0%

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

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

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

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

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

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

    if 5.9999999999999998e29 < x

    1. Initial program 99.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{-55}:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{-197}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-185}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+29}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{else}:\\ \;\;\;\;-1 + \frac{y}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 61.7% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq 8 \cdot 10^{-273}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 4.6 \cdot 10^{-173}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 1.85 \cdot 10^{+30}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.1e15 or 1.85000000000000008e30 < x

    1. Initial program 100.0%

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

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

    if -3.1e15 < x < 8.000000000000001e-273 or 4.59999999999999976e-173 < x < 1.85000000000000008e30

    1. Initial program 99.9%

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

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

    if 8.000000000000001e-273 < x < 4.59999999999999976e-173

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{2 - y}} \]
    5. Simplified79.0%

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

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    8. Simplified49.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.1 \cdot 10^{+15}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-273}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-173}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{+30}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 62.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq 7 \cdot 10^{-274}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 2.5 \cdot 10^{+24}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.4e15 or 2.50000000000000023e24 < x

    1. Initial program 100.0%

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

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

    if -3.4e15 < x < 6.99999999999999963e-274 or 9.49999999999999931e-118 < x < 2.50000000000000023e24

    1. Initial program 99.9%

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

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

    if 6.99999999999999963e-274 < x < 9.49999999999999931e-118

    1. Initial program 100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{+15}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-274}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-118}:\\ \;\;\;\;\left(x - y\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{+24}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 87.0% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

    if -33 < x < 2.15e30

    1. Initial program 99.9%

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

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

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

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

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

    if 2.15e30 < x

    1. Initial program 99.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-1}{x}} \cdot \left(x - y\right) \]
    6. Step-by-step derivation
      1. expm1-log1p-u76.5%

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\left(x - y\right) \cdot \frac{\color{blue}{1}}{-x}\right)} - 1 \]
      6. un-div-inv76.6%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x - y}{-x}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def76.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -33:\\ \;\;\;\;\frac{x}{2 - x}\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{+30}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{1}{2 - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{-x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 62.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 3.8 \cdot 10^{+31}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.4e14 or 3.8000000000000001e31 < x

    1. Initial program 100.0%

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

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

    if -9.4e14 < x < 3.8000000000000001e31

    1. Initial program 99.9%

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

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

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

Alternative 13: 38.2% accurate, 9.0× speedup?

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

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

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

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

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

Developer target: 100.0% accurate, 0.6× speedup?

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

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

Reproduce

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