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

Percentage Accurate: 95.6% → 99.4%
Time: 3.6s
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: 95.6% 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.4% 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^{+122} \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+303}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\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+122) (not (<= (* y z) 2e+303)))
   (* 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) <= -1e+122) || !((y * z) <= 2e+303)) {
		tmp = z * (y * -x);
	} 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+122)) .or. (.not. ((y * z) <= 2d+303))) then
        tmp = z * (y * -x)
    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+122) || !((y * z) <= 2e+303)) {
		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) <= -1e+122) or not ((y * z) <= 2e+303):
		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) <= -1e+122) || !(Float64(y * z) <= 2e+303))
		tmp = Float64(z * Float64(y * Float64(-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) <= -1e+122) || ~(((y * z) <= 2e+303)))
		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[Or[LessEqual[N[(y * z), $MachinePrecision], -1e+122], N[Not[LessEqual[N[(y * z), $MachinePrecision], 2e+303]], $MachinePrecision]], 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 -1 \cdot 10^{+122} \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+303}\right):\\
\;\;\;\;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) < -1.00000000000000001e122 or 2e303 < (*.f64 y z)

    1. Initial program 77.2%

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

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

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

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

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

    if -1.00000000000000001e122 < (*.f64 y z) < 2e303

    1. Initial program 99.8%

      \[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^{+122} \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+303}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 76.2% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+128} \lor \neg \left(y \leq -9 \cdot 10^{+120} \lor \neg \left(y \leq -3.5 \cdot 10^{+43}\right) \land y \leq 8 \cdot 10^{-64}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\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 -5e+128)
         (not (or (<= y -9e+120) (and (not (<= y -3.5e+43)) (<= y 8e-64)))))
   (* z (* y (- x)))
   x))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5e+128) || !((y <= -9e+120) || (!(y <= -3.5e+43) && (y <= 8e-64)))) {
		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 <= (-5d+128)) .or. (.not. (y <= (-9d+120)) .or. (.not. (y <= (-3.5d+43))) .and. (y <= 8d-64))) 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 <= -5e+128) || !((y <= -9e+120) || (!(y <= -3.5e+43) && (y <= 8e-64)))) {
		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 <= -5e+128) or not ((y <= -9e+120) or (not (y <= -3.5e+43) and (y <= 8e-64))):
		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 <= -5e+128) || !((y <= -9e+120) || (!(y <= -3.5e+43) && (y <= 8e-64))))
		tmp = Float64(z * Float64(y * 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 <= -5e+128) || ~(((y <= -9e+120) || (~((y <= -3.5e+43)) && (y <= 8e-64)))))
		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, -5e+128], N[Not[Or[LessEqual[y, -9e+120], And[N[Not[LessEqual[y, -3.5e+43]], $MachinePrecision], LessEqual[y, 8e-64]]]], $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 \cdot 10^{+128} \lor \neg \left(y \leq -9 \cdot 10^{+120} \lor \neg \left(y \leq -3.5 \cdot 10^{+43}\right) \land y \leq 8 \cdot 10^{-64}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5e128 or -8.99999999999999953e120 < y < -3.5000000000000001e43 or 7.99999999999999972e-64 < y

    1. Initial program 91.0%

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

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

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

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

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

    if -5e128 < y < -8.99999999999999953e120 or -3.5000000000000001e43 < y < 7.99999999999999972e-64

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+128} \lor \neg \left(y \leq -9 \cdot 10^{+120} \lor \neg \left(y \leq -3.5 \cdot 10^{+43}\right) \land y \leq 8 \cdot 10^{-64}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 75.6% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+126} \lor \neg \left(y \leq -9 \cdot 10^{+120} \lor \neg \left(y \leq -1.1 \cdot 10^{+41}\right) \land y \leq 5.1 \cdot 10^{-163}\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 -9.2e+126)
         (not (or (<= y -9e+120) (and (not (<= y -1.1e+41)) (<= y 5.1e-163)))))
   (* y (* x (- z)))
   x))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -9.2e+126) || !((y <= -9e+120) || (!(y <= -1.1e+41) && (y <= 5.1e-163)))) {
		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 <= (-9.2d+126)) .or. (.not. (y <= (-9d+120)) .or. (.not. (y <= (-1.1d+41))) .and. (y <= 5.1d-163))) 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 <= -9.2e+126) || !((y <= -9e+120) || (!(y <= -1.1e+41) && (y <= 5.1e-163)))) {
		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 <= -9.2e+126) or not ((y <= -9e+120) or (not (y <= -1.1e+41) and (y <= 5.1e-163))):
		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 <= -9.2e+126) || !((y <= -9e+120) || (!(y <= -1.1e+41) && (y <= 5.1e-163))))
		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 <= -9.2e+126) || ~(((y <= -9e+120) || (~((y <= -1.1e+41)) && (y <= 5.1e-163)))))
		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, -9.2e+126], N[Not[Or[LessEqual[y, -9e+120], And[N[Not[LessEqual[y, -1.1e+41]], $MachinePrecision], LessEqual[y, 5.1e-163]]]], $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 -9.2 \cdot 10^{+126} \lor \neg \left(y \leq -9 \cdot 10^{+120} \lor \neg \left(y \leq -1.1 \cdot 10^{+41}\right) \land y \leq 5.1 \cdot 10^{-163}\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 < -9.2000000000000002e126 or -8.99999999999999953e120 < y < -1.09999999999999995e41 or 5.0999999999999999e-163 < y

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

    if -9.2000000000000002e126 < y < -8.99999999999999953e120 or -1.09999999999999995e41 < y < 5.0999999999999999e-163

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+126} \lor \neg \left(y \leq -9 \cdot 10^{+120} \lor \neg \left(y \leq -1.1 \cdot 10^{+41}\right) \land y \leq 5.1 \cdot 10^{-163}\right):\\ \;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 95.8% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z] = \mathsf{sort}([x, y, z])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 3.65 \cdot 10^{-81}:\\ \;\;\;\;x - \left(x \cdot y\right) \cdot z\\ \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 3.65e-81) (- x (* (* x y) z)) (* x (- 1.0 (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
	double tmp;
	if (x <= 3.65e-81) {
		tmp = x - ((x * y) * 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 <= 3.65d-81) then
        tmp = x - ((x * y) * 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 <= 3.65e-81) {
		tmp = x - ((x * y) * 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 <= 3.65e-81:
		tmp = x - ((x * y) * 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 <= 3.65e-81)
		tmp = Float64(x - Float64(Float64(x * y) * 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 <= 3.65e-81)
		tmp = x - ((x * y) * 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, 3.65e-81], N[(x - N[(N[(x * y), $MachinePrecision] * 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}\;x \leq 3.65 \cdot 10^{-81}:\\
\;\;\;\;x - \left(x \cdot y\right) \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 3.6500000000000001e-81

    1. Initial program 92.6%

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

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

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

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

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

    if 3.6500000000000001e-81 < x

    1. Initial program 99.8%

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

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

Alternative 5: 50.1% 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 95.1%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification50.6%

    \[\leadsto x \]
  5. Add Preprocessing

Reproduce

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