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

Percentage Accurate: 96.2% → 99.5%
Time: 7.1s
Alternatives: 12
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 12 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.2% 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: 99.5% accurate, 0.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (-.f64 1 y) z) < -4.99999999999999964e224

    1. Initial program 77.4%

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

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

        \[\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)} \]

    if -4.99999999999999964e224 < (*.f64 (-.f64 1 y) z) < 5.0000000000000001e296

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e296 < (*.f64 (-.f64 1 y) z)

    1. Initial program 62.6%

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+296}:\\
\;\;\;\;x \cdot \left(1 - t_0\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (-.f64 1 y) z) < -4.99999999999999964e224

    1. Initial program 77.4%

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

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

        \[\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)} \]

    if -4.99999999999999964e224 < (*.f64 (-.f64 1 y) z) < 5.0000000000000001e296

    1. Initial program 99.9%

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

    if 5.0000000000000001e296 < (*.f64 (-.f64 1 y) z)

    1. Initial program 62.6%

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 0.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (-.f64 1 y) z) < -4.99999999999999964e224

    1. Initial program 77.4%

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

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

        \[\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)} \]

    if -4.99999999999999964e224 < (*.f64 (-.f64 1 y) z) < 5.0000000000000001e296

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if 5.0000000000000001e296 < (*.f64 (-.f64 1 y) z)

    1. Initial program 62.6%

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

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

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

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

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

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

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

Alternative 4: 96.1% accurate, 0.7× speedup?

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

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

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

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

    if -1 < z < 1.17999999999999993e-284

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.17999999999999993e-284 < z < 0.20000000000000001

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.3% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < y < 0.39000000000000001

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{1 \cdot x - z \cdot x} \]
      3. *-lft-identity98.7%

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

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

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

Alternative 6: 98.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

    if -0.900000000000000022 < z < 0.20000000000000001

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.3% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 95.1%

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

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

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

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

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

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

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

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

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

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

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

    if 3.30000000000000019e-283 < z

    1. Initial program 93.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 53.9% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.4999999999999993e-143 or 4.79999999999999996e82 < y

    1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

    if -9.4999999999999993e-143 < y < 4.79999999999999996e82

    1. Initial program 99.2%

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

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

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

Alternative 9: 65.7% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.39999999999999994e-30 or 1.4000000000000001e-45 < z

    1. Initial program 89.7%

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

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

    if -1.39999999999999994e-30 < z < 1.4000000000000001e-45

    1. Initial program 99.9%

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

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

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

Alternative 10: 84.7% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.19999999999999991e44 or 2.5500000000000001e79 < y

    1. Initial program 86.5%

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

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

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

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

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

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

    if -6.19999999999999991e44 < y < 2.5500000000000001e79

    1. Initial program 99.3%

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

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

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

        \[\leadsto \color{blue}{1 \cdot x - z \cdot x} \]
      3. *-lft-identity93.3%

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

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

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

Alternative 11: 98.3% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 39.1% 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 94.1%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification38.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 2023196 
(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))))