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

Percentage Accurate: 95.8% → 99.6%
Time: 9.6s
Alternatives: 9
Speedup: 0.5×

Specification

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

\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 95.8% 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.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - y\right) \cdot z\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;t\_0 \leq 10^{+109}:\\ \;\;\;\;x \cdot \left(1 + \frac{z}{\frac{1}{y + -1}}\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (- 1.0 y) z)))
   (if (<= t_0 (- INFINITY))
     (* z (* y x))
     (if (<= t_0 1e+109)
       (* x (+ 1.0 (/ z (/ 1.0 (+ y -1.0)))))
       (* z (* x (+ y -1.0)))))))
double code(double x, double y, double z) {
	double t_0 = (1.0 - y) * z;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = z * (y * x);
	} else if (t_0 <= 1e+109) {
		tmp = x * (1.0 + (z / (1.0 / (y + -1.0))));
	} else {
		tmp = z * (x * (y + -1.0));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = (1.0 - y) * z;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = z * (y * x);
	} else if (t_0 <= 1e+109) {
		tmp = x * (1.0 + (z / (1.0 / (y + -1.0))));
	} else {
		tmp = z * (x * (y + -1.0));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (1.0 - y) * z
	tmp = 0
	if t_0 <= -math.inf:
		tmp = z * (y * x)
	elif t_0 <= 1e+109:
		tmp = x * (1.0 + (z / (1.0 / (y + -1.0))))
	else:
		tmp = z * (x * (y + -1.0))
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(1.0 - y) * z)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(z * Float64(y * x));
	elseif (t_0 <= 1e+109)
		tmp = Float64(x * Float64(1.0 + Float64(z / Float64(1.0 / Float64(y + -1.0)))));
	else
		tmp = Float64(z * Float64(x * Float64(y + -1.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (1.0 - y) * z;
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = z * (y * x);
	elseif (t_0 <= 1e+109)
		tmp = x * (1.0 + (z / (1.0 / (y + -1.0))));
	else
		tmp = z * (x * (y + -1.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+109], N[(x * N[(1.0 + N[(z / N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq 10^{+109}:\\
\;\;\;\;x \cdot \left(1 + \frac{z}{\frac{1}{y + -1}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -inf.0

    1. Initial program 69.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f6469.9%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr69.9%

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

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{z} \]
      2. *-commutativeN/A

        \[\leadsto z \cdot \color{blue}{\left(x \cdot y\right)} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \color{blue}{\left(x \cdot y\right)}\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(z, \left(y \cdot \color{blue}{x}\right)\right) \]
      5. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(y, \color{blue}{x}\right)\right) \]
    7. Simplified100.0%

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

    if -inf.0 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 9.99999999999999982e108

    1. Initial program 99.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr100.0%

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

    if 9.99999999999999982e108 < (*.f64 (-.f64 #s(literal 1 binary64) y) z)

    1. Initial program 91.4%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f6491.3%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr91.3%

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

      \[\leadsto \color{blue}{x \cdot \left(z \cdot \left(y - 1\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(x \cdot z\right) \cdot \color{blue}{\left(y - 1\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(z \cdot x\right) \cdot \left(\color{blue}{y} - 1\right) \]
      3. associate-*r*N/A

        \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(y - 1\right)\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \color{blue}{\left(x \cdot \left(y - 1\right)\right)}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \color{blue}{\left(y - 1\right)}\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \left(y + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \left(y + -1\right)\right)\right) \]
      8. +-lowering-+.f6499.9%

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(y, \color{blue}{-1}\right)\right)\right) \]
    7. Simplified99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \leq -\infty:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \leq 10^{+109}:\\ \;\;\;\;x \cdot \left(1 + \frac{z}{\frac{1}{y + -1}}\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.4% accurate, 0.3× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -4.99999999999999978e110 or 9.99999999999999982e108 < (*.f64 (-.f64 #s(literal 1 binary64) y) z)

    1. Initial program 90.5%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f6490.5%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr90.5%

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

      \[\leadsto \color{blue}{x \cdot \left(z \cdot \left(y - 1\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(x \cdot z\right) \cdot \color{blue}{\left(y - 1\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(z \cdot x\right) \cdot \left(\color{blue}{y} - 1\right) \]
      3. associate-*r*N/A

        \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(y - 1\right)\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \color{blue}{\left(x \cdot \left(y - 1\right)\right)}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \color{blue}{\left(y - 1\right)}\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \left(y + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \left(y + -1\right)\right)\right) \]
      8. +-lowering-+.f6499.9%

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(y, \color{blue}{-1}\right)\right)\right) \]
    7. Simplified99.9%

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

    if -4.99999999999999978e110 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 9.99999999999999982e108

    1. Initial program 100.0%

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

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

Alternative 3: 98.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x \cdot \left(1 + y \cdot z\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.0) (* x (+ 1.0 (* y z))) 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.0) {
		tmp = x * (1.0 + (y * z));
	} 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.0d0) then
        tmp = x * (1.0d0 + (y * z))
    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.0) {
		tmp = x * (1.0 + (y * z));
	} 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.0:
		tmp = x * (1.0 + (y * z))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(x * Float64(y + -1.0)))
	tmp = 0.0
	if (z <= -1.0)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = Float64(x * Float64(1.0 + Float64(y * z)));
	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.0)
		tmp = x * (1.0 + (y * z));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 1.0], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 91.4%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f6491.4%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr91.4%

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

      \[\leadsto \color{blue}{x \cdot \left(z \cdot \left(y - 1\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(x \cdot z\right) \cdot \color{blue}{\left(y - 1\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(z \cdot x\right) \cdot \left(\color{blue}{y} - 1\right) \]
      3. associate-*r*N/A

        \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(y - 1\right)\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \color{blue}{\left(x \cdot \left(y - 1\right)\right)}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \color{blue}{\left(y - 1\right)}\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \left(y + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \left(y + -1\right)\right)\right) \]
      8. +-lowering-+.f6498.0%

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(y, \color{blue}{-1}\right)\right)\right) \]
    7. Simplified98.0%

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

    if -1 < z < 1

    1. Initial program 99.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f6499.9%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr99.9%

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

      \[\leadsto \color{blue}{y \cdot \left(x \cdot z + \frac{x \cdot \left(1 - z\right)}{y}\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(x \cdot z + \frac{x \cdot \left(1 - z\right)}{y}\right)}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(\frac{x \cdot \left(1 - z\right)}{y} + \color{blue}{x \cdot z}\right)\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x \cdot \frac{1 - z}{y} + \color{blue}{x} \cdot z\right)\right) \]
      4. distribute-lft-outN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x \cdot \color{blue}{\left(\frac{1 - z}{y} + z\right)}\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{1 - z}{y} + z\right)}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\left(\frac{1 - z}{y}\right), \color{blue}{z}\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(1 - z\right), y\right), z\right)\right)\right) \]
      8. --lowering--.f6478.5%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, z\right), y\right), z\right)\right)\right) \]
    7. Simplified78.5%

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

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\color{blue}{\left(\frac{1}{y}\right)}, z\right)\right)\right) \]
    9. Step-by-step derivation
      1. /-lowering-/.f6478.5%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, y\right), z\right)\right)\right) \]
    10. Simplified78.5%

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

      \[\leadsto \color{blue}{x + x \cdot \left(y \cdot z\right)} \]
    12. Step-by-step derivation
      1. *-rgt-identityN/A

        \[\leadsto x \cdot 1 + \color{blue}{x} \cdot \left(y \cdot z\right) \]
      2. distribute-lft-inN/A

        \[\leadsto x \cdot \color{blue}{\left(1 + y \cdot z\right)} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 + y \cdot z\right)}\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \left(y \cdot z + \color{blue}{1}\right)\right) \]
      5. +-lowering-+.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, z\right), 1\right)\right) \]
    13. Simplified99.5%

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

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

