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

Percentage Accurate: 96.1% → 97.2%
Time: 10.7s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 96.1% accurate, 1.0× speedup?

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

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

Alternative 1: 97.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - y \leq -15000000000:\\ \;\;\;\;\left(x \cdot z\right) \cdot \left(y + -2\right) + x \cdot \left(1 + z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(y + -1\right), x, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (- 1.0 y) -15000000000.0)
   (+ (* (* x z) (+ y -2.0)) (* x (+ 1.0 z)))
   (fma (* z (+ y -1.0)) x x)))
double code(double x, double y, double z) {
	double tmp;
	if ((1.0 - y) <= -15000000000.0) {
		tmp = ((x * z) * (y + -2.0)) + (x * (1.0 + z));
	} else {
		tmp = fma((z * (y + -1.0)), x, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (Float64(1.0 - y) <= -15000000000.0)
		tmp = Float64(Float64(Float64(x * z) * Float64(y + -2.0)) + Float64(x * Float64(1.0 + z)));
	else
		tmp = fma(Float64(z * Float64(y + -1.0)), x, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[N[(1.0 - y), $MachinePrecision], -15000000000.0], N[(N[(N[(x * z), $MachinePrecision] * N[(y + -2.0), $MachinePrecision]), $MachinePrecision] + N[(x * N[(1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 1 y) < -1.5e10

    1. Initial program 87.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative87.9%

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

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

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

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

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

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

        \[\leadsto \frac{\left(1 - {\left(\left(1 - y\right) \cdot z\right)}^{2}\right) \cdot x}{\color{blue}{\mathsf{fma}\left(1 - y, z, 1\right)}} \]
    4. Applied egg-rr60.7%

      \[\leadsto \color{blue}{\frac{\left(1 - {\left(\left(1 - y\right) \cdot z\right)}^{2}\right) \cdot x}{\mathsf{fma}\left(1 - y, z, 1\right)}} \]
    5. Taylor expanded in y around inf 72.0%

      \[\leadsto \color{blue}{\left(-2 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right) - -1 \cdot \left(x \cdot \left(1 + z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg72.0%

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

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

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

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

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

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

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

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

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

    if -1.5e10 < (-.f64 1 y)

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

Alternative 2: 64.3% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq 1.25 \cdot 10^{-59}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 3.2 \cdot 10^{+103}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\

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


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

    1. Initial program 92.3%

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

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

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

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

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

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

    if -1 < z < 1.25e-59

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

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

    if 1.25e-59 < z < 3.19999999999999993e103

    1. Initial program 99.8%

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

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

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

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

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

Alternative 3: 97.2% accurate, 0.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 1 y) < -1.5e10

    1. Initial program 87.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative87.9%

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

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

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

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

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

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

        \[\leadsto \frac{\left(1 - {\left(\left(1 - y\right) \cdot z\right)}^{2}\right) \cdot x}{\color{blue}{\mathsf{fma}\left(1 - y, z, 1\right)}} \]
    4. Applied egg-rr60.7%

      \[\leadsto \color{blue}{\frac{\left(1 - {\left(\left(1 - y\right) \cdot z\right)}^{2}\right) \cdot x}{\mathsf{fma}\left(1 - y, z, 1\right)}} \]
    5. Taylor expanded in y around inf 72.0%

      \[\leadsto \color{blue}{\left(-2 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right) - -1 \cdot \left(x \cdot \left(1 + z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg72.0%

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

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

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

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

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

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

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

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

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

    if -1.5e10 < (-.f64 1 y)

    1. Initial program 98.9%

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

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

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

Alternative 4: 97.6% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 91.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999976e73 < (*.f64 (-.f64 1 y) z)

    1. Initial program 97.9%

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

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

Alternative 5: 82.4% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.7e5 or 3.79999999999999994e-60 < z

    1. Initial program 93.6%

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

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

    if -1.7e5 < z < 3.79999999999999994e-60

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

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

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

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

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

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

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

Alternative 6: 87.0% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.7e5 or 4.4999999999999999e-4 < z

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \left(x \cdot \color{blue}{\left(0 - \left(1 - y\right)\right)}\right) \]
      12. associate--r-99.4%

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

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

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

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

    if -1.7e5 < z < 4.4999999999999999e-4

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 7: 87.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 1.08 \cdot 10^{-5}:\\
\;\;\;\;x - x \cdot z\\

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


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

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(-\left(1 - y\right)\right)\right)} \]
      11. neg-sub099.0%

        \[\leadsto z \cdot \left(x \cdot \color{blue}{\left(0 - \left(1 - y\right)\right)}\right) \]
      12. associate--r-99.0%

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

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

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

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

    if -2.1e5 < z < 1.07999999999999999e-5

    1. Initial program 99.9%

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

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

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

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

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

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

    if 1.07999999999999999e-5 < z

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(-\left(1 - y\right)\right)\right)} \]
      11. neg-sub099.8%

        \[\leadsto z \cdot \left(x \cdot \color{blue}{\left(0 - \left(1 - y\right)\right)}\right) \]
      12. associate--r-99.8%

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

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

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

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

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

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

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

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

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

Alternative 8: 87.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 1.35 \cdot 10^{-6}:\\
\;\;\;\;x - x \cdot z\\

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


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

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.3e5 < z < 1.34999999999999999e-6

    1. Initial program 99.9%

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

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

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

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

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

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

    if 1.34999999999999999e-6 < z

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(-\left(1 - y\right)\right)\right)} \]
      11. neg-sub099.8%

        \[\leadsto z \cdot \left(x \cdot \color{blue}{\left(0 - \left(1 - y\right)\right)}\right) \]
      12. associate--r-99.8%

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

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

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

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

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

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

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

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

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

Alternative 9: 98.9% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.1499999999999999 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

    if 1 < z

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(-\left(1 - y\right)\right)\right)} \]
      11. neg-sub099.8%

        \[\leadsto z \cdot \left(x \cdot \color{blue}{\left(0 - \left(1 - y\right)\right)}\right) \]
      12. associate--r-99.8%

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

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

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

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

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

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

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

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

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

Alternative 10: 98.9% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + -1\right) \cdot \left(x \cdot z\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. Taylor expanded in y around inf 99.3%

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

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

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

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

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

    if 1 < z

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(-\left(1 - y\right)\right)\right)} \]
      11. neg-sub099.8%

        \[\leadsto z \cdot \left(x \cdot \color{blue}{\left(0 - \left(1 - y\right)\right)}\right) \]
      12. associate--r-99.8%

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

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

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

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

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

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

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

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

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

Alternative 11: 83.3% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.00000000000000025e83 or 4.8e14 < y

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

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

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

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

    if -8.00000000000000025e83 < y < 4.8e14

    1. Initial program 98.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{+83} \lor \neg \left(y \leq 4.8 \cdot 10^{+14}\right):\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 84.4% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 95.2%

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

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

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

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

    if -2.29999999999999995e83 < y < 1.5e10

    1. Initial program 99.9%

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

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

    if 1.5e10 < y

    1. Initial program 87.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 84.4% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y \leq 15500000000:\\
\;\;\;\;x - x \cdot z\\

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


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

    1. Initial program 95.2%

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

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

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

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

    if -1.70000000000000002e88 < y < 1.55e10

    1. Initial program 99.9%

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

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

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

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

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

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

    if 1.55e10 < y

    1. Initial program 87.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 65.1% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 93.2%

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(-z\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. Taylor expanded in z around 0 78.0%

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

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

Alternative 15: 38.8% accurate, 9.0× speedup?

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

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

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification36.6%

    \[\leadsto x \]
  5. Add Preprocessing

Developer target: 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 2024040 
(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))))