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

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

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 71.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y - 2}\\ \mathbf{if}\;x \leq -1.8 \cdot 10^{+124}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-80}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-21}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+52}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (- y 2.0))))
   (if (<= x -1.8e+124)
     -1.0
     (if (<= x 4.7e-80)
       t_0
       (if (<= x 3.1e-21) (* x 0.5) (if (<= x 6.2e+52) t_0 -1.0))))))
double code(double x, double y) {
	double t_0 = y / (y - 2.0);
	double tmp;
	if (x <= -1.8e+124) {
		tmp = -1.0;
	} else if (x <= 4.7e-80) {
		tmp = t_0;
	} else if (x <= 3.1e-21) {
		tmp = x * 0.5;
	} else if (x <= 6.2e+52) {
		tmp = t_0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y / (y - 2.0d0)
    if (x <= (-1.8d+124)) then
        tmp = -1.0d0
    else if (x <= 4.7d-80) then
        tmp = t_0
    else if (x <= 3.1d-21) then
        tmp = x * 0.5d0
    else if (x <= 6.2d+52) then
        tmp = t_0
    else
        tmp = -1.0d0
    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 <= -1.8e+124) {
		tmp = -1.0;
	} else if (x <= 4.7e-80) {
		tmp = t_0;
	} else if (x <= 3.1e-21) {
		tmp = x * 0.5;
	} else if (x <= 6.2e+52) {
		tmp = t_0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (y - 2.0)
	tmp = 0
	if x <= -1.8e+124:
		tmp = -1.0
	elif x <= 4.7e-80:
		tmp = t_0
	elif x <= 3.1e-21:
		tmp = x * 0.5
	elif x <= 6.2e+52:
		tmp = t_0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(y - 2.0))
	tmp = 0.0
	if (x <= -1.8e+124)
		tmp = -1.0;
	elseif (x <= 4.7e-80)
		tmp = t_0;
	elseif (x <= 3.1e-21)
		tmp = Float64(x * 0.5);
	elseif (x <= 6.2e+52)
		tmp = t_0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (y - 2.0);
	tmp = 0.0;
	if (x <= -1.8e+124)
		tmp = -1.0;
	elseif (x <= 4.7e-80)
		tmp = t_0;
	elseif (x <= 3.1e-21)
		tmp = x * 0.5;
	elseif (x <= 6.2e+52)
		tmp = t_0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.8e+124], -1.0, If[LessEqual[x, 4.7e-80], t$95$0, If[LessEqual[x, 3.1e-21], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 6.2e+52], t$95$0, -1.0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 4.7 \cdot 10^{-80}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 6.2 \cdot 10^{+52}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.79999999999999993e124 or 6.2e52 < x

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} - \frac{y + x}{-1}} \]
      12. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity99.9%

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

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

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

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

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

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

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

    if -1.79999999999999993e124 < x < 4.69999999999999973e-80 or 3.0999999999999998e-21 < x < 6.2e52

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity100.0%

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

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

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

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

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

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

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

    if 4.69999999999999973e-80 < x < 3.0999999999999998e-21

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} - \frac{y + x}{-1}} \]
      12. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity99.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{x - 2}} \]
      2. mul-1-neg70.5%

        \[\leadsto \frac{\color{blue}{-x}}{x - 2} \]
      3. sub-neg70.5%

        \[\leadsto \frac{-x}{\color{blue}{x + \left(-2\right)}} \]
      4. metadata-eval70.5%

        \[\leadsto \frac{-x}{x + \color{blue}{-2}} \]
    6. Simplified70.5%

      \[\leadsto \color{blue}{\frac{-x}{x + -2}} \]
    7. Taylor expanded in x around 0 70.5%

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    9. Simplified70.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{+124}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-80}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-21}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+52}:\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 3: 74.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \cdot 10^{-11} \lor \neg \left(y \leq 1.06 \cdot 10^{-49}\right):\\
\;\;\;\;\frac{y}{y - 2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.4499999999999999e-11 or 1.06000000000000002e-49 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} - \frac{y + x}{-1}} \]
      12. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity99.9%

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

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

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

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

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

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

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

    if -2.4499999999999999e-11 < y < 1.06000000000000002e-49

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{x - 2}} \]
      2. mul-1-neg83.4%

        \[\leadsto \frac{\color{blue}{-x}}{x - 2} \]
      3. sub-neg83.4%

        \[\leadsto \frac{-x}{\color{blue}{x + \left(-2\right)}} \]
      4. metadata-eval83.4%

        \[\leadsto \frac{-x}{x + \color{blue}{-2}} \]
    6. Simplified83.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.45 \cdot 10^{-11} \lor \neg \left(y \leq 1.06 \cdot 10^{-49}\right):\\ \;\;\;\;\frac{y}{y - 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{x + -2}\\ \end{array} \]

