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

Percentage Accurate: 96.0% → 98.1%
Time: 5.1s
Alternatives: 6
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 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: 96.0% 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} [y, z] = \mathsf{sort}([y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq 4 \cdot 10^{+278}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \end{array} \]
NOTE: y and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) 4e+278) (- x (* (* y z) x)) (* z (* y (- x)))))
assert(y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= 4e+278) {
		tmp = x - ((y * z) * x);
	} else {
		tmp = z * (y * -x);
	}
	return tmp;
}
NOTE: 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) <= 4d+278) then
        tmp = x - ((y * z) * x)
    else
        tmp = z * (y * -x)
    end if
    code = tmp
end function
assert y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= 4e+278) {
		tmp = x - ((y * z) * x);
	} else {
		tmp = z * (y * -x);
	}
	return tmp;
}
[y, z] = sort([y, z])
def code(x, y, z):
	tmp = 0
	if (y * z) <= 4e+278:
		tmp = x - ((y * z) * x)
	else:
		tmp = z * (y * -x)
	return tmp
y, z = sort([y, z])
function code(x, y, z)
	tmp = 0.0
	if (Float64(y * z) <= 4e+278)
		tmp = Float64(x - Float64(Float64(y * z) * x));
	else
		tmp = Float64(z * Float64(y * Float64(-x)));
	end
	return tmp
end
y, z = num2cell(sort([y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y * z) <= 4e+278)
		tmp = x - ((y * z) * x);
	else
		tmp = z * (y * -x);
	end
	tmp_2 = tmp;
end
NOTE: y and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], 4e+278], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq 4 \cdot 10^{+278}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y z) < 3.99999999999999985e278

    1. Initial program 98.3%

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

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

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

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

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

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

    if 3.99999999999999985e278 < (*.f64 y z)

    1. Initial program 75.8%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. add-sqr-sqrt40.5%

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

        \[\leadsto \color{blue}{{\left(\sqrt{x \cdot \left(1 - y \cdot z\right)}\right)}^{2}} \]
    3. Applied egg-rr40.5%

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

      \[\leadsto {\left(\sqrt{\color{blue}{-1 \cdot \left(y \cdot \left(z \cdot x\right)\right)}}\right)}^{2} \]
    5. Step-by-step derivation
      1. mul-1-neg54.8%

        \[\leadsto {\left(\sqrt{\color{blue}{-y \cdot \left(z \cdot x\right)}}\right)}^{2} \]
      2. distribute-rgt-neg-in54.8%

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

        \[\leadsto {\left(\sqrt{y \cdot \color{blue}{\left(z \cdot \left(-x\right)\right)}}\right)}^{2} \]
    6. Simplified54.8%

      \[\leadsto {\left(\sqrt{\color{blue}{y \cdot \left(z \cdot \left(-x\right)\right)}}\right)}^{2} \]
    7. Step-by-step derivation
      1. unpow254.8%

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(-x \cdot y\right)} \]
      6. neg-mul-199.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z \leq 4 \cdot 10^{+278}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \]

Alternative 2: 98.1% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y z) < 3.99999999999999996e239

    1. Initial program 98.2%

      \[x \cdot \left(1 - y \cdot z\right) \]

    if 3.99999999999999996e239 < (*.f64 y z)

    1. Initial program 83.3%

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

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

        \[\leadsto {\left(\sqrt{\color{blue}{-y \cdot \left(z \cdot x\right)}}\right)}^{2} \]
      2. distribute-rgt-neg-in44.6%

        \[\leadsto {\left(\sqrt{\color{blue}{y \cdot \left(-z \cdot x\right)}}\right)}^{2} \]
      3. distribute-rgt-neg-in44.6%

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

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

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

Alternative 3: 98.1% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y z) < 3.99999999999999985e278

    1. Initial program 98.3%

      \[x \cdot \left(1 - y \cdot z\right) \]

    if 3.99999999999999985e278 < (*.f64 y z)

    1. Initial program 75.8%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. add-sqr-sqrt40.5%

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

        \[\leadsto \color{blue}{{\left(\sqrt{x \cdot \left(1 - y \cdot z\right)}\right)}^{2}} \]
    3. Applied egg-rr40.5%

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

      \[\leadsto {\left(\sqrt{\color{blue}{-1 \cdot \left(y \cdot \left(z \cdot x\right)\right)}}\right)}^{2} \]
    5. Step-by-step derivation
      1. mul-1-neg54.8%

        \[\leadsto {\left(\sqrt{\color{blue}{-y \cdot \left(z \cdot x\right)}}\right)}^{2} \]
      2. distribute-rgt-neg-in54.8%

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

        \[\leadsto {\left(\sqrt{y \cdot \color{blue}{\left(z \cdot \left(-x\right)\right)}}\right)}^{2} \]
    6. Simplified54.8%

      \[\leadsto {\left(\sqrt{\color{blue}{y \cdot \left(z \cdot \left(-x\right)\right)}}\right)}^{2} \]
    7. Step-by-step derivation
      1. unpow254.8%

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(-x \cdot y\right)} \]
      6. neg-mul-199.6%

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

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

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

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

Alternative 4: 72.1% accurate, 0.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.35e-95 or 3.19999999999999982e-19 < z

    1. Initial program 94.3%

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

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

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

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

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

    if -1.35e-95 < z < 3.19999999999999982e-19

    1. Initial program 100.0%

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

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

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

Alternative 5: 74.0% accurate, 0.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.0999999999999999e-96 or 4.3000000000000002e-18 < z

    1. Initial program 94.3%

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

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

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

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

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

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

    if -1.0999999999999999e-96 < z < 4.3000000000000002e-18

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{-96} \lor \neg \left(z \leq 4.3 \cdot 10^{-18}\right):\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 6: 50.5% accurate, 7.0× speedup?

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

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

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

    \[\leadsto x \]

Reproduce

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