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

Percentage Accurate: 96.2% → 96.3%
Time: 4.6s
Alternatives: 5
Speedup: 0.8×

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: 96.3% accurate, 0.8× speedup?

\[\begin{array}{l} [y, z] = \mathsf{sort}([y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+207}:\\ \;\;\;\;x - y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\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 -3.8e+207) (- x (* y (* x z))) (* x (- 1.0 (* y z)))))
assert(y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.8e+207) {
		tmp = x - (y * (x * z));
	} else {
		tmp = x * (1.0 - (y * z));
	}
	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 <= (-3.8d+207)) then
        tmp = x - (y * (x * z))
    else
        tmp = x * (1.0d0 - (y * z))
    end if
    code = tmp
end function
assert y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.8e+207) {
		tmp = x - (y * (x * z));
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
[y, z] = sort([y, z])
def code(x, y, z):
	tmp = 0
	if y <= -3.8e+207:
		tmp = x - (y * (x * z))
	else:
		tmp = x * (1.0 - (y * z))
	return tmp
y, z = sort([y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.8e+207)
		tmp = Float64(x - Float64(y * Float64(x * z)));
	else
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	end
	return tmp
end
y, z = num2cell(sort([y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -3.8e+207)
		tmp = x - (y * (x * z));
	else
		tmp = x * (1.0 - (y * z));
	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[y, -3.8e+207], N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+207}:\\
\;\;\;\;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 y < -3.79999999999999986e207

    1. Initial program 85.8%

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

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

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

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

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

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

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

    if -3.79999999999999986e207 < y

    1. Initial program 97.9%

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

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

Alternative 2: 97.9% accurate, 0.6× speedup?

\[\begin{array}{l} [y, z] = \mathsf{sort}([y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\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) (- INFINITY)) (* z (* y (- x))) (* x (- 1.0 (* y z)))))
assert(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 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;
}
[y, z] = sort([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
y, z = sort([y, z])
function code(x, y, z)
	tmp = 0.0
	if (Float64(y * z) <= Float64(-Inf))
		tmp = Float64(z * Float64(y * Float64(-x)));
	else
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	end
	return tmp
end
y, z = num2cell(sort([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: 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}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\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 79.9%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. add-cbrt-cube79.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{{\color{blue}{\left(x \cdot \left(y \cdot \left(-z\right)\right)\right)}}^{3}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt31.5%

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

        \[\leadsto \sqrt[3]{\color{blue}{\sqrt{{\left(x \cdot \left(y \cdot \left(-z\right)\right)\right)}^{3} \cdot {\left(x \cdot \left(y \cdot \left(-z\right)\right)\right)}^{3}}}} \]
      3. pow-prod-up31.5%

        \[\leadsto \sqrt[3]{\sqrt{\color{blue}{{\left(x \cdot \left(y \cdot \left(-z\right)\right)\right)}^{\left(3 + 3\right)}}}} \]
      4. add-sqr-sqrt17.6%

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

        \[\leadsto \sqrt[3]{\sqrt{{\left(x \cdot \left(y \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)\right)}^{\left(3 + 3\right)}}} \]
      6. sqr-neg31.5%

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

        \[\leadsto \sqrt[3]{\sqrt{{\left(x \cdot \left(y \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}\right)\right)}^{\left(3 + 3\right)}}} \]
      8. add-sqr-sqrt31.5%

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

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

      \[\leadsto \sqrt[3]{\color{blue}{\sqrt{{\left(x \cdot \left(y \cdot z\right)\right)}^{6}}}} \]
    9. Step-by-step derivation
      1. *-commutative31.5%

        \[\leadsto \sqrt[3]{\sqrt{{\color{blue}{\left(\left(y \cdot z\right) \cdot x\right)}}^{6}}} \]
    10. Simplified31.5%

      \[\leadsto \sqrt[3]{\color{blue}{\sqrt{{\left(\left(y \cdot z\right) \cdot x\right)}^{6}}}} \]
    11. Taylor expanded in y around -inf 100.0%

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

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

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

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

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

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

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

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

    1. Initial program 98.3%

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

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

Alternative 3: 72.9% accurate, 0.7× speedup?

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

    1. Initial program 94.3%

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

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

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

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

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

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

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

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

    if -6.79999999999999973e118 < y < 2.2e-85

    1. Initial program 99.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{+118} \lor \neg \left(y \leq 2.2 \cdot 10^{-85}\right):\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 4: 73.4% accurate, 0.7× speedup?

\[\begin{array}{l} [y, z] = \mathsf{sort}([y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{+118}:\\ \;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{-85}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\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 -2.7e+118)
   (* y (* x (- z)))
   (if (<= y 1.95e-85) x (* x (* y (- z))))))
assert(y < z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.7e+118) {
		tmp = y * (x * -z);
	} else if (y <= 1.95e-85) {
		tmp = x;
	} else {
		tmp = x * (y * -z);
	}
	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 <= (-2.7d+118)) then
        tmp = y * (x * -z)
    else if (y <= 1.95d-85) then
        tmp = x
    else
        tmp = x * (y * -z)
    end if
    code = tmp
end function
assert y < z;
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.7e+118) {
		tmp = y * (x * -z);
	} else if (y <= 1.95e-85) {
		tmp = x;
	} else {
		tmp = x * (y * -z);
	}
	return tmp;
}
[y, z] = sort([y, z])
def code(x, y, z):
	tmp = 0
	if y <= -2.7e+118:
		tmp = y * (x * -z)
	elif y <= 1.95e-85:
		tmp = x
	else:
		tmp = x * (y * -z)
	return tmp
y, z = sort([y, z])
function code(x, y, z)
	tmp = 0.0
	if (y <= -2.7e+118)
		tmp = Float64(y * Float64(x * Float64(-z)));
	elseif (y <= 1.95e-85)
		tmp = x;
	else
		tmp = Float64(x * Float64(y * Float64(-z)));
	end
	return tmp
end
y, z = num2cell(sort([y, z])){:}
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2.7e+118)
		tmp = y * (x * -z);
	elseif (y <= 1.95e-85)
		tmp = x;
	else
		tmp = x * (y * -z);
	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[y, -2.7e+118], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.95e-85], x, N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+118}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\

\mathbf{elif}\;y \leq 1.95 \cdot 10^{-85}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.7e118

    1. Initial program 88.7%

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

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

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

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

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

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

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

    if -2.7e118 < y < 1.94999999999999994e-85

    1. Initial program 99.1%

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

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

    if 1.94999999999999994e-85 < y

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

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

Alternative 5: 50.8% 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.6%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification49.6%

    \[\leadsto x \]

Reproduce

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