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

Percentage Accurate: 96.1% → 97.8%
Time: 6.6s
Alternatives: 9
Speedup: 0.8×

Specification

?
\[\begin{array}{l} \\ x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
	return x * (1.0 - ((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 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
	return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z):
	return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z)))
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - ((1.0 - y) * z));
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(1 - \left(1 - y\right) \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 9 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 - \left(1 - y\right) \cdot z\right) \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
	return x * (1.0 - ((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 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
	return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z):
	return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z)))
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - ((1.0 - y) * z));
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}

Alternative 1: 97.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 8.2 \cdot 10^{-101}:\\ \;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y + -1, z \cdot x, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z 8.2e-101)
   (* x (+ 1.0 (* z (+ y -1.0))))
   (fma (+ y -1.0) (* z x) x)))
double code(double x, double y, double z) {
	double tmp;
	if (z <= 8.2e-101) {
		tmp = x * (1.0 + (z * (y + -1.0)));
	} else {
		tmp = fma((y + -1.0), (z * x), x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= 8.2e-101)
		tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0))));
	else
		tmp = fma(Float64(y + -1.0), Float64(z * x), x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, 8.2e-101], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 8.20000000000000052e-101

    1. Initial program 99.3%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]

    if 8.20000000000000052e-101 < z

    1. Initial program 94.2%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-out--94.2%

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

        \[\leadsto \color{blue}{x} - \left(\left(1 - y\right) \cdot z\right) \cdot x \]
      3. cancel-sign-sub-inv94.2%

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

        \[\leadsto \color{blue}{\left(-\left(1 - y\right) \cdot z\right) \cdot x + x} \]
      5. distribute-lft-neg-in94.2%

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

        \[\leadsto \color{blue}{\left(-\left(1 - y\right)\right) \cdot \left(z \cdot x\right)} + x \]
      7. fma-def99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-\left(1 - y\right), z \cdot x, x\right)} \]
      8. neg-sub099.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{0 - \left(1 - y\right)}, z \cdot x, x\right) \]
      9. associate--r-99.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0 - 1\right) + y}, z \cdot x, x\right) \]
      10. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{-1} + y, z \cdot x, x\right) \]
      11. +-commutative99.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y + -1}, z \cdot x, x\right) \]
      12. *-commutative99.9%

        \[\leadsto \mathsf{fma}\left(y + -1, \color{blue}{x \cdot z}, x\right) \]
    3. Simplified99.9%

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

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

Alternative 2: 56.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(-x\right)\\ t_1 := x \cdot \left(z \cdot y\right)\\ \mathbf{if}\;y \leq -1.85 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-189}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (- x))) (t_1 (* x (* z y))))
   (if (<= y -1.85e+121)
     t_1
     (if (<= y -2.9e-110)
       x
       (if (<= y -2.5e-189)
         t_0
         (if (<= y -9e-250)
           x
           (if (<= y 1.55e-6) t_0 (if (<= y 7.8e+34) x t_1))))))))