Alternative 4: 74.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{1 - \frac{2}{y}}\\

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} - \frac{y + x}{-1}} \]
      12. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity99.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y + -2}{y}}} \]
      2. metadata-eval84.6%

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

        \[\leadsto \frac{1}{\frac{\color{blue}{y - 2}}{y}} \]
      4. div-sub84.6%

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

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

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

    if -8.79999999999999966e-12 < y < 2.79999999999999997e-49

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{x - 2}} \]
      2. mul-1-neg83.4%

        \[\leadsto \frac{\color{blue}{-x}}{x - 2} \]
      3. sub-neg83.4%

        \[\leadsto \frac{-x}{\color{blue}{x + \left(-2\right)}} \]
      4. metadata-eval83.4%

        \[\leadsto \frac{-x}{x + \color{blue}{-2}} \]
    6. Simplified83.4%

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

    if 2.79999999999999997e-49 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} - \frac{y + x}{-1}} \]
      12. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.8 \cdot 10^{-12}:\\ \;\;\;\;\frac{1}{1 - \frac{2}{y}}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-49}:\\ \;\;\;\;\frac{-x}{x + -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - 2}\\ \end{array} \]

Alternative 5: 60.1% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq 2 \cdot 10^{-129}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 5 \cdot 10^{+17}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.79999999999999993e124 or 5e17 < x

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} - \frac{y + x}{-1}} \]
      12. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity99.9%

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

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

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

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

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

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

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

    if -1.79999999999999993e124 < x < 1.9999999999999999e-129 or 4.49999999999999968e-21 < x < 5e17

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity100.0%

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

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

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

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

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

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

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

    if 1.9999999999999999e-129 < x < 4.49999999999999968e-21

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} - \frac{y + x}{-1}} \]
      12. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity99.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{x - 2}} \]
      2. mul-1-neg63.5%

        \[\leadsto \frac{\color{blue}{-x}}{x - 2} \]
      3. sub-neg63.5%

        \[\leadsto \frac{-x}{\color{blue}{x + \left(-2\right)}} \]
      4. metadata-eval63.5%

        \[\leadsto \frac{-x}{x + \color{blue}{-2}} \]
    6. Simplified63.5%

      \[\leadsto \color{blue}{\frac{-x}{x + -2}} \]
    7. Taylor expanded in x around 0 63.5%

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    9. Simplified63.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{+124}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-129}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-21}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+17}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 6: 60.3% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.2000000000000002e130 or 2.00000000000000018e25 < x

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval99.9%

        \[\leadsto \frac{y - x}{\color{blue}{-2} - \frac{y + x}{-1}} \]
      12. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity99.9%

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

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

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

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

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

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

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

    if -7.2000000000000002e130 < x < 2.00000000000000018e25

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
      11. metadata-eval100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
      19. /-rgt-identity100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{+130}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+25}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 7: 37.4% accurate, 9.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{y - x}{\color{blue}{\frac{2}{-1} - \frac{y + x}{-1}}} \]
    11. metadata-eval100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{y - x}{\left(-2\right) + \frac{y + x}{\color{blue}{1}}} \]
    19. /-rgt-identity100.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification33.0%

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