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

Percentage Accurate: 95.9% → 99.1%
Time: 9.6s
Alternatives: 14
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 14 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.9% 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.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - y\right) \cdot z\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+186}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{elif}\;t\_0 \leq 10^{+289}:\\ \;\;\;\;x + x \cdot \left(y \cdot z - z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{1}{\mathsf{fma}\left(x, y, x\right)}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (- 1.0 y) z)))
   (if (<= t_0 -1e+186)
     (* z (* x (+ y -1.0)))
     (if (<= t_0 1e+289)
       (+ x (* x (- (* y z) z)))
       (+ x (/ z (/ 1.0 (fma x y x))))))))
double code(double x, double y, double z) {
	double t_0 = (1.0 - y) * z;
	double tmp;
	if (t_0 <= -1e+186) {
		tmp = z * (x * (y + -1.0));
	} else if (t_0 <= 1e+289) {
		tmp = x + (x * ((y * z) - z));
	} else {
		tmp = x + (z / (1.0 / fma(x, y, x)));
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(1.0 - y) * z)
	tmp = 0.0
	if (t_0 <= -1e+186)
		tmp = Float64(z * Float64(x * Float64(y + -1.0)));
	elseif (t_0 <= 1e+289)
		tmp = Float64(x + Float64(x * Float64(Float64(y * z) - z)));
	else
		tmp = Float64(x + Float64(z / Float64(1.0 / fma(x, y, x))));
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+186], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+289], N[(x + N[(x * N[(N[(y * z), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z / N[(1.0 / N[(x * y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

    if -9.9999999999999998e185 < (*.f64 (-.f64 1 y) z) < 1.0000000000000001e289

    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. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

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

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

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

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

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

    if 1.0000000000000001e289 < (*.f64 (-.f64 1 y) z)

    1. Initial program 58.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x + z \cdot \color{blue}{\frac{\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(-x\right) \cdot \left(-x\right)}{x \cdot y - \left(-x\right)}} \]
      9. associate-*r/44.0%

        \[\leadsto x + \color{blue}{\frac{z \cdot \left(\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(-x\right) \cdot \left(-x\right)\right)}{x \cdot y - \left(-x\right)}} \]
      10. add-sqr-sqrt24.8%

        \[\leadsto x + \frac{z \cdot \left(\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(-x\right) \cdot \left(-x\right)\right)}{x \cdot y - \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}} \]
      11. sqrt-unprod44.0%

        \[\leadsto x + \frac{z \cdot \left(\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(-x\right) \cdot \left(-x\right)\right)}{x \cdot y - \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}} \]
      12. sqr-neg44.0%

        \[\leadsto x + \frac{z \cdot \left(\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(-x\right) \cdot \left(-x\right)\right)}{x \cdot y - \sqrt{\color{blue}{x \cdot x}}} \]
      13. sqrt-unprod19.2%

        \[\leadsto x + \frac{z \cdot \left(\left(x \cdot y\right) \cdot \left(x \cdot y\right) - \left(-x\right) \cdot \left(-x\right)\right)}{x \cdot y - \color{blue}{\sqrt{x} \cdot \sqrt{x}}} \]
      14. add-sqr-sqrt44.0%

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

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

      \[\leadsto x + \color{blue}{\frac{z \cdot {\left(\mathsf{fma}\left(x, y, x\right)\right)}^{2}}{\mathsf{fma}\left(x, y, x\right)}} \]
    10. Step-by-step derivation
      1. associate-/l*56.2%

        \[\leadsto x + \color{blue}{\frac{z}{\frac{\mathsf{fma}\left(x, y, x\right)}{{\left(\mathsf{fma}\left(x, y, x\right)\right)}^{2}}}} \]
      2. unpow256.2%

        \[\leadsto x + \frac{z}{\frac{\mathsf{fma}\left(x, y, x\right)}{\color{blue}{\mathsf{fma}\left(x, y, x\right) \cdot \mathsf{fma}\left(x, y, x\right)}}} \]
      3. associate-/r*62.3%

        \[\leadsto x + \frac{z}{\color{blue}{\frac{\frac{\mathsf{fma}\left(x, y, x\right)}{\mathsf{fma}\left(x, y, x\right)}}{\mathsf{fma}\left(x, y, x\right)}}} \]
      4. *-inverses99.8%

        \[\leadsto x + \frac{z}{\frac{\color{blue}{1}}{\mathsf{fma}\left(x, y, x\right)}} \]
    11. Simplified99.8%

      \[\leadsto x + \color{blue}{\frac{z}{\frac{1}{\mathsf{fma}\left(x, y, x\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.9%

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

Alternative 2: 61.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(-x\right)\\ t_1 := x \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -2.1 \cdot 10^{+169}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-48}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-82}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-36}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-14}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+122} \lor \neg \left(z \leq 6.8 \cdot 10^{+212}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (- x))) (t_1 (* x (* y z))))
   (if (<= z -2.1e+169)
     t_0
     (if (<= z -2.25e-48)
       t_1
       (if (<= z 4.6e-82)
         x
         (if (<= z 8e-36)
           t_1
           (if (<= z 1.65e-14)
             x
             (if (or (<= z 1.9e+122) (not (<= z 6.8e+212))) t_1 t_0))))))))
double code(double x, double y, double z) {
	double t_0 = z * -x;
	double t_1 = x * (y * z);
	double tmp;
	if (z <= -2.1e+169) {
		tmp = t_0;
	} else if (z <= -2.25e-48) {
		tmp = t_1;
	} else if (z <= 4.6e-82) {
		tmp = x;
	} else if (z <= 8e-36) {
		tmp = t_1;
	} else if (z <= 1.65e-14) {
		tmp = x;
	} else if ((z <= 1.9e+122) || !(z <= 6.8e+212)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = z * -x
    t_1 = x * (y * z)
    if (z <= (-2.1d+169)) then
        tmp = t_0
    else if (z <= (-2.25d-48)) then
        tmp = t_1
    else if (z <= 4.6d-82) then
        tmp = x
    else if (z <= 8d-36) then
        tmp = t_1
    else if (z <= 1.65d-14) then
        tmp = x
    else if ((z <= 1.9d+122) .or. (.not. (z <= 6.8d+212))) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * -x;
	double t_1 = x * (y * z);
	double tmp;
	if (z <= -2.1e+169) {
		tmp = t_0;
	} else if (z <= -2.25e-48) {
		tmp = t_1;
	} else if (z <= 4.6e-82) {
		tmp = x;
	} else if (z <= 8e-36) {
		tmp = t_1;
	} else if (z <= 1.65e-14) {
		tmp = x;
	} else if ((z <= 1.9e+122) || !(z <= 6.8e+212)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * -x
	t_1 = x * (y * z)
	tmp = 0
	if z <= -2.1e+169:
		tmp = t_0
	elif z <= -2.25e-48:
		tmp = t_1
	elif z <= 4.6e-82:
		tmp = x
	elif z <= 8e-36:
		tmp = t_1
	elif z <= 1.65e-14:
		tmp = x
	elif (z <= 1.9e+122) or not (z <= 6.8e+212):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(-x))
	t_1 = Float64(x * Float64(y * z))
	tmp = 0.0
	if (z <= -2.1e+169)
		tmp = t_0;
	elseif (z <= -2.25e-48)
		tmp = t_1;
	elseif (z <= 4.6e-82)
		tmp = x;
	elseif (z <= 8e-36)
		tmp = t_1;
	elseif (z <= 1.65e-14)
		tmp = x;
	elseif ((z <= 1.9e+122) || !(z <= 6.8e+212))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * -x;
	t_1 = x * (y * z);
	tmp = 0.0;
	if (z <= -2.1e+169)
		tmp = t_0;
	elseif (z <= -2.25e-48)
		tmp = t_1;
	elseif (z <= 4.6e-82)
		tmp = x;
	elseif (z <= 8e-36)
		tmp = t_1;
	elseif (z <= 1.65e-14)
		tmp = x;
	elseif ((z <= 1.9e+122) || ~((z <= 6.8e+212)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.1e+169], t$95$0, If[LessEqual[z, -2.25e-48], t$95$1, If[LessEqual[z, 4.6e-82], x, If[LessEqual[z, 8e-36], t$95$1, If[LessEqual[z, 1.65e-14], x, If[Or[LessEqual[z, 1.9e+122], N[Not[LessEqual[z, 6.8e+212]], $MachinePrecision]], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.25 \cdot 10^{-48}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 4.6 \cdot 10^{-82}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 8 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.65 \cdot 10^{-14}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 1.9 \cdot 10^{+122} \lor \neg \left(z \leq 6.8 \cdot 10^{+212}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.1000000000000001e169 or 1.8999999999999999e122 < z < 6.80000000000000073e212

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

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

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

    if -2.1000000000000001e169 < z < -2.24999999999999994e-48 or 4.59999999999999994e-82 < z < 7.9999999999999995e-36 or 1.6499999999999999e-14 < z < 1.8999999999999999e122 or 6.80000000000000073e212 < z

    1. Initial program 92.7%

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

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

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

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

    if -2.24999999999999994e-48 < z < 4.59999999999999994e-82 or 7.9999999999999995e-36 < z < 1.6499999999999999e-14

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.1 \cdot 10^{+169}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-48}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-82}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-36}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-14}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+122} \lor \neg \left(z \leq 6.8 \cdot 10^{+212}\right):\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 86.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{if}\;z \leq -105000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-82}:\\ \;\;\;\;x - z \cdot x\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-35}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 2.1:\\ \;\;\;\;x \cdot \left(1 - 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 -105000.0)
     t_0
     (if (<= z 4.6e-82)
       (- x (* z x))
       (if (<= z 1.2e-35)
         (* x (* y z))
         (if (<= z 2.1) (* x (- 1.0 z)) t_0))))))
double code(double x, double y, double z) {
	double t_0 = z * (x * (y + -1.0));
	double tmp;
	if (z <= -105000.0) {
		tmp = t_0;
	} else if (z <= 4.6e-82) {
		tmp = x - (z * x);
	} else if (z <= 1.2e-35) {
		tmp = x * (y * z);
	} else if (z <= 2.1) {
		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 * (x * (y + (-1.0d0)))
    if (z <= (-105000.0d0)) then
        tmp = t_0
    else if (z <= 4.6d-82) then
        tmp = x - (z * x)
    else if (z <= 1.2d-35) then
        tmp = x * (y * z)
    else if (z <= 2.1d0) 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 * (x * (y + -1.0));
	double tmp;
	if (z <= -105000.0) {
		tmp = t_0;
	} else if (z <= 4.6e-82) {
		tmp = x - (z * x);
	} else if (z <= 1.2e-35) {
		tmp = x * (y * z);
	} else if (z <= 2.1) {
		tmp = x * (1.0 - z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * (x * (y + -1.0))
	tmp = 0
	if z <= -105000.0:
		tmp = t_0
	elif z <= 4.6e-82:
		tmp = x - (z * x)
	elif z <= 1.2e-35:
		tmp = x * (y * z)
	elif z <= 2.1:
		tmp = x * (1.0 - 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 <= -105000.0)
		tmp = t_0;
	elseif (z <= 4.6e-82)
		tmp = Float64(x - Float64(z * x));
	elseif (z <= 1.2e-35)
		tmp = Float64(x * Float64(y * z));
	elseif (z <= 2.1)
		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 * (x * (y + -1.0));
	tmp = 0.0;
	if (z <= -105000.0)
		tmp = t_0;
	elseif (z <= 4.6e-82)
		tmp = x - (z * x);
	elseif (z <= 1.2e-35)
		tmp = x * (y * z);
	elseif (z <= 2.1)
		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[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -105000.0], t$95$0, If[LessEqual[z, 4.6e-82], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e-35], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1], N[(x * N[(1.0 - z), $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 -105000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 4.6 \cdot 10^{-82}:\\
\;\;\;\;x - z \cdot x\\

\mathbf{elif}\;z \leq 1.2 \cdot 10^{-35}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\

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

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


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

    1. Initial program 89.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)} \]
    4. Step-by-step derivation
      1. *-commutative89.6%

        \[\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. *-commutative99.8%

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

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

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

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

    if -105000 < z < 4.59999999999999994e-82

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

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

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

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

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

      \[\leadsto \color{blue}{x + \left(-z\right) \cdot x} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-out80.1%

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

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

        \[\leadsto \color{blue}{x - x \cdot z} \]
    7. Applied egg-rr80.1%

      \[\leadsto \color{blue}{x - x \cdot z} \]

    if 4.59999999999999994e-82 < z < 1.2000000000000001e-35

    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 inf 87.8%

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

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

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

    if 1.2000000000000001e-35 < z < 2.10000000000000009

    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 0 77.8%

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

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

Alternative 4: 86.4% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;z \leq 8 \cdot 10^{-89}:\\
\;\;\;\;x - z \cdot x\\

\mathbf{elif}\;z \leq 9.8 \cdot 10^{-36}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -105000 < z < 8.00000000000000031e-89

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

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

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

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

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

      \[\leadsto \color{blue}{x + \left(-z\right) \cdot x} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-out80.1%

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

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

        \[\leadsto \color{blue}{x - x \cdot z} \]
    7. Applied egg-rr80.1%

      \[\leadsto \color{blue}{x - x \cdot z} \]

    if 8.00000000000000031e-89 < z < 9.7999999999999994e-36

    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 inf 87.8%

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

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

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

    if 9.7999999999999994e-36 < z < 0.112000000000000002

    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 0 77.8%

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

    if 0.112000000000000002 < z

    1. Initial program 86.5%

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

      \[\leadsto \color{blue}{x \cdot \left(z \cdot \left(y - 1\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutative86.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. *-commutative99.8%

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

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

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

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

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

Alternative 5: 99.8% accurate, 0.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 1 y) z) < -9.9999999999999998e185 or 4.9999999999999995e201 < (*.f64 (-.f64 1 y) z)

    1. Initial program 84.3%

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

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

        \[\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. *-commutative99.8%

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

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

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

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

    if -9.9999999999999998e185 < (*.f64 (-.f64 1 y) z) < 4.9999999999999995e201

    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. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

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

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

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

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

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

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

Alternative 6: 99.7% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 10^{+77}:\\
\;\;\;\;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}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.00000000000000009e25

    1. Initial program 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000009e25 < z < 9.99999999999999983e76

    1. Initial program 99.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing

    if 9.99999999999999983e76 < z

    1. Initial program 80.2%

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

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

        \[\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. *-commutative99.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+25}:\\ \;\;\;\;z \cdot \left(y \cdot x - x\right)\\ \mathbf{elif}\;z \leq 10^{+77}:\\ \;\;\;\;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 7: 99.7% accurate, 0.5× speedup?

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

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

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

\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 z < -5.0000000000000001e29

    1. Initial program 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000001e29 < z < 9.99999999999999983e76

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

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

    if 9.99999999999999983e76 < z

    1. Initial program 80.2%

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

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

        \[\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. *-commutative99.8%

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

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

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

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

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

Alternative 8: 98.6% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 7400000:\\
\;\;\;\;x + x \cdot \left(y \cdot z\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 z < -0.97999999999999998

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.97999999999999998 < z < 7.4e6

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

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

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

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

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

    if 7.4e6 < z

    1. Initial program 85.6%

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

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

        \[\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. *-commutative99.8%

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

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

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

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

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

Alternative 9: 83.2% accurate, 0.6× speedup?

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

    1. Initial program 88.9%

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

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

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

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

    if -4.44999999999999988e42 < y < 1.55e6

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

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

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

Alternative 10: 85.4% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 88.9%

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

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

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

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

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

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

    if -1.12e42 < y < 4300

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

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

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

Alternative 11: 85.5% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 88.9%

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

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

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

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

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

    if -1.1999999999999999e42 < y < 31500

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

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

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

Alternative 12: 85.5% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 88.9%

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

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

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

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

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

    if -9.4999999999999996e41 < y < 3850

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

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

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

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

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

      \[\leadsto \color{blue}{x + \left(-z\right) \cdot x} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-out94.5%

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

        \[\leadsto x + \left(-\color{blue}{x \cdot z}\right) \]
      3. unsub-neg94.5%

        \[\leadsto \color{blue}{x - x \cdot z} \]
    7. Applied egg-rr94.5%

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

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

Alternative 13: 65.1% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

    if -1 < z < 7.5999999999999996

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

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

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

Alternative 14: 38.5% accurate, 9.0× speedup?

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

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

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification34.9%

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