double code(double x, double y, double z) {
	double t_0 = z * -x;
	double t_1 = x * (z * y);
	double tmp;
	if (y <= -1.85e+121) {
		tmp = t_1;
	} else if (y <= -2.9e-110) {
		tmp = x;
	} else if (y <= -2.5e-189) {
		tmp = t_0;
	} else if (y <= -9e-250) {
		tmp = x;
	} else if (y <= 1.55e-6) {
		tmp = t_0;
	} else if (y <= 7.8e+34) {
		tmp = x;
	} else {
		tmp = t_1;
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = z * -x
    t_1 = x * (z * y)
    if (y <= (-1.85d+121)) then
        tmp = t_1
    else if (y <= (-2.9d-110)) then
        tmp = x
    else if (y <= (-2.5d-189)) then
        tmp = t_0
    else if (y <= (-9d-250)) then
        tmp = x
    else if (y <= 1.55d-6) then
        tmp = t_0
    else if (y <= 7.8d+34) then
        tmp = x
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * -x;
	double t_1 = x * (z * y);
	double tmp;
	if (y <= -1.85e+121) {
		tmp = t_1;
	} else if (y <= -2.9e-110) {
		tmp = x;
	} else if (y <= -2.5e-189) {
		tmp = t_0;
	} else if (y <= -9e-250) {
		tmp = x;
	} else if (y <= 1.55e-6) {
		tmp = t_0;
	} else if (y <= 7.8e+34) {
		tmp = x;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * -x
	t_1 = x * (z * y)
	tmp = 0
	if y <= -1.85e+121:
		tmp = t_1
	elif y <= -2.9e-110:
		tmp = x
	elif y <= -2.5e-189:
		tmp = t_0
	elif y <= -9e-250:
		tmp = x
	elif y <= 1.55e-6:
		tmp = t_0
	elif y <= 7.8e+34:
		tmp = x
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(-x))
	t_1 = Float64(x * Float64(z * y))
	tmp = 0.0
	if (y <= -1.85e+121)
		tmp = t_1;
	elseif (y <= -2.9e-110)
		tmp = x;
	elseif (y <= -2.5e-189)
		tmp = t_0;
	elseif (y <= -9e-250)
		tmp = x;
	elseif (y <= 1.55e-6)
		tmp = t_0;
	elseif (y <= 7.8e+34)
		tmp = x;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * -x;
	t_1 = x * (z * y);
	tmp = 0.0;
	if (y <= -1.85e+121)
		tmp = t_1;
	elseif (y <= -2.9e-110)
		tmp = x;
	elseif (y <= -2.5e-189)
		tmp = t_0;
	elseif (y <= -9e-250)
		tmp = x;
	elseif (y <= 1.55e-6)
		tmp = t_0;
	elseif (y <= 7.8e+34)
		tmp = x;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.85e+121], t$95$1, If[LessEqual[y, -2.9e-110], x, If[LessEqual[y, -2.5e-189], t$95$0, If[LessEqual[y, -9e-250], x, If[LessEqual[y, 1.55e-6], t$95$0, If[LessEqual[y, 7.8e+34], x, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;y \leq -1.85 \cdot 10^{+121}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -2.9 \cdot 10^{-110}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq -2.5 \cdot 10^{-189}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -9 \cdot 10^{-250}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.55 \cdot 10^{-6}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 7.8 \cdot 10^{+34}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.85000000000000006e121 or 7.80000000000000038e34 < y

    1. Initial program 93.8%

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

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

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

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

    if -1.85000000000000006e121 < y < -2.9000000000000002e-110 or -2.4999999999999999e-189 < y < -8.99999999999999987e-250 or 1.55e-6 < y < 7.80000000000000038e34

    1. Initial program 100.0%

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

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

    if -2.9000000000000002e-110 < y < -2.4999999999999999e-189 or -8.99999999999999987e-250 < y < 1.55e-6

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(1 + \left(-z\right)\right)} \cdot x \]
      2. +-commutative99.3%

        \[\leadsto \color{blue}{\left(\left(-z\right) + 1\right)} \cdot x \]
      3. distribute-rgt1-in99.3%

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

        \[\leadsto \color{blue}{x - z \cdot x} \]
    4. Simplified99.3%

      \[\leadsto \color{blue}{x - z \cdot x} \]
    5. Taylor expanded in z around inf 66.7%

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

        \[\leadsto \color{blue}{-z \cdot x} \]
      2. distribute-rgt-neg-out66.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.85 \cdot 10^{+121}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-189}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-6}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \end{array} \]

Alternative 3: 57.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -8.2 \cdot 10^{+121}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-191}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{-247}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{+33}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (- x))))
   (if (<= y -8.2e+121)
     (* x (* z y))
     (if (<= y -6.5e-110)
       x
       (if (<= y -5.8e-191)
         t_0
         (if (<= y -1.15e-247)
           x
           (if (<= y 1.3e-7) t_0 (if (<= y 9.8e+33) x (* y (* z x))))))))))
