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

Percentage Accurate: 96.5% → 98.2%
Time: 4.8s
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.5% 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.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;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 (<= (* y z) (- INFINITY)) (* z (* y (- x))) (- x (* (* y z) x))))
double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= -((double) INFINITY)) {
		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) {
		tmp = z * (y * -x);
	} else {
		tmp = x - ((y * z) * x);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y * z) <= -math.inf:
		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))
		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)
		tmp = z * (y * -x);
	else
		tmp = x - ((y * z) * x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], 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:\\
\;\;\;\;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

    1. Initial program 70.7%

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

        \[\leadsto x \cdot \color{blue}{\frac{{1}^{3} - {\left(y \cdot z\right)}^{3}}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)}} \]
      2. associate-*r/0.0%

        \[\leadsto \color{blue}{\frac{x \cdot \left({1}^{3} - {\left(y \cdot z\right)}^{3}\right)}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)}} \]
      3. metadata-eval0.0%

        \[\leadsto \frac{x \cdot \left(\color{blue}{1} - {\left(y \cdot z\right)}^{3}\right)}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)} \]
      4. metadata-eval0.0%

        \[\leadsto \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{\color{blue}{1} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)} \]
      5. distribute-rgt-out0.0%

        \[\leadsto \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \color{blue}{\left(y \cdot z\right) \cdot \left(y \cdot z + 1\right)}} \]
      6. +-commutative0.0%

        \[\leadsto \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \left(y \cdot z\right) \cdot \color{blue}{\left(1 + y \cdot z\right)}} \]
    3. Applied egg-rr0.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \left(y \cdot z\right) \cdot \left(1 + y \cdot z\right)}} \]
    4. Step-by-step derivation
      1. associate-/l*0.0%

        \[\leadsto \color{blue}{\frac{x}{\frac{1 + \left(y \cdot z\right) \cdot \left(1 + y \cdot z\right)}{1 - {\left(y \cdot z\right)}^{3}}}} \]
    5. Simplified0.0%

      \[\leadsto \color{blue}{\frac{x}{\frac{1 + \left(y \cdot z\right) \cdot \left(1 + y \cdot z\right)}{1 - {\left(y \cdot z\right)}^{3}}}} \]
    6. Taylor expanded in y around inf 70.7%

      \[\leadsto \frac{x}{\color{blue}{\frac{-1}{y \cdot z}}} \]
    7. Step-by-step derivation
      1. associate-/r/70.7%

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

        \[\leadsto \color{blue}{\left(\frac{x}{-1} \cdot y\right) \cdot z} \]
      3. div-inv100.0%

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

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

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

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

    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} \]
  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 - \left(y \cdot z\right) \cdot x\\ \end{array} \]

