Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I

Percentage Accurate: 95.9% → 99.6%
Time: 6.9s
Alternatives: 6
Speedup: 0.3×

Specification

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

\\
x \cdot \left(1 - y \cdot z\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 6 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: 95.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+185} \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+182}\right):\\ \;\;\;\;y \cdot \left(-x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* y z) -1e+185) (not (<= (* y z) 2e+182)))
   (* y (- (* x z)))
   (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (((y * z) <= -1e+185) || !((y * z) <= 2e+182)) {
		tmp = y * -(x * z);
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (((y * z) <= (-1d+185)) .or. (.not. ((y * z) <= 2d+182))) then
        tmp = y * -(x * z)
    else
        tmp = x * (1.0d0 - (y * z))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (((y * z) <= -1e+185) || !((y * z) <= 2e+182)) {
		tmp = y * -(x * z);
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if ((y * z) <= -1e+185) or not ((y * z) <= 2e+182):
		tmp = y * -(x * z)
	else:
		tmp = x * (1.0 - (y * z))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if ((Float64(y * z) <= -1e+185) || !(Float64(y * z) <= 2e+182))
		tmp = Float64(y * Float64(-Float64(x * z)));
	else
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((y * z) <= -1e+185) || ~(((y * z) <= 2e+182)))
		tmp = y * -(x * z);
	else
		tmp = x * (1.0 - (y * z));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -1e+185], N[Not[LessEqual[N[(y * z), $MachinePrecision], 2e+182]], $MachinePrecision]], N[(y * (-N[(x * z), $MachinePrecision])), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+185} \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+182}\right):\\