double code(double x, double y, double z) {
	double t_0 = z * -x;
	double tmp;
	if (y <= -8.2e+121) {
		tmp = x * (z * y);
	} else if (y <= -6.5e-110) {
		tmp = x;
	} else if (y <= -5.8e-191) {
		tmp = t_0;
	} else if (y <= -1.15e-247) {
		tmp = x;
	} else if (y <= 1.3e-7) {
		tmp = t_0;
	} else if (y <= 9.8e+33) {
		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) :: t_0
    real(8) :: tmp
    t_0 = z * -x
    if (y <= (-8.2d+121)) then
        tmp = x * (z * y)
    else if (y <= (-6.5d-110)) then
        tmp = x
    else if (y <= (-5.8d-191)) then
        tmp = t_0
    else if (y <= (-1.15d-247)) then
        tmp = x
    else if (y <= 1.3d-7) then
        tmp = t_0
    else if (y <= 9.8d+33) 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 t_0 = z * -x;
	double tmp;
	if (y <= -8.2e+121) {
		tmp = x * (z * y);
	} else if (y <= -6.5e-110) {
		tmp = x;
	} else if (y <= -5.8e-191) {
		tmp = t_0;
	} else if (y <= -1.15e-247) {
		tmp = x;
	} else if (y <= 1.3e-7) {
		tmp = t_0;
	} else if (y <= 9.8e+33) {
		tmp = x;
	} else {
		tmp = y * (z * x);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * -x
	tmp = 0
	if y <= -8.2e+121:
		tmp = x * (z * y)
	elif y <= -6.5e-110:
		tmp = x
	elif y <= -5.8e-191:
		tmp = t_0
	elif y <= -1.15e-247:
		tmp = x
	elif y <= 1.3e-7:
		tmp = t_0
	elif y <= 9.8e+33:
		tmp = x
	else:
		tmp = y * (z * x)
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(-x))
	tmp = 0.0
	if (y <= -8.2e+121)
		tmp = Float64(x * Float64(z * y));
	elseif (y <= -6.5e-110)
		tmp = x;
	elseif (y <= -5.8e-191)
		tmp = t_0;
	elseif (y <= -1.15e-247)
		tmp = x;
	elseif (y <= 1.3e-7)
		tmp = t_0;
	elseif (y <= 9.8e+33)
		tmp = x;
	else
		tmp = Float64(y * Float64(z * x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * -x;
	tmp = 0.0;
	if (y <= -8.2e+121)
		tmp = x * (z * y);
	elseif (y <= -6.5e-110)
		tmp = x;
	elseif (y <= -5.8e-191)
		tmp = t_0;
	elseif (y <= -1.15e-247)
		tmp = x;
	elseif (y <= 1.3e-7)
		tmp = t_0;
	elseif (y <= 9.8e+33)
		tmp = x;
	else
		tmp = y * (z * x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[y, -8.2e+121], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -6.5e-110], x, If[LessEqual[y, -5.8e-191], t$95$0, If[LessEqual[y, -1.15e-247], x, If[LessEqual[y, 1.3e-7], t$95$0, If[LessEqual[y, 9.8e+33], x, N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+121}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\

\mathbf{elif}\;y \leq -6.5 \cdot 10^{-110}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq -5.8 \cdot 10^{-191}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -1.15 \cdot 10^{-247}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{-7}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 9.8 \cdot 10^{+33}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -8.2e121

    1. Initial program 97.2%

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

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

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

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

    if -8.2e121 < y < -6.4999999999999996e-110 or -5.7999999999999999e-191 < y < -1.15e-247 or 1.29999999999999999e-7 < y < 9.80000000000000027e33

    1. Initial program 100.0%

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

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

    if -6.4999999999999996e-110 < y < -5.7999999999999999e-191 or -1.15e-247 < y < 1.29999999999999999e-7

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(1 + \left(-z\right)\right)} \cdot x \]
      2. +-commutative99.3%

        \[\leadsto \color{blue}{\left(\left(-z\right) + 1\right)} \cdot x \]
      3. distribute-rgt1-in99.3%

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

        \[\leadsto \color{blue}{x - z \cdot x} \]
    4. Simplified99.3%

      \[\leadsto \color{blue}{x - z \cdot x} \]
    5. Taylor expanded in z around inf 66.7%

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

        \[\leadsto \color{blue}{-z \cdot x} \]
      2. distribute-rgt-neg-out66.7%

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

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

    if 9.80000000000000027e33 < y

    1. Initial program 91.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+121}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-191}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{-247}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-7}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{+33}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \end{array} \]

Alternative 4: 57.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{+121}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-192}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.02 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{+33}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (- x))))
   (if (<= y -1.7e+121)
     (* x (* z y))
     (if (<= y -2.9e-110)
       x
       (if (<= y -2.8e-192)
         t_0
         (if (<= y -1.02e-250)
           x
           (if (<= y 1.8e-8) t_0 (if (<= y 8.8e+33) x (* z (* x y))))))))))