Alternative 4: 95.0% accurate, 0.5× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.25 or 2.80000000000000019e-7 < y

    1. Initial program 90.3%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f6490.3%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr90.3%

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

      \[\leadsto \color{blue}{y \cdot \left(x \cdot z + \frac{x \cdot \left(1 - z\right)}{y}\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(x \cdot z + \frac{x \cdot \left(1 - z\right)}{y}\right)}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(\frac{x \cdot \left(1 - z\right)}{y} + \color{blue}{x \cdot z}\right)\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x \cdot \frac{1 - z}{y} + \color{blue}{x} \cdot z\right)\right) \]
      4. distribute-lft-outN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x \cdot \color{blue}{\left(\frac{1 - z}{y} + z\right)}\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{1 - z}{y} + z\right)}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\left(\frac{1 - z}{y}\right), \color{blue}{z}\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(1 - z\right), y\right), z\right)\right)\right) \]
      8. --lowering--.f6489.6%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, z\right), y\right), z\right)\right)\right) \]
    7. Simplified89.6%

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

      \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\color{blue}{\left(\frac{1}{y}\right)}, z\right)\right)\right) \]
    9. Step-by-step derivation
      1. /-lowering-/.f6488.4%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{/.f64}\left(1, y\right), z\right)\right)\right) \]
    10. Simplified88.4%

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

      \[\leadsto \color{blue}{x + x \cdot \left(y \cdot z\right)} \]
    12. Step-by-step derivation
      1. *-rgt-identityN/A

        \[\leadsto x \cdot 1 + \color{blue}{x} \cdot \left(y \cdot z\right) \]
      2. distribute-lft-inN/A

        \[\leadsto x \cdot \color{blue}{\left(1 + y \cdot z\right)} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 + y \cdot z\right)}\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \left(y \cdot z + \color{blue}{1}\right)\right) \]
      5. +-lowering-+.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, z\right), 1\right)\right) \]
    13. Simplified89.1%

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

    if -3.25 < y < 2.80000000000000019e-7

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 - z\right)}\right) \]
      2. --lowering--.f6499.3%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \color{blue}{z}\right)\right) \]
    5. Simplified99.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.25:\\ \;\;\;\;x \cdot \left(1 + y \cdot z\right)\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-7}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.4% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 88.0%

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

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(y \cdot z\right)}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \left(z \cdot \color{blue}{y}\right)\right) \]
      3. *-lowering-*.f6471.1%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(z, \color{blue}{y}\right)\right) \]
    5. Simplified71.1%

      \[\leadsto \color{blue}{x \cdot \left(z \cdot y\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(x \cdot z\right) \cdot \color{blue}{y} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(x \cdot z\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f6481.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, z\right), y\right) \]
    7. Applied egg-rr81.3%

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

    if -1.49999999999999988e86 < y < 270

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 - z\right)}\right) \]
      2. --lowering--.f6495.1%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \color{blue}{z}\right)\right) \]
    5. Simplified95.1%

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

    if 270 < y

    1. Initial program 88.8%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f6488.8%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr88.8%

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

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{z} \]
      2. *-commutativeN/A

        \[\leadsto z \cdot \color{blue}{\left(x \cdot y\right)} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \color{blue}{\left(x \cdot y\right)}\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(z, \left(y \cdot \color{blue}{x}\right)\right) \]
      5. *-lowering-*.f6476.5%

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(y, \color{blue}{x}\right)\right) \]
    7. Simplified76.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+86}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;y \leq 270:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.4% accurate, 0.6× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 88.4%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \color{blue}{\left(1 - y\right)}\right)\right)\right) \]
      2. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1 \cdot 1 - y \cdot y}{\color{blue}{1 + y}}\right)\right)\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(z \cdot \frac{1}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \left(\frac{z}{\color{blue}{\frac{1 + y}{1 \cdot 1 - y \cdot y}}}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{1 + y}{1 \cdot 1 - y \cdot y}\right)}\right)\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 + y}}}\right)\right)\right)\right) \]
      7. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \left(\frac{1}{1 - \color{blue}{y}}\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \color{blue}{\left(1 - y\right)}\right)\right)\right)\right) \]
      9. --lowering--.f6488.4%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(1, \color{blue}{y}\right)\right)\right)\right)\right) \]
    4. Applied egg-rr88.4%

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

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{z} \]
      2. *-commutativeN/A

        \[\leadsto z \cdot \color{blue}{\left(x \cdot y\right)} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(z, \color{blue}{\left(x \cdot y\right)}\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(z, \left(y \cdot \color{blue}{x}\right)\right) \]
      5. *-lowering-*.f6479.0%

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(y, \color{blue}{x}\right)\right) \]
    7. Simplified79.0%

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

    if -8.19999999999999957e85 < y < 1.80000000000000004

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 - z\right)}\right) \]
      2. --lowering--.f6495.1%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \color{blue}{z}\right)\right) \]
    5. Simplified95.1%

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

