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

Percentage Accurate: 96.2% → 97.9%
Time: 5.8s
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.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: 97.9% accurate, 0.5× 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 52.5%

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

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

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

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

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

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

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

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

    1. Initial program 98.3%

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

Alternative 2: 68.9% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{+130} \lor \neg \left(y \leq 3 \cdot 10^{-101}\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 < -3.6000000000000001e130 or 3.0000000000000003e-101 < y

    1. Initial program 93.1%

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

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

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

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

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

    if -3.6000000000000001e130 < y < 3.0000000000000003e-101

    1. Initial program 98.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{+130} \lor \neg \left(y \leq 3 \cdot 10^{-101}\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 70.0% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.45 \cdot 10^{+130}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

\mathbf{elif}\;y \leq 2.8 \cdot 10^{-101}:\\
\;\;\;\;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 < -3.4500000000000001e130

    1. Initial program 84.8%

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

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

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

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

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

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

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

    if -3.4500000000000001e130 < y < 2.79999999999999989e-101

    1. Initial program 98.4%

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

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

    if 2.79999999999999989e-101 < y

    1. Initial program 96.6%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.45 \cdot 10^{+130}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-101}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 69.2% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.45 \cdot 10^{+130}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

\mathbf{elif}\;y \leq 3 \cdot 10^{-101}:\\
\;\;\;\;x\\

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


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

    1. Initial program 84.8%

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

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

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

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

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

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

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

    if -3.4500000000000001e130 < y < 3.0000000000000003e-101

    1. Initial program 98.4%

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

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

    if 3.0000000000000003e-101 < y

    1. Initial program 96.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.45 \cdot 10^{+130}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-101}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 51.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+131}:\\
\;\;\;\;\frac{z \cdot x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.69999999999999995e131

    1. Initial program 84.8%

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

      \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \left(x \cdot y\right) + \frac{x}{z}\right)} \]
    4. Taylor expanded in y around 0 9.7%

      \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
    5. Step-by-step derivation
      1. associate-*r/9.7%

        \[\leadsto \color{blue}{\frac{z \cdot x}{z}} \]
      2. *-commutative9.7%

        \[\leadsto \frac{\color{blue}{x \cdot z}}{z} \]
    6. Applied egg-rr9.7%

      \[\leadsto \color{blue}{\frac{x \cdot z}{z}} \]

    if -3.69999999999999995e131 < y

    1. Initial program 97.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+131}:\\ \;\;\;\;\frac{z \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

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

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

    \[\leadsto \color{blue}{x} \]
  4. Add Preprocessing

Reproduce

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