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

Percentage Accurate: 95.5% → 98.8%
Time: 6.2s
Alternatives: 11
Speedup: 1.0×

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: 95.5% 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: 98.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 94.3%

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

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

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

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

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

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

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

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

    if -5.2e6 < z < 0.00250000000000000005

    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 98.9%

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

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

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

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

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

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

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

Alternative 2: 61.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(-x\right)\\ t_1 := x \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -1.22 \cdot 10^{+232}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{+204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{+184}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5200000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-61}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 11500 \lor \neg \left(z \leq 7.1 \cdot 10^{+152}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (- x))) (t_1 (* x (* z y))))
   (if (<= z -1.22e+232)
     t_0
     (if (<= z -2.1e+204)
       t_1
       (if (<= z -1.25e+184)
         t_0
         (if (<= z -5.6e+138)
           t_1
           (if (<= z -5200000.0)
             t_0
             (if (<= z 5.8e-61)
               x
               (if (or (<= z 11500.0) (not (<= z 7.1e+152))) t_1 t_0)))))))))
double code(double x, double y, double z) {
	double t_0 = z * -x;
	double t_1 = x * (z * y);
	double tmp;
	if (z <= -1.22e+232) {
		tmp = t_0;
	} else if (z <= -2.1e+204) {
		tmp = t_1;
	} else if (z <= -1.25e+184) {
		tmp = t_0;
	} else if (z <= -5.6e+138) {
		tmp = t_1;
	} else if (z <= -5200000.0) {
		tmp = t_0;
	} else if (z <= 5.8e-61) {
		tmp = x;
	} else if ((z <= 11500.0) || !(z <= 7.1e+152)) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = z * -x
    t_1 = x * (z * y)
    if (z <= (-1.22d+232)) then
        tmp = t_0
    else if (z <= (-2.1d+204)) then
        tmp = t_1
    else if (z <= (-1.25d+184)) then
        tmp = t_0
    else if (z <= (-5.6d+138)) then
        tmp = t_1
    else if (z <= (-5200000.0d0)) then
        tmp = t_0
    else if (z <= 5.8d-61) then
        tmp = x
    else if ((z <= 11500.0d0) .or. (.not. (z <= 7.1d+152))) then
        tmp = t_1
    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 t_1 = x * (z * y);
	double tmp;
	if (z <= -1.22e+232) {
		tmp = t_0;
	} else if (z <= -2.1e+204) {
		tmp = t_1;
	} else if (z <= -1.25e+184) {
		tmp = t_0;
	} else if (z <= -5.6e+138) {
		tmp = t_1;
	} else if (z <= -5200000.0) {
		tmp = t_0;
	} else if (z <= 5.8e-61) {
		tmp = x;
	} else if ((z <= 11500.0) || !(z <= 7.1e+152)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * -x
	t_1 = x * (z * y)
	tmp = 0
	if z <= -1.22e+232:
		tmp = t_0
	elif z <= -2.1e+204:
		tmp = t_1
	elif z <= -1.25e+184:
		tmp = t_0
	elif z <= -5.6e+138:
		tmp = t_1
	elif z <= -5200000.0:
		tmp = t_0
	elif z <= 5.8e-61:
		tmp = x
	elif (z <= 11500.0) or not (z <= 7.1e+152):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(-x))
	t_1 = Float64(x * Float64(z * y))
	tmp = 0.0
	if (z <= -1.22e+232)
		tmp = t_0;
	elseif (z <= -2.1e+204)
		tmp = t_1;
	elseif (z <= -1.25e+184)
		tmp = t_0;
	elseif (z <= -5.6e+138)
		tmp = t_1;
	elseif (z <= -5200000.0)
		tmp = t_0;
	elseif (z <= 5.8e-61)
		tmp = x;
	elseif ((z <= 11500.0) || !(z <= 7.1e+152))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * -x;
	t_1 = x * (z * y);
	tmp = 0.0;
	if (z <= -1.22e+232)
		tmp = t_0;
	elseif (z <= -2.1e+204)
		tmp = t_1;
	elseif (z <= -1.25e+184)
		tmp = t_0;
	elseif (z <= -5.6e+138)
		tmp = t_1;
	elseif (z <= -5200000.0)
		tmp = t_0;
	elseif (z <= 5.8e-61)
		tmp = x;
	elseif ((z <= 11500.0) || ~((z <= 7.1e+152)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.22e+232], t$95$0, If[LessEqual[z, -2.1e+204], t$95$1, If[LessEqual[z, -1.25e+184], t$95$0, If[LessEqual[z, -5.6e+138], t$95$1, If[LessEqual[z, -5200000.0], t$95$0, If[LessEqual[z, 5.8e-61], x, If[Or[LessEqual[z, 11500.0], N[Not[LessEqual[z, 7.1e+152]], $MachinePrecision]], t$95$1, t$95$0]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.1 \cdot 10^{+204}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -1.25 \cdot 10^{+184}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq -5200000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 5.8 \cdot 10^{-61}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 11500 \lor \neg \left(z \leq 7.1 \cdot 10^{+152}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.21999999999999994e232 or -2.1e204 < z < -1.25e184 or -5.6000000000000002e138 < z < -5.2e6 or 11500 < z < 7.10000000000000017e152

    1. Initial program 95.5%

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

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

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

        \[\leadsto \color{blue}{-x \cdot z} \]
      2. distribute-lft-neg-out76.9%

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

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

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

    if -1.21999999999999994e232 < z < -2.1e204 or -1.25e184 < z < -5.6000000000000002e138 or 5.7999999999999999e-61 < z < 11500 or 7.10000000000000017e152 < z

    1. Initial program 93.2%

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

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

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

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

    if -5.2e6 < z < 5.7999999999999999e-61

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.22 \cdot 10^{+232}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{+204}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{+184}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{+138}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;z \leq -5200000:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-61}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 11500 \lor \neg \left(z \leq 7.1 \cdot 10^{+152}\right):\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \]

Alternative 3: 86.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{-15} \lor \neg \left(z \leq 5.8 \cdot 10^{-61}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-1 + y\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.30000000000000002e-15 or 5.7999999999999999e-61 < z

    1. Initial program 94.8%

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

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

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

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

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

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

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

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

    if -1.30000000000000002e-15 < z < 5.7999999999999999e-61

    1. Initial program 99.9%

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

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

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

Alternative 4: 83.6% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 93.2%

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

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

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

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

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

    if -8.7999999999999993e140 < y < 1.6000000000000001e-8

    1. Initial program 99.4%

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

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

    if 1.6000000000000001e-8 < y

    1. Initial program 92.9%

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

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

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

Alternative 5: 84.9% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 93.2%

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

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

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

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

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

    if -1.79999999999999993e139 < y < 1.6000000000000001e-8

    1. Initial program 99.4%

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

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

    if 1.6000000000000001e-8 < y

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

Alternative 6: 82.9% accurate, 1.0× speedup?

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

    1. Initial program 92.9%

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

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

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

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

    if -5.0000000000000003e139 < y < 420

    1. Initial program 99.4%

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

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

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

Alternative 7: 83.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 93.2%

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

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

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

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

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

    if -2.1999999999999999e139 < y < 92000

    1. Initial program 99.4%

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

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

    if 92000 < y

    1. Initial program 92.8%

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

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

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

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

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

Alternative 8: 97.8% accurate, 1.0× speedup?

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

\\
x - \left(x \cdot z\right) \cdot \left(1 - y\right)
\end{array}
Derivation
  1. Initial program 97.0%

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

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

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

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

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

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

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

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

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

Alternative 9: 95.5% accurate, 1.0× speedup?

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

\\
x \cdot \left(1 + z \cdot \left(-1 + y\right)\right)
\end{array}
Derivation
  1. Initial program 97.0%

    \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
  2. Final simplification97.0%

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

Alternative 10: 64.4% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 94.3%

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

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

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

        \[\leadsto \color{blue}{-x \cdot z} \]
      2. distribute-lft-neg-out61.9%

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

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

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

    if -5.2e6 < z < 0.00250000000000000005

    1. Initial program 99.9%

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

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

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

Alternative 11: 38.3% accurate, 9.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
	return x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x
end function
public static double code(double x, double y, double z) {
	return x;
}
def code(x, y, z):
	return x
function code(x, y, z)
	return x
end
function tmp = code(x, y, z)
	tmp = x;
end
code[x_, y_, z_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 97.0%

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

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

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