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

Percentage Accurate: 96.1% → 97.8%
Time: 7.1s
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.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^{+304}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\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+304) t_0 (* (* z x) (+ y -1.0)))))
double code(double x, double y, double z) {
	double t_0 = x * (1.0 + (z * (y + -1.0)));
	double tmp;
	if (t_0 <= 1e+304) {
		tmp = t_0;
	} else {
		tmp = (z * x) * (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) :: t_0
    real(8) :: tmp
    t_0 = x * (1.0d0 + (z * (y + (-1.0d0))))
    if (t_0 <= 1d+304) then
        tmp = t_0
    else
        tmp = (z * x) * (y + (-1.0d0))
    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+304) {
		tmp = t_0;
	} else {
		tmp = (z * x) * (y + -1.0);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (1.0 + (z * (y + -1.0)))
	tmp = 0
	if t_0 <= 1e+304:
		tmp = t_0
	else:
		tmp = (z * x) * (y + -1.0)
	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+304)
		tmp = t_0;
	else
		tmp = Float64(Float64(z * x) * Float64(y + -1.0));
	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+304)
		tmp = t_0;
	else
		tmp = (z * x) * (y + -1.0);
	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+304], t$95$0, N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $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^{+304}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 98.6%

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

    if 9.9999999999999994e303 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z)))

    1. Initial program 80.2%

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

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

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

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

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

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

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

Alternative 2: 82.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+149} \lor \neg \left(y \leq -7 \cdot 10^{+89}\right) \land \left(y \leq -1.05 \cdot 10^{+43} \lor \neg \left(y \leq 1.2 \cdot 10^{+69}\right)\right):\\
\;\;\;\;x \cdot \left(z \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 < -4.49999999999999982e149 or -7.0000000000000001e89 < y < -1.05000000000000001e43 or 1.2000000000000001e69 < y

    1. Initial program 92.1%

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

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

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

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

    if -4.49999999999999982e149 < y < -7.0000000000000001e89 or -1.05000000000000001e43 < y < 1.2000000000000001e69

    1. Initial program 99.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{+149} \lor \neg \left(y \leq -7 \cdot 10^{+89}\right) \land \left(y \leq -1.05 \cdot 10^{+43} \lor \neg \left(y \leq 1.2 \cdot 10^{+69}\right)\right):\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]

Alternative 3: 82.9% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;y \leq -8 \cdot 10^{+88}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\

\mathbf{elif}\;y \leq -2.15 \cdot 10^{+43} \lor \neg \left(y \leq 3.5 \cdot 10^{+67}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.19999999999999974e149 or -7.99999999999999968e88 < y < -2.15e43 or 3.5e67 < y

    1. Initial program 92.1%

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

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

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

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

    if -6.19999999999999974e149 < y < -7.99999999999999968e88

    1. Initial program 90.5%

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

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

    if -2.15e43 < y < 3.5e67

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \color{blue}{x} + \left(-z\right) \cdot x \]
      4. distribute-lft-neg-in94.0%

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

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

        \[\leadsto \color{blue}{x - x \cdot z} \]
      7. *-commutative94.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{+149}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;y \leq -8 \cdot 10^{+88}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{elif}\;y \leq -2.15 \cdot 10^{+43} \lor \neg \left(y \leq 3.5 \cdot 10^{+67}\right):\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot x\\ \end{array} \]

Alternative 4: 86.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-13} \lor \neg \left(z \leq 23500\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.95000000000000002e-13 or 23500 < z

    1. Initial program 93.5%

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

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

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

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

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

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

    if -1.95000000000000002e-13 < z < 23500

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \color{blue}{x} + \left(-z\right) \cdot x \]
      4. distribute-lft-neg-in76.5%

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

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

        \[\leadsto \color{blue}{x - x \cdot z} \]
      7. *-commutative76.5%

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

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

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

Alternative 5: 98.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+20} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\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 < -4.6e20 or 1 < z

    1. Initial program 93.2%

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

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

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

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

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

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

    if -4.6e20 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \left(\color{blue}{\left(\left(-\left(-y\right)\right) + -1\right)} \cdot x\right) + 1 \cdot x \]
      11. remove-double-neg91.4%

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(z \cdot y\right)} + x \]
    6. Simplified98.0%

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

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

