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

Percentage Accurate: 96.1% → 99.0%
Time: 4.6s
Alternatives: 6
Speedup: 0.5×

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.1% 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.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+70}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* y z) (- INFINITY)) (not (<= (* y z) 2e+70)))
   (* z (* y (- x)))
   (- x (* (* y z) x))))
double code(double x, double y, double z) {
	double tmp;
	if (((y * z) <= -((double) INFINITY)) || !((y * z) <= 2e+70)) {
		tmp = z * (y * -x);
	} else {
		tmp = x - ((y * z) * x);
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (((y * z) <= -Double.POSITIVE_INFINITY) || !((y * z) <= 2e+70)) {
		tmp = z * (y * -x);
	} else {
		tmp = x - ((y * z) * x);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if ((y * z) <= -math.inf) or not ((y * z) <= 2e+70):
		tmp = z * (y * -x)
	else:
		tmp = x - ((y * z) * x)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((Float64(y * z) <= Float64(-Inf)) || !(Float64(y * z) <= 2e+70))
		tmp = Float64(z * Float64(y * Float64(-x)));
	else
		tmp = Float64(x - Float64(Float64(y * z) * x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((y * z) <= -Inf) || ~(((y * z) <= 2e+70)))
		tmp = z * (y * -x);
	else
		tmp = x - ((y * z) * x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(y * z), $MachinePrecision], 2e+70]], $MachinePrecision]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+70}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y z) < -inf.0 or 2.00000000000000015e70 < (*.f64 y z)

    1. Initial program 78.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+70}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* y z) (- INFINITY)) (not (<= (* y z) 2e+70)))
   (* z (* y (- x)))
   (* x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
	double tmp;
	if (((y * z) <= -((double) INFINITY)) || !((y * z) <= 2e+70)) {
		tmp = z * (y * -x);
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (((y * z) <= -Double.POSITIVE_INFINITY) || !((y * z) <= 2e+70)) {
		tmp = z * (y * -x);
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if ((y * z) <= -math.inf) or not ((y * z) <= 2e+70):
		tmp = z * (y * -x)
	else:
		tmp = x * (1.0 - (y * z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((Float64(y * z) <= Float64(-Inf)) || !(Float64(y * z) <= 2e+70))
		tmp = Float64(z * Float64(y * Float64(-x)));
	else
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((y * z) <= -Inf) || ~(((y * z) <= 2e+70)))
		tmp = z * (y * -x);
	else
		tmp = x * (1.0 - (y * z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(y * z), $MachinePrecision], 2e+70]], $MachinePrecision]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+70}\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) < -inf.0 or 2.00000000000000015e70 < (*.f64 y z)

    1. Initial program 78.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.9%

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

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

Alternative 3: 68.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.000112 \lor \neg \left(y \leq 1.5 \cdot 10^{-146}\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -0.000112) (not (<= y 1.5e-146))) (* (* y z) (- x)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -0.000112) || !(y <= 1.5e-146)) {
		tmp = (y * z) * -x;
	} else {
		tmp = x;
	}
	return tmp;
}
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 <= (-0.000112d0)) .or. (.not. (y <= 1.5d-146))) then
        tmp = (y * z) * -x
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -0.000112) || !(y <= 1.5e-146)) {
		tmp = (y * z) * -x;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -0.000112) or not (y <= 1.5e-146):
		tmp = (y * z) * -x
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -0.000112) || !(y <= 1.5e-146))
		tmp = Float64(Float64(y * z) * Float64(-x));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -0.000112) || ~((y <= 1.5e-146)))
		tmp = (y * z) * -x;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.000112], N[Not[LessEqual[y, 1.5e-146]], $MachinePrecision]], N[(N[(y * z), $MachinePrecision] * (-x)), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.000112 \lor \neg \left(y \leq 1.5 \cdot 10^{-146}\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.11999999999999998e-4 or 1.50000000000000009e-146 < y

    1. Initial program 90.3%

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

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

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

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

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

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

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

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

    if -1.11999999999999998e-4 < y < 1.50000000000000009e-146

    1. Initial program 99.9%

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

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

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

Alternative 4: 68.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.000105 \lor \neg \left(y \leq 1.95 \cdot 10^{-185}\right):\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -0.000105) (not (<= y 1.95e-185))) (* y (* z (- x))) x))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -0.000105) || !(y <= 1.95e-185)) {
		tmp = y * (z * -x);
	} else {
		tmp = x;
	}
	return tmp;
}
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 <= (-0.000105d0)) .or. (.not. (y <= 1.95d-185))) then
        tmp = y * (z * -x)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -0.000105) || !(y <= 1.95e-185)) {
		tmp = y * (z * -x);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -0.000105) or not (y <= 1.95e-185):
		tmp = y * (z * -x)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -0.000105) || !(y <= 1.95e-185))
		tmp = Float64(y * Float64(z * Float64(-x)));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -0.000105) || ~((y <= 1.95e-185)))
		tmp = y * (z * -x);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.000105], N[Not[LessEqual[y, 1.95e-185]], $MachinePrecision]], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.000105 \lor \neg \left(y \leq 1.95 \cdot 10^{-185}\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 y < -1.05e-4 or 1.95e-185 < y

    1. Initial program 90.7%

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

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

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

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

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

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

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

    if -1.05e-4 < y < 1.95e-185

    1. Initial program 99.8%

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

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

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

Alternative 5: 68.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.000112:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{-185}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -0.000112)
   (* z (* y (- x)))
   (if (<= y 1.95e-185) x (* y (* z (- x))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -0.000112) {
		tmp = z * (y * -x);
	} else if (y <= 1.95e-185) {
		tmp = x;
	} else {
		tmp = y * (z * -x);
	}
	return tmp;
}
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 <= (-0.000112d0)) then
        tmp = z * (y * -x)
    else if (y <= 1.95d-185) then
        tmp = x
    else
        tmp = y * (z * -x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -0.000112) {
		tmp = z * (y * -x);
	} else if (y <= 1.95e-185) {
		tmp = x;
	} else {
		tmp = y * (z * -x);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -0.000112:
		tmp = z * (y * -x)
	elif y <= 1.95e-185:
		tmp = x
	else:
		tmp = y * (z * -x)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -0.000112)
		tmp = Float64(z * Float64(y * Float64(-x)));
	elseif (y <= 1.95e-185)
		tmp = x;
	else
		tmp = Float64(y * Float64(z * Float64(-x)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -0.000112)
		tmp = z * (y * -x);
	elseif (y <= 1.95e-185)
		tmp = x;
	else
		tmp = y * (z * -x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -0.000112], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.95e-185], x, N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.000112:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.11999999999999998e-4

    1. Initial program 88.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.11999999999999998e-4 < y < 1.95e-185

    1. Initial program 99.8%

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

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

    if 1.95e-185 < y

    1. Initial program 92.2%

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

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

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

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

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

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

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

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

Alternative 6: 51.3% accurate, 7.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
	return x;
}
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
public static double code(double x, double y, double z) {
	return x;
}
def code(x, y, z):
	return x
function code(x, y, z)
	return x
end
function tmp = code(x, y, z)
	tmp = x;
end
code[x_, y_, z_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 94.0%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification48.0%

    \[\leadsto x \]

Reproduce

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