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

Percentage Accurate: 96.2% → 98.1%
Time: 6.8s
Alternatives: 5
Speedup: 0.6×

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 5 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: 96.2% 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: 98.1% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;z \cdot \left(\left(-y\right) \cdot x\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 (<= (* y z) (- INFINITY)) (* z (* (- y) x)) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= -((double) INFINITY)) {
		tmp = z * (-y * x);
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
assert x < y && y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= -Double.POSITIVE_INFINITY) {
		tmp = z * (-y * x);
	} 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) <= -math.inf:
		tmp = z * (-y * x)
	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) <= Float64(-Inf))
		tmp = Float64(z * Float64(Float64(-y) * x));
	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) <= -Inf)
		tmp = z * (-y * x);
	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[N[(y * z), $MachinePrecision], (-Infinity)], N[(z * N[((-y) * x), $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 -\infty:\\
\;\;\;\;z \cdot \left(\left(-y\right) \cdot x\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) < -inf.0

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x - z \cdot \left(y \cdot x\right)} \]
    9. Taylor expanded in z around inf 63.3%

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 y z)

    1. Initial program 98.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;z \cdot \left(\left(-y\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]

Alternative 2: 74.1% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+40} \lor \neg \left(y \leq 1.35 \cdot 10^{-108}\right):\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\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 -5.5e+40) (not (<= y 1.35e-108))) (* x (* y (- z))) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5.5e+40) || !(y <= 1.35e-108)) {
		tmp = x * (y * -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 <= (-5.5d+40)) .or. (.not. (y <= 1.35d-108))) then
        tmp = x * (y * -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 <= -5.5e+40) || !(y <= 1.35e-108)) {
		tmp = x * (y * -z);
	} else {
		tmp = x;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if (y <= -5.5e+40) or not (y <= 1.35e-108):
		tmp = x * (y * -z)
	else:
		tmp = x
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if ((y <= -5.5e+40) || !(y <= 1.35e-108))
		tmp = Float64(x * Float64(y * Float64(-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 <= -5.5e+40) || ~((y <= 1.35e-108)))
		tmp = x * (y * -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, -5.5e+40], N[Not[LessEqual[y, 1.35e-108]], $MachinePrecision]], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+40} \lor \neg \left(y \leq 1.35 \cdot 10^{-108}\right):\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.49999999999999974e40 or 1.35000000000000002e-108 < y

    1. Initial program 93.0%

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

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

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

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

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

    if -5.49999999999999974e40 < y < 1.35000000000000002e-108

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+40} \lor \neg \left(y \leq 1.35 \cdot 10^{-108}\right):\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 3: 76.0% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+37} \lor \neg \left(y \leq 7 \cdot 10^{-106}\right):\\ \;\;\;\;y \cdot \left(x \cdot \left(-z\right)\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 -5.2e+37) (not (<= y 7e-106))) (* y (* x (- z))) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5.2e+37) || !(y <= 7e-106)) {
		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 <= (-5.2d+37)) .or. (.not. (y <= 7d-106))) 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 <= -5.2e+37) || !(y <= 7e-106)) {
		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 <= -5.2e+37) or not (y <= 7e-106):
		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 <= -5.2e+37) || !(y <= 7e-106))
		tmp = Float64(y * Float64(x * Float64(-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 <= -5.2e+37) || ~((y <= 7e-106)))
		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, -5.2e+37], N[Not[LessEqual[y, 7e-106]], $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 -5.2 \cdot 10^{+37} \lor \neg \left(y \leq 7 \cdot 10^{-106}\right):\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.1999999999999998e37 or 7e-106 < y

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

    if -5.1999999999999998e37 < y < 7e-106

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+37} \lor \neg \left(y \leq 7 \cdot 10^{-106}\right):\\ \;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 4: 75.8% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+37} \lor \neg \left(y \leq 7.4 \cdot 10^{-106}\right):\\ \;\;\;\;z \cdot \left(\left(-y\right) \cdot 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 -5.2e+37) (not (<= y 7.4e-106))) (* z (* (- y) x)) x))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5.2e+37) || !(y <= 7.4e-106)) {
		tmp = z * (-y * 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 <= (-5.2d+37)) .or. (.not. (y <= 7.4d-106))) then
        tmp = z * (-y * 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 <= -5.2e+37) || !(y <= 7.4e-106)) {
		tmp = z * (-y * x);
	} else {
		tmp = x;
	}
	return tmp;
}
[x, y, z] = sort([x, y, z])
def code(x, y, z):
	tmp = 0
	if (y <= -5.2e+37) or not (y <= 7.4e-106):
		tmp = z * (-y * x)
	else:
		tmp = x
	return tmp
x, y, z = sort([x, y, z])
function code(x, y, z)
	tmp = 0.0
	if ((y <= -5.2e+37) || !(y <= 7.4e-106))
		tmp = Float64(z * Float64(Float64(-y) * 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 <= -5.2e+37) || ~((y <= 7.4e-106)))
		tmp = z * (-y * 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, -5.2e+37], N[Not[LessEqual[y, 7.4e-106]], $MachinePrecision]], N[(z * N[((-y) * x), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+37} \lor \neg \left(y \leq 7.4 \cdot 10^{-106}\right):\\
\;\;\;\;z \cdot \left(\left(-y\right) \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.1999999999999998e37 or 7.39999999999999959e-106 < y

    1. Initial program 93.0%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. 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 \]
    3. Applied egg-rr93.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{\left(-\left(y \cdot x\right) \cdot z\right)} \]
      4. unsub-neg94.1%

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

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

      \[\leadsto \color{blue}{x - z \cdot \left(y \cdot x\right)} \]
    9. Taylor expanded in z around inf 70.6%

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

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

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

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

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

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

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

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

    if -5.1999999999999998e37 < y < 7.39999999999999959e-106

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+37} \lor \neg \left(y \leq 7.4 \cdot 10^{-106}\right):\\ \;\;\;\;z \cdot \left(\left(-y\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 50.5% 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 96.2%

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

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

    \[\leadsto x \]

Reproduce

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