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

Percentage Accurate: 96.1% → 97.9%
Time: 7.5s
Alternatives: 11
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 11 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.9% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 1.00000000000000002e306

    1. Initial program 98.2%

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

    if 1.00000000000000002e306 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z)))

    1. Initial program 76.9%

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

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

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

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

        \[\leadsto z \cdot \left(x \cdot y + \color{blue}{\left(-x\right)}\right) \]
      3. unsub-neg100.0%

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

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

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

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

Alternative 2: 98.7% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 90.9%

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

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

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

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

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

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

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

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

    if -57000 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot z + 1\right) \cdot x} \]
    7. Applied egg-rr97.7%

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

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

Alternative 3: 86.1% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;y \leq 7.4:\\
\;\;\;\;x - x \cdot z\\

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


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

    1. Initial program 84.6%

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

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

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

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

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

    if -1.6500000000000001e32 < y < 7.4000000000000004

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto x + \color{blue}{x \cdot \left(-z\right)} \]
      5. distribute-rgt-neg-out97.8%

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

        \[\leadsto \color{blue}{x - x \cdot z} \]
    4. Applied egg-rr97.8%

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

    if 7.4000000000000004 < y

    1. Initial program 92.8%

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

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

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

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

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

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

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

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

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

Alternative 4: 98.7% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -57000

    1. Initial program 92.1%

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

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

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

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

        \[\leadsto z \cdot \left(x \cdot y + \color{blue}{\left(-x\right)}\right) \]
      3. unsub-neg97.8%

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

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

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

    if -57000 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot z + 1\right) \cdot x} \]
    7. Applied egg-rr97.7%

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

    if 1 < z

    1. Initial program 89.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Step-by-step derivation
      1. add-cbrt-cube58.5%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\right)}^{3}}} \]
      3. sub-neg58.5%

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

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

        \[\leadsto \sqrt[3]{{\left(x \cdot \left(\color{blue}{\left(1 - y\right) \cdot \left(-z\right)} + 1\right)\right)}^{3}} \]
      6. fma-def58.5%

        \[\leadsto \sqrt[3]{{\left(x \cdot \color{blue}{\mathsf{fma}\left(1 - y, -z, 1\right)}\right)}^{3}} \]
    3. Applied egg-rr58.5%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(x \cdot \mathsf{fma}\left(1 - y, -z, 1\right)\right)}^{3}}} \]
    4. Taylor expanded in z around inf 89.4%

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

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

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

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

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

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

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

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

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

Alternative 5: 64.8% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;z \leq -3 \cdot 10^{-23}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.7999999999999999e194 or 1 < z

    1. Initial program 88.7%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
    3. Taylor expanded in z around inf 61.5%

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

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

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

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

    if -3.7999999999999999e194 < z < -3.00000000000000003e-23

    1. Initial program 97.6%

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

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

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

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

    if -3.00000000000000003e-23 < z < 1

    1. Initial program 99.9%

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

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

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

Alternative 6: 84.0% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.59999999999999996e31 or 12 < y

    1. Initial program 89.3%

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

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

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

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

    if -3.59999999999999996e31 < y < 12

    1. Initial program 100.0%

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

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

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

Alternative 7: 86.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.8e33 or 6.5999999999999996 < y

    1. Initial program 89.3%

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

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

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

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

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

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

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

    if -4.8e33 < y < 6.5999999999999996

    1. Initial program 100.0%

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

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

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

Alternative 8: 86.0% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.2e33 or 10.199999999999999 < y

    1. Initial program 89.3%

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

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

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

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

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

    if -6.2e33 < y < 10.199999999999999

    1. Initial program 100.0%

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

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

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

Alternative 9: 85.9% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.10000000000000005e31 or 14.5 < y

    1. Initial program 89.3%

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

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

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

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

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

    if -1.10000000000000005e31 < y < 14.5

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto x + \color{blue}{x \cdot \left(-z\right)} \]
      5. distribute-rgt-neg-out97.8%

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

        \[\leadsto \color{blue}{x - x \cdot z} \]
    4. Applied egg-rr97.8%

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

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

Alternative 10: 64.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\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.0))) (* z (- x)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		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.0d0))) 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.0)) {
		tmp = z * -x;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 1.0):
		tmp = z * -x
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 1.0))
		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.0)))
		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.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\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 < z

    1. Initial program 91.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
    3. Taylor expanded in z around inf 54.7%

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

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

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

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

    if -1 < z < 1

    1. Initial program 99.9%

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

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

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

Alternative 11: 39.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 95.2%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification35.7%

    \[\leadsto x \]

Developer target: 99.6% 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 2023320 
(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))))