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

Percentage Accurate: 96.0% → 97.8%
Time: 6.4s
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.0% 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.8× speedup?

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

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

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


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

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

    if -1.99999999999999985e75 < z

    1. Initial program 99.5%

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

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

Alternative 2: 65.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z \cdot x\right)\\ \mathbf{if}\;z \leq -1.02 \cdot 10^{-13}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 9.8 \cdot 10^{+17} \lor \neg \left(z \leq 1.25 \cdot 10^{+42}\right) \land \left(z \leq 1.32 \cdot 10^{+91} \lor \neg \left(z \leq 2.65 \cdot 10^{+209}\right) \land z \leq 3.4 \cdot 10^{+256}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* z x))))
   (if (<= z -1.02e-13)
     t_0
     (if (<= z 1.15e-19)
       x
       (if (or (<= z 9.8e+17)
               (and (not (<= z 1.25e+42))
                    (or (<= z 1.32e+91)
                        (and (not (<= z 2.65e+209)) (<= z 3.4e+256)))))
         t_0
         (* z (- x)))))))
double code(double x, double y, double z) {
	double t_0 = y * (z * x);
	double tmp;
	if (z <= -1.02e-13) {
		tmp = t_0;
	} else if (z <= 1.15e-19) {
		tmp = x;
	} else if ((z <= 9.8e+17) || (!(z <= 1.25e+42) && ((z <= 1.32e+91) || (!(z <= 2.65e+209) && (z <= 3.4e+256))))) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = y * (z * x)
    if (z <= (-1.02d-13)) then
        tmp = t_0
    else if (z <= 1.15d-19) then
        tmp = x
    else if ((z <= 9.8d+17) .or. (.not. (z <= 1.25d+42)) .and. (z <= 1.32d+91) .or. (.not. (z <= 2.65d+209)) .and. (z <= 3.4d+256)) then
        tmp = t_0
    else
        tmp = z * -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (z * x);
	double tmp;
	if (z <= -1.02e-13) {
		tmp = t_0;
	} else if (z <= 1.15e-19) {
		tmp = x;
	} else if ((z <= 9.8e+17) || (!(z <= 1.25e+42) && ((z <= 1.32e+91) || (!(z <= 2.65e+209) && (z <= 3.4e+256))))) {
		tmp = t_0;
	} else {
		tmp = z * -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z * x)
	tmp = 0
	if z <= -1.02e-13:
		tmp = t_0
	elif z <= 1.15e-19:
		tmp = x
	elif (z <= 9.8e+17) or (not (z <= 1.25e+42) and ((z <= 1.32e+91) or (not (z <= 2.65e+209) and (z <= 3.4e+256)))):
		tmp = t_0
	else:
		tmp = z * -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(z * x))
	tmp = 0.0
	if (z <= -1.02e-13)
		tmp = t_0;
	elseif (z <= 1.15e-19)
		tmp = x;
	elseif ((z <= 9.8e+17) || (!(z <= 1.25e+42) && ((z <= 1.32e+91) || (!(z <= 2.65e+209) && (z <= 3.4e+256)))))
		tmp = t_0;
	else
		tmp = Float64(z * Float64(-x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (z * x);
	tmp = 0.0;
	if (z <= -1.02e-13)
		tmp = t_0;
	elseif (z <= 1.15e-19)
		tmp = x;
	elseif ((z <= 9.8e+17) || (~((z <= 1.25e+42)) && ((z <= 1.32e+91) || (~((z <= 2.65e+209)) && (z <= 3.4e+256)))))
		tmp = t_0;
	else
		tmp = z * -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.02e-13], t$95$0, If[LessEqual[z, 1.15e-19], x, If[Or[LessEqual[z, 9.8e+17], And[N[Not[LessEqual[z, 1.25e+42]], $MachinePrecision], Or[LessEqual[z, 1.32e+91], And[N[Not[LessEqual[z, 2.65e+209]], $MachinePrecision], LessEqual[z, 3.4e+256]]]]], t$95$0, N[(z * (-x)), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 1.15 \cdot 10^{-19}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 9.8 \cdot 10^{+17} \lor \neg \left(z \leq 1.25 \cdot 10^{+42}\right) \land \left(z \leq 1.32 \cdot 10^{+91} \lor \neg \left(z \leq 2.65 \cdot 10^{+209}\right) \land z \leq 3.4 \cdot 10^{+256}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.0199999999999999e-13 or 1.1499999999999999e-19 < z < 9.8e17 or 1.25000000000000002e42 < z < 1.32000000000000003e91 or 2.64999999999999997e209 < z < 3.39999999999999984e256

    1. Initial program 93.2%

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

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

    if -1.0199999999999999e-13 < z < 1.1499999999999999e-19

    1. Initial program 100.0%

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

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

    if 9.8e17 < z < 1.25000000000000002e42 or 1.32000000000000003e91 < z < 2.64999999999999997e209 or 3.39999999999999984e256 < z

    1. Initial program 96.8%

      \[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 \color{blue}{\left(\left(y - 1\right) \cdot x\right) \cdot z} \]
      2. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.02 \cdot 10^{-13}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 9.8 \cdot 10^{+17} \lor \neg \left(z \leq 1.25 \cdot 10^{+42}\right) \land \left(z \leq 1.32 \cdot 10^{+91} \lor \neg \left(z \leq 2.65 \cdot 10^{+209}\right) \land z \leq 3.4 \cdot 10^{+256}\right):\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \]

Alternative 3: 65.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(y \cdot x\right)\\ t_1 := z \cdot \left(-x\right)\\ t_2 := y \cdot \left(z \cdot x\right)\\ \mathbf{if}\;z \leq -8.5 \cdot 10^{-14}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+23}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{+210} \lor \neg \left(z \leq 3.7 \cdot 10^{+256}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (* y x))) (t_1 (* z (- x))) (t_2 (* y (* z x))))
   (if (<= z -8.5e-14)
     t_2
     (if (<= z 1.2e-19)
       x
       (if (<= z 1.2e+23)
         t_0
         (if (<= z 5.6e+40)
           t_1
           (if (<= z 1.35e+94)
             t_0
             (if (or (<= z 1.85e+210) (not (<= z 3.7e+256))) t_1 t_2))))))))