Alternative 6: 97.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ x + \frac{z \cdot x}{\frac{1}{y + -1}} \end{array} \]
(FPCore (x y z) :precision binary64 (+ x (/ (* z x) (/ 1.0 (+ y -1.0)))))
double code(double x, double y, double z) {
	return x + ((z * x) / (1.0 / (y + -1.0)));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + ((z * x) / (1.0d0 / (y + (-1.0d0))))
end function
public static double code(double x, double y, double z) {
	return x + ((z * x) / (1.0 / (y + -1.0)));
}
def code(x, y, z):
	return x + ((z * x) / (1.0 / (y + -1.0)))
function code(x, y, z)
	return Float64(x + Float64(Float64(z * x) / Float64(1.0 / Float64(y + -1.0))))
end
function tmp = code(x, y, z)
	tmp = x + ((z * x) / (1.0 / (y + -1.0)));
end
code[x_, y_, z_] := N[(x + N[(N[(z * x), $MachinePrecision] / N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{z \cdot x}{\frac{1}{y + -1}}
\end{array}
Derivation
  1. Initial program 96.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto z \cdot \left(\color{blue}{\left(\left(-\left(-y\right)\right) + -1\right)} \cdot x\right) + 1 \cdot x \]
    11. remove-double-neg95.5%

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

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

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

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

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

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

      \[\leadsto \left(x \cdot z\right) \cdot \color{blue}{\frac{y \cdot y - -1 \cdot -1}{y - -1}} + x \]
    5. clear-num85.7%

      \[\leadsto \left(x \cdot z\right) \cdot \color{blue}{\frac{1}{\frac{y - -1}{y \cdot y - -1 \cdot -1}}} + x \]
    6. un-div-inv85.7%

      \[\leadsto \color{blue}{\frac{x \cdot z}{\frac{y - -1}{y \cdot y - -1 \cdot -1}}} + x \]
    7. *-commutative85.7%

      \[\leadsto \frac{\color{blue}{z \cdot x}}{\frac{y - -1}{y \cdot y - -1 \cdot -1}} + x \]
    8. clear-num85.7%

      \[\leadsto \frac{z \cdot x}{\color{blue}{\frac{1}{\frac{y \cdot y - -1 \cdot -1}{y - -1}}}} + x \]
    9. flip-+97.6%

      \[\leadsto \frac{z \cdot x}{\frac{1}{\color{blue}{y + -1}}} + x \]
  5. Applied egg-rr97.6%

    \[\leadsto \color{blue}{\frac{z \cdot x}{\frac{1}{y + -1}}} + x \]
  6. Final simplification97.6%

    \[\leadsto x + \frac{z \cdot x}{\frac{1}{y + -1}} \]

Alternative 7: 64.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -9000000 \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 -9000000.0) (not (<= z 1.0))) (* z (- x)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -9000000.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 <= (-9000000.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 <= -9000000.0) || !(z <= 1.0)) {
		tmp = z * -x;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -9000000.0) or not (z <= 1.0):
		tmp = z * -x
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -9000000.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 <= -9000000.0) || ~((z <= 1.0)))
		tmp = z * -x;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -9000000.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -9000000 \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 < -9e6 or 1 < z

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9e6 < 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.8%

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

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

Alternative 8: 61.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{-13}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -8.2e-13) (* x (* z y)) (if (<= z 1.0) x (* z (- x)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -8.2e-13) {
		tmp = x * (z * y);
	} else if (z <= 1.0) {
		tmp = x;
	} else {
		tmp = z * -x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-8.2d-13)) then
        tmp = x * (z * y)
    else if (z <= 1.0d0) then
        tmp = x
    else
        tmp = z * -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -8.2e-13) {
		tmp = x * (z * y);
	} else if (z <= 1.0) {
		tmp = x;
	} else {
		tmp = z * -x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -8.2e-13:
		tmp = x * (z * y)
	elif z <= 1.0:
		tmp = x
	else:
		tmp = z * -x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -8.2e-13)
		tmp = Float64(x * Float64(z * y));
	elseif (z <= 1.0)
		tmp = x;
	else
		tmp = Float64(z * Float64(-x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -8.2e-13)
		tmp = x * (z * y);
	elseif (z <= 1.0)
		tmp = x;
	else
		tmp = z * -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -8.2e-13], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], x, N[(z * (-x)), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 91.6%

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

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

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

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

    if -8.2000000000000004e-13 < 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.8%

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

    if 1 < z

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 37.6% 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 96.6%

    \[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 2023297 
(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))))