Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, A

Percentage Accurate: 100.0% → 100.0%
Time: 3.4s
Alternatives: 7
Speedup: 1.0×

Specification

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

\\
\left(x + y\right) - x \cdot y
\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} \\ \left(x + y\right) - x \cdot y \end{array} \]
(FPCore (x y) :precision binary64 (- (+ x y) (* x y)))
double code(double x, double y) {
	return (x + y) - (x * y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x + y) - (x * y)
end function
public static double code(double x, double y) {
	return (x + y) - (x * y);
}
def code(x, y):
	return (x + y) - (x * y)
function code(x, y)
	return Float64(Float64(x + y) - Float64(x * y))
end
function tmp = code(x, y)
	tmp = (x + y) - (x * y);
end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 100.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(y, 1 - x, x\right) \end{array} \]
(FPCore (x y) :precision binary64 (fma y (- 1.0 x) x))
double code(double x, double y) {
	return fma(y, (1.0 - x), x);
}
function code(x, y)
	return fma(y, Float64(1.0 - x), x)
end
code[x_, y_] := N[(y * N[(1.0 - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(y, 1 - x, x\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(x + y\right) - x \cdot y \]
  2. Step-by-step derivation
    1. associate--l+100.0%

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

      \[\leadsto \color{blue}{\left(y - x \cdot y\right) + x} \]
    3. *-lft-identity100.0%

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

      \[\leadsto \left(\color{blue}{\left(--1\right)} \cdot y - x \cdot y\right) + x \]
    5. distribute-rgt-out--100.0%

      \[\leadsto \color{blue}{y \cdot \left(\left(--1\right) - x\right)} + x \]
    6. fma-define100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \left(--1\right) - x, x\right)} \]
    7. metadata-eval100.0%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, 1 - x, x\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 59.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(-y\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{-166}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-116}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-73}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+249}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (- y))))
   (if (<= y -1.0)
     t_0
     (if (<= y 5.1e-166)
       x
       (if (<= y 7.6e-116)
         y
         (if (<= y 1.1e-73) x (if (<= y 7e+249) y t_0)))))))
double code(double x, double y) {
	double t_0 = x * -y;
	double tmp;
	if (y <= -1.0) {
		tmp = t_0;
	} else if (y <= 5.1e-166) {
		tmp = x;
	} else if (y <= 7.6e-116) {
		tmp = y;
	} else if (y <= 1.1e-73) {
		tmp = x;
	} else if (y <= 7e+249) {
		tmp = y;
	} 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 = x * -y
    if (y <= (-1.0d0)) then
        tmp = t_0
    else if (y <= 5.1d-166) then
        tmp = x
    else if (y <= 7.6d-116) then
        tmp = y
    else if (y <= 1.1d-73) then
        tmp = x
    else if (y <= 7d+249) then
        tmp = y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * -y;
	double tmp;
	if (y <= -1.0) {
		tmp = t_0;
	} else if (y <= 5.1e-166) {
		tmp = x;
	} else if (y <= 7.6e-116) {
		tmp = y;
	} else if (y <= 1.1e-73) {
		tmp = x;
	} else if (y <= 7e+249) {
		tmp = y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * -y
	tmp = 0
	if y <= -1.0:
		tmp = t_0
	elif y <= 5.1e-166:
		tmp = x
	elif y <= 7.6e-116:
		tmp = y
	elif y <= 1.1e-73:
		tmp = x
	elif y <= 7e+249:
		tmp = y
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(-y))
	tmp = 0.0
	if (y <= -1.0)
		tmp = t_0;
	elseif (y <= 5.1e-166)
		tmp = x;
	elseif (y <= 7.6e-116)
		tmp = y;
	elseif (y <= 1.1e-73)
		tmp = x;
	elseif (y <= 7e+249)
		tmp = y;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * -y;
	tmp = 0.0;
	if (y <= -1.0)
		tmp = t_0;
	elseif (y <= 5.1e-166)
		tmp = x;
	elseif (y <= 7.6e-116)
		tmp = y;
	elseif (y <= 1.1e-73)
		tmp = x;
	elseif (y <= 7e+249)
		tmp = y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * (-y)), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 5.1e-166], x, If[LessEqual[y, 7.6e-116], y, If[LessEqual[y, 1.1e-73], x, If[LessEqual[y, 7e+249], y, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(-y\right)\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 5.1 \cdot 10^{-166}:\\
\;\;\;\;x\\

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

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-73}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 7 \cdot 10^{+249}:\\
\;\;\;\;y\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1 or 7.00000000000000024e249 < y

    1. Initial program 99.9%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 99.9%

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

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot y\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg53.0%

        \[\leadsto \color{blue}{-x \cdot y} \]
      2. *-commutative53.0%

        \[\leadsto -\color{blue}{y \cdot x} \]
      3. distribute-rgt-neg-in53.0%

        \[\leadsto \color{blue}{y \cdot \left(-x\right)} \]
    6. Simplified53.0%

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

    if -1 < y < 5.1000000000000002e-166 or 7.6000000000000003e-116 < y < 1.1e-73

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 80.2%

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

    if 5.1000000000000002e-166 < y < 7.6000000000000003e-116 or 1.1e-73 < y < 7.00000000000000024e249

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 49.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{-166}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-116}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-73}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+249}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 72.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(1 - y\right)\\ \mathbf{if}\;x \leq -4.4 \cdot 10^{-63}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-117}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-176}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (- 1.0 y))))
   (if (<= x -4.4e-63)
     t_0
     (if (<= x -1.35e-117)
       y
       (if (<= x -9e-176) t_0 (if (<= x 1.0) y (* x (- y))))))))