\;\;\;\;y \cdot \left(-x \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y z) < -9.9999999999999998e184 or 2.0000000000000001e182 < (*.f64 y z)

    1. Initial program 81.4%

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

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

        \[\leadsto \color{blue}{-x \cdot \left(y \cdot z\right)} \]
      2. associate-*r*99.8%

        \[\leadsto -\color{blue}{\left(x \cdot y\right) \cdot z} \]
      3. distribute-rgt-neg-in99.8%

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \left(-z\right)} \]
      4. *-commutative99.8%

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot \left(-z\right) \]
      5. associate-*r*99.7%

        \[\leadsto \color{blue}{y \cdot \left(x \cdot \left(-z\right)\right)} \]
      6. distribute-rgt-neg-out99.7%

        \[\leadsto y \cdot \color{blue}{\left(-x \cdot z\right)} \]
    5. Simplified99.7%

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

    if -9.9999999999999998e184 < (*.f64 y z) < 2.0000000000000001e182

    1. Initial program 99.9%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+185} \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+182}\right):\\ \;\;\;\;y \cdot \left(-x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 74.2% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.38 \cdot 10^{+42} \lor \neg \left(y \leq 1.5 \cdot 10^{-88}\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -1.38e+42) (not (<= y 1.5e-88))) (* (* y z) (- x)) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.38e+42) || !(y <= 1.5e-88)) {
		tmp = (y * z) * -x;
	} else {
		tmp = x;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-1.38d+42)) .or. (.not. (y <= 1.5d-88))) then
        tmp = (y * z) * -x
    else
        tmp = x
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.38e+42) || !(y <= 1.5e-88)) {
		tmp = (y * z) * -x;
	} else {
		tmp = x;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if (y <= -1.38e+42) or not (y <= 1.5e-88):
		tmp = (y * z) * -x
	else:
		tmp = x
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1.38e+42) || !(y <= 1.5e-88))
		tmp = Float64(Float64(y * z) * Float64(-x));
	else
		tmp = x;
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -1.38e+42) || ~((y <= 1.5e-88)))
		tmp = (y * z) * -x;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[Or[LessEqual[y, -1.38e+42], N[Not[LessEqual[y, 1.5e-88]], $MachinePrecision]], N[(N[(y * z), $MachinePrecision] * (-x)), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.38 \cdot 10^{+42} \lor \neg \left(y \leq 1.5 \cdot 10^{-88}\right):\\
\;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.3800000000000001e42 or 1.5e-88 < y

    1. Initial program 90.2%

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

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

        \[\leadsto \color{blue}{-x \cdot \left(y \cdot z\right)} \]
      2. distribute-rgt-neg-in66.0%

        \[\leadsto \color{blue}{x \cdot \left(-y \cdot z\right)} \]
      3. distribute-rgt-neg-out66.0%

        \[\leadsto x \cdot \color{blue}{\left(y \cdot \left(-z\right)\right)} \]
    5. Simplified66.0%

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

    if -1.3800000000000001e42 < y < 1.5e-88

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.38 \cdot 10^{+42} \lor \neg \left(y \leq 1.5 \cdot 10^{-88}\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.2% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.18 \cdot 10^{+42} \lor \neg \left(y \leq 1.25 \cdot 10^{-86}\right):\\ \;\;\;\;y \cdot \left(-x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -1.18e+42) (not (<= y 1.25e-86))) (* y (- (* x z))) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.18e+42) || !(y <= 1.25e-86)) {
		tmp = y * -(x * z);
	} else {
		tmp = x;
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-1.18d+42)) .or. (.not. (y <= 1.25d-86))) then
        tmp = y * -(x * z)
    else
        tmp = x
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.18e+42) || !(y <= 1.25e-86)) {
		tmp = y * -(x * z);
	} else {
		tmp = x;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if (y <= -1.18e+42) or not (y <= 1.25e-86):
		tmp = y * -(x * z)
	else:
		tmp = x
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1.18e+42) || !(y <= 1.25e-86))
		tmp = Float64(y * Float64(-Float64(x * z)));
	else
		tmp = x;
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -1.18e+42) || ~((y <= 1.25e-86)))
		tmp = y * -(x * z);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[Or[LessEqual[y, -1.18e+42], N[Not[LessEqual[y, 1.25e-86]], $MachinePrecision]], N[(y * (-N[(x * z), $MachinePrecision])), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.18 \cdot 10^{+42} \lor \neg \left(y \leq 1.25 \cdot 10^{-86}\right):\\
\;\;\;\;y \cdot \left(-x \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.18e42 or 1.25e-86 < y

    1. Initial program 90.2%

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

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

        \[\leadsto \color{blue}{-x \cdot \left(y \cdot z\right)} \]
      2. associate-*r*75.0%

        \[\leadsto -\color{blue}{\left(x \cdot y\right) \cdot z} \]
      3. distribute-rgt-neg-in75.0%

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \left(-z\right)} \]
      4. *-commutative75.0%

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot \left(-z\right) \]
      5. associate-*r*72.5%

        \[\leadsto \color{blue}{y \cdot \left(x \cdot \left(-z\right)\right)} \]
      6. distribute-rgt-neg-out72.5%

        \[\leadsto y \cdot \color{blue}{\left(-x \cdot z\right)} \]
    5. Simplified72.5%

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

    if -1.18e42 < y < 1.25e-86

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.18 \cdot 10^{+42} \lor \neg \left(y \leq 1.25 \cdot 10^{-86}\right):\\ \;\;\;\;y \cdot \left(-x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 95.7% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 8 \cdot 10^{+107}:\\ \;\;\;\;x - y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \left(y \cdot z\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= x 8e+107) (- x (* y (* x z))) (- x (* x (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (x <= 8e+107) {
		tmp = x - (y * (x * z));
	} else {
		tmp = x - (x * (y * z));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 8d+107) then
        tmp = x - (y * (x * z))
    else
        tmp = x - (x * (y * z))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 8e+107) {
		tmp = x - (y * (x * z));
	} else {
		tmp = x - (x * (y * z));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if x <= 8e+107:
		tmp = x - (y * (x * z))
	else:
		tmp = x - (x * (y * z))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (x <= 8e+107)
		tmp = Float64(x - Float64(y * Float64(x * z)));
	else
		tmp = Float64(x - Float64(x * Float64(y * z)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 8e+107)
		tmp = x - (y * (x * z));
	else
		tmp = x - (x * (y * z));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[x, 8e+107], N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{+107}:\\
\;\;\;\;x - y \cdot \left(x \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 7.9999999999999998e107

    1. Initial program 93.3%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg93.3%

        \[\leadsto x \cdot \color{blue}{\left(1 + \left(-y \cdot z\right)\right)} \]
      2. distribute-rgt-in93.3%

        \[\leadsto \color{blue}{1 \cdot x + \left(-y \cdot z\right) \cdot x} \]
      3. *-un-lft-identity93.3%

        \[\leadsto \color{blue}{x} + \left(-y \cdot z\right) \cdot x \]
      4. distribute-rgt-neg-in93.3%

        \[\leadsto x + \color{blue}{\left(y \cdot \left(-z\right)\right)} \cdot x \]
    4. Applied egg-rr93.3%

      \[\leadsto \color{blue}{x + \left(y \cdot \left(-z\right)\right) \cdot x} \]
    5. Step-by-step derivation
      1. distribute-rgt-neg-out93.3%

        \[\leadsto x + \color{blue}{\left(-y \cdot z\right)} \cdot x \]
      2. distribute-lft-neg-out93.3%

        \[\leadsto x + \color{blue}{\left(-\left(y \cdot z\right) \cdot x\right)} \]
      3. associate-*r*93.8%

        \[\leadsto x + \left(-\color{blue}{y \cdot \left(z \cdot x\right)}\right) \]
      4. *-commutative93.8%

        \[\leadsto x + \left(-y \cdot \color{blue}{\left(x \cdot z\right)}\right) \]
      5. distribute-lft-neg-in93.8%

        \[\leadsto x + \color{blue}{\left(-y\right) \cdot \left(x \cdot z\right)} \]
      6. add-sqr-sqrt51.9%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\left(\sqrt{x \cdot z} \cdot \sqrt{x \cdot z}\right)} \]
      7. sqrt-unprod58.7%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\sqrt{\left(x \cdot z\right) \cdot \left(x \cdot z\right)}} \]
      8. sqr-neg58.7%

        \[\leadsto x + \left(-y\right) \cdot \sqrt{\color{blue}{\left(-x \cdot z\right) \cdot \left(-x \cdot z\right)}} \]
      9. sqrt-unprod27.2%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\left(\sqrt{-x \cdot z} \cdot \sqrt{-x \cdot z}\right)} \]
      10. add-sqr-sqrt45.2%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\left(-x \cdot z\right)} \]
      11. *-commutative45.2%

        \[\leadsto x + \left(-y\right) \cdot \left(-\color{blue}{z \cdot x}\right) \]
      12. distribute-lft-neg-in45.2%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\left(\left(-z\right) \cdot x\right)} \]
      13. cancel-sign-sub-inv45.2%

        \[\leadsto \color{blue}{x - y \cdot \left(\left(-z\right) \cdot x\right)} \]
      14. associate-*l*47.6%

        \[\leadsto x - \color{blue}{\left(y \cdot \left(-z\right)\right) \cdot x} \]
      15. *-commutative47.6%

        \[\leadsto x - \color{blue}{x \cdot \left(y \cdot \left(-z\right)\right)} \]
      16. *-commutative47.6%

        \[\leadsto x - x \cdot \color{blue}{\left(\left(-z\right) \cdot y\right)} \]
      17. associate-*r*45.2%

        \[\leadsto x - \color{blue}{\left(x \cdot \left(-z\right)\right) \cdot y} \]
    6. Applied egg-rr93.8%

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

    if 7.9999999999999998e107 < x

    1. Initial program 100.0%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto x \cdot \color{blue}{\left(1 + \left(-y \cdot z\right)\right)} \]
      2. distribute-rgt-in100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8 \cdot 10^{+107}:\\ \;\;\;\;x - y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \left(y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 95.8% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{+83}:\\ \;\;\;\;x - y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= x 5e+83) (- x (* y (* x z))) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (x <= 5e+83) {
		tmp = x - (y * (x * z));
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 5d+83) then
        tmp = x - (y * (x * z))
    else
        tmp = x * (1.0d0 - (y * z))
    end if
    code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 5e+83) {
		tmp = x - (y * (x * z));
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if x <= 5e+83:
		tmp = x - (y * (x * z))
	else:
		tmp = x * (1.0 - (y * z))
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if (x <= 5e+83)
		tmp = Float64(x - Float64(y * Float64(x * z)));
	else
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	end
	return tmp
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 5e+83)
		tmp = x - (y * (x * z));
	else
		tmp = x * (1.0 - (y * z));
	end
	tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[x, 5e+83], N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+83}:\\