double code(double x, double y, double z) {
	double t_0 = z * -x;
	double tmp;
	if (y <= -1.7e+121) {
		tmp = x * (z * y);
	} else if (y <= -2.9e-110) {
		tmp = x;
	} else if (y <= -2.8e-192) {
		tmp = t_0;
	} else if (y <= -1.02e-250) {
		tmp = x;
	} else if (y <= 1.8e-8) {
		tmp = t_0;
	} else if (y <= 8.8e+33) {
		tmp = x;
	} else {
		tmp = z * (x * y);
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = z * -x
    if (y <= (-1.7d+121)) then
        tmp = x * (z * y)
    else if (y <= (-2.9d-110)) then
        tmp = x
    else if (y <= (-2.8d-192)) then
        tmp = t_0
    else if (y <= (-1.02d-250)) then
        tmp = x
    else if (y <= 1.8d-8) then
        tmp = t_0
    else if (y <= 8.8d+33) then
        tmp = x
    else
        tmp = z * (x * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * -x;
	double tmp;
	if (y <= -1.7e+121) {
		tmp = x * (z * y);
	} else if (y <= -2.9e-110) {
		tmp = x;
	} else if (y <= -2.8e-192) {
		tmp = t_0;
	} else if (y <= -1.02e-250) {
		tmp = x;
	} else if (y <= 1.8e-8) {
		tmp = t_0;
	} else if (y <= 8.8e+33) {
		tmp = x;
	} else {
		tmp = z * (x * y);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * -x
	tmp = 0
	if y <= -1.7e+121:
		tmp = x * (z * y)
	elif y <= -2.9e-110:
		tmp = x
	elif y <= -2.8e-192:
		tmp = t_0
	elif y <= -1.02e-250:
		tmp = x
	elif y <= 1.8e-8:
		tmp = t_0
	elif y <= 8.8e+33:
		tmp = x
	else:
		tmp = z * (x * y)
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(-x))
	tmp = 0.0
	if (y <= -1.7e+121)
		tmp = Float64(x * Float64(z * y));
	elseif (y <= -2.9e-110)
		tmp = x;
	elseif (y <= -2.8e-192)
		tmp = t_0;
	elseif (y <= -1.02e-250)
		tmp = x;
	elseif (y <= 1.8e-8)
		tmp = t_0;
	elseif (y <= 8.8e+33)
		tmp = x;
	else
		tmp = Float64(z * Float64(x * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * -x;
	tmp = 0.0;
	if (y <= -1.7e+121)
		tmp = x * (z * y);
	elseif (y <= -2.9e-110)
		tmp = x;
	elseif (y <= -2.8e-192)
		tmp = t_0;
	elseif (y <= -1.02e-250)
		tmp = x;
	elseif (y <= 1.8e-8)
		tmp = t_0;
	elseif (y <= 8.8e+33)
		tmp = x;
	else
		tmp = z * (x * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[y, -1.7e+121], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.9e-110], x, If[LessEqual[y, -2.8e-192], t$95$0, If[LessEqual[y, -1.02e-250], x, If[LessEqual[y, 1.8e-8], t$95$0, If[LessEqual[y, 8.8e+33], x, N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+121}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\

\mathbf{elif}\;y \leq -2.9 \cdot 10^{-110}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq -2.8 \cdot 10^{-192}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -1.02 \cdot 10^{-250}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{-8}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 8.8 \cdot 10^{+33}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.70000000000000005e121

    1. Initial program 97.2%

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

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

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

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

    if -1.70000000000000005e121 < y < -2.9000000000000002e-110 or -2.80000000000000004e-192 < y < -1.02000000000000001e-250 or 1.79999999999999991e-8 < y < 8.79999999999999975e33

    1. Initial program 100.0%

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

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

    if -2.9000000000000002e-110 < y < -2.80000000000000004e-192 or -1.02000000000000001e-250 < y < 1.79999999999999991e-8

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(1 + \left(-z\right)\right)} \cdot x \]
      2. +-commutative99.3%

        \[\leadsto \color{blue}{\left(\left(-z\right) + 1\right)} \cdot x \]
      3. distribute-rgt1-in99.3%

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

        \[\leadsto \color{blue}{x - z \cdot x} \]
    4. Simplified99.3%

      \[\leadsto \color{blue}{x - z \cdot x} \]
    5. Taylor expanded in z around inf 66.7%

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

        \[\leadsto \color{blue}{-z \cdot x} \]
      2. distribute-rgt-neg-out66.7%

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

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

    if 8.79999999999999975e33 < y

    1. Initial program 91.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{+121}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-192}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -1.02 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-8}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{+33}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \end{array} \]

Alternative 5: 98.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -380 \lor \neg \left(z \leq 2.9 \cdot 10^{-16}\right):\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -380 or 2.8999999999999998e-16 < z

    1. Initial program 95.7%

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

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

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

        \[\leadsto z \cdot \left(x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      3. metadata-eval98.9%

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

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

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

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

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

    if -380 < z < 2.8999999999999998e-16

    1. Initial program 99.8%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(-y\right) \cdot z}\right) \]
      2. cancel-sign-sub99.3%

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

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

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

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

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

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

Alternative 6: 98.0% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 5e14

    1. Initial program 99.4%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]

    if 5e14 < z

    1. Initial program 92.2%

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

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

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

        \[\leadsto z \cdot \left(x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) \]
      3. metadata-eval99.9%

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

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

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

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

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

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

Alternative 7: 83.8% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;y \leq 4.6 \cdot 10^{+34}:\\
\;\;\;\;x - z \cdot x\\

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


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

    1. Initial program 97.2%

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

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

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

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

    if -3.60000000000000016e120 < y < 4.5999999999999996e34

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(1 + \left(-z\right)\right)} \cdot x \]
      2. +-commutative95.2%

        \[\leadsto \color{blue}{\left(\left(-z\right) + 1\right)} \cdot x \]
      3. distribute-rgt1-in95.2%

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

        \[\leadsto \color{blue}{x - z \cdot x} \]
    4. Simplified95.2%

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

    if 4.5999999999999996e34 < y

    1. Initial program 91.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{+120}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+34}:\\ \;\;\;\;x - z \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \end{array} \]