double code(double x, double y, double z) {
	double t_0 = z * (y * x);
	double t_1 = z * -x;
	double t_2 = y * (z * x);
	double tmp;
	if (z <= -8.5e-14) {
		tmp = t_2;
	} else if (z <= 1.2e-19) {
		tmp = x;
	} else if (z <= 1.2e+23) {
		tmp = t_0;
	} else if (z <= 5.6e+40) {
		tmp = t_1;
	} else if (z <= 1.35e+94) {
		tmp = t_0;
	} else if ((z <= 1.85e+210) || !(z <= 3.7e+256)) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_0 = z * (y * x)
    t_1 = z * -x
    t_2 = y * (z * x)
    if (z <= (-8.5d-14)) then
        tmp = t_2
    else if (z <= 1.2d-19) then
        tmp = x
    else if (z <= 1.2d+23) then
        tmp = t_0
    else if (z <= 5.6d+40) then
        tmp = t_1
    else if (z <= 1.35d+94) then
        tmp = t_0
    else if ((z <= 1.85d+210) .or. (.not. (z <= 3.7d+256))) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * (y * x);
	double t_1 = z * -x;
	double t_2 = y * (z * x);
	double tmp;
	if (z <= -8.5e-14) {
		tmp = t_2;
	} else if (z <= 1.2e-19) {
		tmp = x;
	} else if (z <= 1.2e+23) {
		tmp = t_0;
	} else if (z <= 5.6e+40) {
		tmp = t_1;
	} else if (z <= 1.35e+94) {
		tmp = t_0;
	} else if ((z <= 1.85e+210) || !(z <= 3.7e+256)) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * (y * x)
	t_1 = z * -x
	t_2 = y * (z * x)
	tmp = 0
	if z <= -8.5e-14:
		tmp = t_2
	elif z <= 1.2e-19:
		tmp = x
	elif z <= 1.2e+23:
		tmp = t_0
	elif z <= 5.6e+40:
		tmp = t_1
	elif z <= 1.35e+94:
		tmp = t_0
	elif (z <= 1.85e+210) or not (z <= 3.7e+256):
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(y * x))
	t_1 = Float64(z * Float64(-x))
	t_2 = Float64(y * Float64(z * x))
	tmp = 0.0
	if (z <= -8.5e-14)
		tmp = t_2;
	elseif (z <= 1.2e-19)
		tmp = x;
	elseif (z <= 1.2e+23)
		tmp = t_0;
	elseif (z <= 5.6e+40)
		tmp = t_1;
	elseif (z <= 1.35e+94)
		tmp = t_0;
	elseif ((z <= 1.85e+210) || !(z <= 3.7e+256))
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * (y * x);
	t_1 = z * -x;
	t_2 = y * (z * x);
	tmp = 0.0;
	if (z <= -8.5e-14)
		tmp = t_2;
	elseif (z <= 1.2e-19)
		tmp = x;
	elseif (z <= 1.2e+23)
		tmp = t_0;
	elseif (z <= 5.6e+40)
		tmp = t_1;
	elseif (z <= 1.35e+94)
		tmp = t_0;
	elseif ((z <= 1.85e+210) || ~((z <= 3.7e+256)))
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.5e-14], t$95$2, If[LessEqual[z, 1.2e-19], x, If[LessEqual[z, 1.2e+23], t$95$0, If[LessEqual[z, 5.6e+40], t$95$1, If[LessEqual[z, 1.35e+94], t$95$0, If[Or[LessEqual[z, 1.85e+210], N[Not[LessEqual[z, 3.7e+256]], $MachinePrecision]], t$95$1, t$95$2]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 1.2 \cdot 10^{-19}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 1.2 \cdot 10^{+23}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 5.6 \cdot 10^{+40}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 1.35 \cdot 10^{+94}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 1.85 \cdot 10^{+210} \lor \neg \left(z \leq 3.7 \cdot 10^{+256}\right):\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -8.50000000000000038e-14 or 1.84999999999999999e210 < z < 3.70000000000000031e256

    1. Initial program 91.6%

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

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

    if -8.50000000000000038e-14 < z < 1.20000000000000011e-19

    1. Initial program 100.0%

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

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

    if 1.20000000000000011e-19 < z < 1.2e23 or 5.6000000000000003e40 < z < 1.3500000000000001e94

    1. Initial program 99.9%

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

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

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

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

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

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

    if 1.2e23 < z < 5.6000000000000003e40 or 1.3500000000000001e94 < z < 1.84999999999999999e210 or 3.70000000000000031e256 < z

    1. Initial program 96.8%

      \[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 \color{blue}{\left(\left(y - 1\right) \cdot x\right) \cdot z} \]
      2. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{-14}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+23}:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{+40}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+94}:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{+210} \lor \neg \left(z \leq 3.7 \cdot 10^{+256}\right):\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \end{array} \]

Alternative 4: 86.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-5} \lor \neg \left(z \leq 1.6 \cdot 10^{-19}\right):\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.79999999999999996e-5 or 1.59999999999999991e-19 < z

    1. Initial program 93.9%

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

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

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

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

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

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

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

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

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

    if -2.79999999999999996e-5 < z < 1.59999999999999991e-19

    1. Initial program 100.0%

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

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

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

Alternative 5: 86.6% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 1.45 \cdot 10^{-19}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\

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


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

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

    if -1.7e-5 < z < 1.45e-19

    1. Initial program 100.0%

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

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

    if 1.45e-19 < z

    1. Initial program 98.3%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 98.4% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 90.4%

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

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

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

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

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

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

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

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

    if -0.94999999999999996 < z < 1.75999999999999993e-19

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.75999999999999993e-19 < z

    1. Initial program 98.3%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 85.0% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.0999999999999998e48 or 5.29999999999999982 < y

    1. Initial program 93.5%

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

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

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

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

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

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

    if -2.0999999999999998e48 < y < 5.29999999999999982

    1. Initial program 99.3%

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

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

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

Alternative 8: 64.0% accurate, 1.1× speedup?

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

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

    1. Initial program 93.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < z < 4e-14

    1. Initial program 100.0%

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

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

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

Alternative 9: 38.5% 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 38.0%

    \[\leadsto \color{blue}{x} \]
  3. Final simplification38.0%

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