Alternative 2: 98.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+230}:\\ \;\;\;\;y \cdot \left(z \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 (<= (* y z) -1e+230) (* y (* z (- x))) (* x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= -1e+230) {
		tmp = y * (z * -x);
	} else {
		tmp = x * (1.0 - (y * z));
	}
	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 * z) <= (-1d+230)) then
        tmp = y * (z * -x)
    else
        tmp = x * (1.0d0 - (y * z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= -1e+230) {
		tmp = y * (z * -x);
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y * z) <= -1e+230:
		tmp = y * (z * -x)
	else:
		tmp = x * (1.0 - (y * z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(y * z) <= -1e+230)
		tmp = Float64(y * Float64(z * 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) <= -1e+230)
		tmp = y * (z * -x);
	else
		tmp = x * (1.0 - (y * z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -1e+230], N[(y * N[(z * (-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 -1 \cdot 10^{+230}:\\
\;\;\;\;y \cdot \left(z \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.0000000000000001e230

    1. Initial program 82.5%

      \[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-neg99.8%

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

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

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

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

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

    if -1.0000000000000001e230 < (*.f64 y z)

    1. Initial program 98.2%

      \[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 -1 \cdot 10^{+230}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]

Alternative 3: 98.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \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} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) (- INFINITY)) (* z (* y (- x))) (* x (- 1.0 (* 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;
}
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;
}
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
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
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
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}

\\
\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 70.7%

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

        \[\leadsto x \cdot \color{blue}{\frac{{1}^{3} - {\left(y \cdot z\right)}^{3}}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)}} \]
      2. associate-*r/0.0%

        \[\leadsto \color{blue}{\frac{x \cdot \left({1}^{3} - {\left(y \cdot z\right)}^{3}\right)}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)}} \]
      3. metadata-eval0.0%

        \[\leadsto \frac{x \cdot \left(\color{blue}{1} - {\left(y \cdot z\right)}^{3}\right)}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)} \]
      4. metadata-eval0.0%

        \[\leadsto \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{\color{blue}{1} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)} \]
      5. distribute-rgt-out0.0%

        \[\leadsto \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \color{blue}{\left(y \cdot z\right) \cdot \left(y \cdot z + 1\right)}} \]
      6. +-commutative0.0%

        \[\leadsto \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \left(y \cdot z\right) \cdot \color{blue}{\left(1 + y \cdot z\right)}} \]
    3. Applied egg-rr0.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \left(y \cdot z\right) \cdot \left(1 + y \cdot z\right)}} \]
    4. Step-by-step derivation
      1. associate-/l*0.0%

        \[\leadsto \color{blue}{\frac{x}{\frac{1 + \left(y \cdot z\right) \cdot \left(1 + y \cdot z\right)}{1 - {\left(y \cdot z\right)}^{3}}}} \]
    5. Simplified0.0%

      \[\leadsto \color{blue}{\frac{x}{\frac{1 + \left(y \cdot z\right) \cdot \left(1 + y \cdot z\right)}{1 - {\left(y \cdot z\right)}^{3}}}} \]
    6. Taylor expanded in y around inf 70.7%

      \[\leadsto \frac{x}{\color{blue}{\frac{-1}{y \cdot z}}} \]
    7. Step-by-step derivation
      1. associate-/r/70.7%

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

        \[\leadsto \color{blue}{\left(\frac{x}{-1} \cdot y\right) \cdot z} \]
      3. div-inv100.0%

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

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

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

    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 4: 70.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+41} \lor \neg \left(y \leq 2.4 \cdot 10^{-103}\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 -1e+41) (not (<= y 2.4e-103))) (* (* y z) (- x)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1e+41) || !(y <= 2.4e-103)) {
		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 <= (-1d+41)) .or. (.not. (y <= 2.4d-103))) 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 <= -1e+41) || !(y <= 2.4e-103)) {
		tmp = (y * z) * -x;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -1e+41) or not (y <= 2.4e-103):
		tmp = (y * z) * -x
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1e+41) || !(y <= 2.4e-103))
		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 <= -1e+41) || ~((y <= 2.4e-103)))
		tmp = (y * z) * -x;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e+41], N[Not[LessEqual[y, 2.4e-103]], $MachinePrecision]], N[(N[(y * z), $MachinePrecision] * (-x)), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+41} \lor \neg \left(y \leq 2.4 \cdot 10^{-103}\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.00000000000000001e41 or 2.4000000000000002e-103 < y

    1. Initial program 93.5%

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

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

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

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

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

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

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

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

    if -1.00000000000000001e41 < y < 2.4000000000000002e-103

    1. Initial program 99.9%

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

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

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

Alternative 5: 70.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{+100} \lor \neg \left(y \leq 3.75 \cdot 10^{-103}\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 -2.4e+100) (not (<= y 3.75e-103))) (* y (* z (- x))) x))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -2.4e+100) || !(y <= 3.75e-103)) {
		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 <= (-2.4d+100)) .or. (.not. (y <= 3.75d-103))) 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 <= -2.4e+100) || !(y <= 3.75e-103)) {
		tmp = y * (z * -x);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -2.4e+100) or not (y <= 3.75e-103):
		tmp = y * (z * -x)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -2.4e+100) || !(y <= 3.75e-103))
		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 <= -2.4e+100) || ~((y <= 3.75e-103)))
		tmp = y * (z * -x);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.4e+100], N[Not[LessEqual[y, 3.75e-103]], $MachinePrecision]], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+100} \lor \neg \left(y \leq 3.75 \cdot 10^{-103}\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 < -2.40000000000000012e100 or 3.75e-103 < y

    1. Initial program 92.9%

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

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

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

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

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

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

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

    if -2.40000000000000012e100 < y < 3.75e-103

    1. Initial program 99.9%

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

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

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

Alternative 6: 51.1% 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 96.6%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification52.1%

    \[\leadsto x \]

Reproduce

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