Alternative 7: 83.4% accurate, 0.6× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 88.4%

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

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(y \cdot z\right)}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \left(z \cdot \color{blue}{y}\right)\right) \]
      3. *-lowering-*.f6469.2%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(z, \color{blue}{y}\right)\right) \]
    5. Simplified69.2%

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

    if -5.79999999999999995e85 < y < 2

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 - z\right)}\right) \]
      2. --lowering--.f6495.1%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, \color{blue}{z}\right)\right) \]
    5. Simplified95.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+85}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;y \leq 2:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 57.0% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \leq 2.8 \cdot 10^{-110}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.79999999999999988e-12 or 2.8e-110 < z

    1. Initial program 92.4%

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

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(y \cdot z\right)}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \left(z \cdot \color{blue}{y}\right)\right) \]
      3. *-lowering-*.f6447.0%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(z, \color{blue}{y}\right)\right) \]
    5. Simplified47.0%

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

    if -7.79999999999999988e-12 < z < 2.8e-110

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x} \]
    4. Step-by-step derivation
      1. Simplified87.4%

        \[\leadsto \color{blue}{x} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification61.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{-12}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \end{array} \]
    7. Add Preprocessing

    Alternative 9: 36.9% accurate, 9.0× speedup?

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

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

      \[\leadsto \color{blue}{x} \]
    4. Step-by-step derivation
      1. Simplified37.1%

        \[\leadsto \color{blue}{x} \]
      2. Add Preprocessing

      Developer Target 1: 99.7% accurate, 0.2× 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 2024161 
      (FPCore (x y z)
        :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
        :precision binary64
      
        :alt
        (! :herbie-platform default (if (< (* x (- 1 (* (- 1 y) z))) -161819597360704900000000000000000000000000000000000) (+ x (* (- 1 y) (* (- z) x))) (if (< (* x (- 1 (* (- 1 y) z))) 389223764966390300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1 y) (* (- z) x))))))
      
        (* x (- 1.0 (* (- 1.0 y) z))))