\;\;\;\;x - y \cdot \left(x \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 5.00000000000000029e83

    1. Initial program 93.0%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg93.0%

        \[\leadsto x \cdot \color{blue}{\left(1 + \left(-y \cdot z\right)\right)} \]
      2. distribute-rgt-in93.0%

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

        \[\leadsto \color{blue}{x} + \left(-y \cdot z\right) \cdot x \]
      4. distribute-rgt-neg-in93.0%

        \[\leadsto x + \color{blue}{\left(y \cdot \left(-z\right)\right)} \cdot x \]
    4. Applied egg-rr93.0%

      \[\leadsto \color{blue}{x + \left(y \cdot \left(-z\right)\right) \cdot x} \]
    5. Step-by-step derivation
      1. distribute-rgt-neg-out93.0%

        \[\leadsto x + \color{blue}{\left(-y \cdot z\right)} \cdot x \]
      2. distribute-lft-neg-out93.0%

        \[\leadsto x + \color{blue}{\left(-\left(y \cdot z\right) \cdot x\right)} \]
      3. associate-*r*93.5%

        \[\leadsto x + \left(-\color{blue}{y \cdot \left(z \cdot x\right)}\right) \]
      4. *-commutative93.5%

        \[\leadsto x + \left(-y \cdot \color{blue}{\left(x \cdot z\right)}\right) \]
      5. distribute-lft-neg-in93.5%

        \[\leadsto x + \color{blue}{\left(-y\right) \cdot \left(x \cdot z\right)} \]
      6. add-sqr-sqrt51.7%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\left(\sqrt{x \cdot z} \cdot \sqrt{x \cdot z}\right)} \]
      7. sqrt-unprod56.9%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\sqrt{\left(x \cdot z\right) \cdot \left(x \cdot z\right)}} \]
      8. sqr-neg56.9%

        \[\leadsto x + \left(-y\right) \cdot \sqrt{\color{blue}{\left(-x \cdot z\right) \cdot \left(-x \cdot z\right)}} \]
      9. sqrt-unprod26.5%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\left(\sqrt{-x \cdot z} \cdot \sqrt{-x \cdot z}\right)} \]
      10. add-sqr-sqrt43.7%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\left(-x \cdot z\right)} \]
      11. *-commutative43.7%

        \[\leadsto x + \left(-y\right) \cdot \left(-\color{blue}{z \cdot x}\right) \]
      12. distribute-lft-neg-in43.7%

        \[\leadsto x + \left(-y\right) \cdot \color{blue}{\left(\left(-z\right) \cdot x\right)} \]
      13. cancel-sign-sub-inv43.7%

        \[\leadsto \color{blue}{x - y \cdot \left(\left(-z\right) \cdot x\right)} \]
      14. associate-*l*46.3%

        \[\leadsto x - \color{blue}{\left(y \cdot \left(-z\right)\right) \cdot x} \]
      15. *-commutative46.3%

        \[\leadsto x - \color{blue}{x \cdot \left(y \cdot \left(-z\right)\right)} \]
      16. *-commutative46.3%

        \[\leadsto x - x \cdot \color{blue}{\left(\left(-z\right) \cdot y\right)} \]
      17. associate-*r*43.7%

        \[\leadsto x - \color{blue}{\left(x \cdot \left(-z\right)\right) \cdot y} \]
    6. Applied egg-rr93.5%

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

    if 5.00000000000000029e83 < x

    1. Initial program 100.0%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification94.8%

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

Alternative 6: 51.2% accurate, 7.0× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ x \end{array} \]
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z) :precision binary64 x)
assert(x < y && y < z);
double code(double x, double y, double z) {
	return x;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
	return x;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	return x
x, y, z = sort([x, y, z])
function code(x, y, z)
	return x
end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
	tmp = x;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := x
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
x
\end{array}
Derivation
  1. Initial program 94.4%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification46.8%

    \[\leadsto x \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2024029 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
  :precision binary64
  (* x (- 1.0 (* y z))))