Alternative 8: 65.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1.12 \cdot 10^{-26}\right):\\
\;\;\;\;z \cdot \left(-x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1 or 1.12e-26 < z

    1. Initial program 95.8%

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

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

        \[\leadsto \color{blue}{\left(1 + \left(-z\right)\right)} \cdot x \]
      2. +-commutative58.7%

        \[\leadsto \color{blue}{\left(\left(-z\right) + 1\right)} \cdot x \]
      3. distribute-rgt1-in58.7%

        \[\leadsto \color{blue}{x + \left(-z\right) \cdot x} \]
      4. cancel-sign-sub-inv58.7%

        \[\leadsto \color{blue}{x - z \cdot x} \]
    4. Simplified58.7%

      \[\leadsto \color{blue}{x - z \cdot x} \]
    5. Taylor expanded in z around inf 57.8%

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

        \[\leadsto \color{blue}{-z \cdot x} \]
      2. distribute-rgt-neg-out57.8%

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

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

    if -1 < z < 1.12e-26

    1. Initial program 99.8%

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

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

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

Alternative 9: 40.0% accurate, 9.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 97.7%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification37.8%

    \[\leadsto x \]

Developer target: 99.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{if}\;t_0 < -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 < 3.892237649663903 \cdot 10^{+134}:\\ \;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))
        (t_1 (+ x (* (- 1.0 y) (* (- z) x)))))
   (if (< t_0 -1.618195973607049e+50)
     t_1
     (if (< t_0 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) t_1))))
double code(double x, double y, double z) {
	double t_0 = x * (1.0 - ((1.0 - y) * z));
	double t_1 = x + ((1.0 - y) * (-z * x));
	double tmp;
	if (t_0 < -1.618195973607049e+50) {
		tmp = t_1;
	} else if (t_0 < 3.892237649663903e+134) {
		tmp = ((x * y) * z) - ((x * z) - x);
	} else {
		tmp = t_1;
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (1.0d0 - ((1.0d0 - y) * z))
    t_1 = x + ((1.0d0 - y) * (-z * x))
    if (t_0 < (-1.618195973607049d+50)) then
        tmp = t_1
    else if (t_0 < 3.892237649663903d+134) then
        tmp = ((x * y) * z) - ((x * z) - x)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (1.0 - ((1.0 - y) * z));
	double t_1 = x + ((1.0 - y) * (-z * x));
	double tmp;
	if (t_0 < -1.618195973607049e+50) {
		tmp = t_1;
	} else if (t_0 < 3.892237649663903e+134) {
		tmp = ((x * y) * z) - ((x * z) - x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (1.0 - ((1.0 - y) * z))
	t_1 = x + ((1.0 - y) * (-z * x))
	tmp = 0
	if t_0 < -1.618195973607049e+50:
		tmp = t_1
	elif t_0 < 3.892237649663903e+134:
		tmp = ((x * y) * z) - ((x * z) - x)
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z)))
	t_1 = Float64(x + Float64(Float64(1.0 - y) * Float64(Float64(-z) * x)))
	tmp = 0.0
	if (t_0 < -1.618195973607049e+50)
		tmp = t_1;
	elseif (t_0 < 3.892237649663903e+134)
		tmp = Float64(Float64(Float64(x * y) * z) - Float64(Float64(x * z) - x));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (1.0 - ((1.0 - y) * z));
	t_1 = x + ((1.0 - y) * (-z * x));
	tmp = 0.0;
	if (t_0 < -1.618195973607049e+50)
		tmp = t_1;
	elseif (t_0 < 3.892237649663903e+134)
		tmp = ((x * y) * z) - ((x * z) - x);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(1.0 - y), $MachinePrecision] * N[((-z) * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$0, -1.618195973607049e+50], t$95$1, If[Less[t$95$0, 3.892237649663903e+134], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}

Reproduce

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

  :herbie-target
  (if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))

  (* x (- 1.0 (* (- 1.0 y) z))))