double code(double x, double y) {
	double t_0 = x * (1.0 - y);
	double tmp;
	if (x <= -4.4e-63) {
		tmp = t_0;
	} else if (x <= -1.35e-117) {
		tmp = y;
	} else if (x <= -9e-176) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = y;
	} else {
		tmp = 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 * (1.0d0 - y)
    if (x <= (-4.4d-63)) then
        tmp = t_0
    else if (x <= (-1.35d-117)) then
        tmp = y
    else if (x <= (-9d-176)) then
        tmp = t_0
    else if (x <= 1.0d0) then
        tmp = y
    else
        tmp = x * -y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * (1.0 - y);
	double tmp;
	if (x <= -4.4e-63) {
		tmp = t_0;
	} else if (x <= -1.35e-117) {
		tmp = y;
	} else if (x <= -9e-176) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = y;
	} else {
		tmp = x * -y;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * (1.0 - y)
	tmp = 0
	if x <= -4.4e-63:
		tmp = t_0
	elif x <= -1.35e-117:
		tmp = y
	elif x <= -9e-176:
		tmp = t_0
	elif x <= 1.0:
		tmp = y
	else:
		tmp = x * -y
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(1.0 - y))
	tmp = 0.0
	if (x <= -4.4e-63)
		tmp = t_0;
	elseif (x <= -1.35e-117)
		tmp = y;
	elseif (x <= -9e-176)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = y;
	else
		tmp = Float64(x * Float64(-y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * (1.0 - y);
	tmp = 0.0;
	if (x <= -4.4e-63)
		tmp = t_0;
	elseif (x <= -1.35e-117)
		tmp = y;
	elseif (x <= -9e-176)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = y;
	else
		tmp = x * -y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.4e-63], t$95$0, If[LessEqual[x, -1.35e-117], y, If[LessEqual[x, -9e-176], t$95$0, If[LessEqual[x, 1.0], y, N[(x * (-y)), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(1 - y\right)\\
\mathbf{if}\;x \leq -4.4 \cdot 10^{-63}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.35 \cdot 10^{-117}:\\
\;\;\;\;y\\

\mathbf{elif}\;x \leq -9 \cdot 10^{-176}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.3999999999999999e-63 or -1.35000000000000001e-117 < x < -9e-176

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 87.2%

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

    if -4.3999999999999999e-63 < x < -1.35000000000000001e-117 or -9e-176 < x < 1

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 75.7%

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

    if 1 < x

    1. Initial program 99.9%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 48.0%

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

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

        \[\leadsto \color{blue}{-x \cdot y} \]
      2. *-commutative45.6%

        \[\leadsto -\color{blue}{y \cdot x} \]
      3. distribute-rgt-neg-in45.6%

        \[\leadsto \color{blue}{y \cdot \left(-x\right)} \]
    6. Simplified45.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{-63}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-117}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-176}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 72.2% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{-166}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\

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

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

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


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

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 69.6%

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

    if 5.1000000000000002e-166 < y < 7.6000000000000003e-116

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 55.7%

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

    if 7.6000000000000003e-116 < y < 3.6000000000000002e-74

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 100.0%

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

    if 3.6000000000000002e-74 < y

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 85.8%

      \[\leadsto \color{blue}{y \cdot \left(1 - x\right)} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 5: 100.0% accurate, 1.0× speedup?

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

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

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

    \[\leadsto \left(y + x\right) - y \cdot x \]
  4. Add Preprocessing

Alternative 6: 47.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{-166}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 5.1000000000000002e-166

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 49.9%

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

    if 5.1000000000000002e-166 < y

    1. Initial program 100.0%

      \[\left(x + y\right) - x \cdot y \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 45.5%

      \[\leadsto \color{blue}{y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 38.5% accurate, 7.0× speedup?

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

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

    \[\left(x + y\right) - x \cdot y \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0 40.3%

    \[\leadsto \color{blue}{x} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024097 
(FPCore (x y)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, A"
  :precision binary64
  (- (+ x y) (* x y)))