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

Percentage Accurate: 95.7% → 97.7%
Time: 8.7s
Alternatives: 12
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 95.7% 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.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 500000000000:\\ \;\;\;\;x - x \cdot \left(z - 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 500000000000.0) (- x (* x (- z (* y z)))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= 500000000000.0) {
		tmp = x - (x * (z - (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 <= 500000000000.0d0) then
        tmp = x - (x * (z - (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 <= 500000000000.0) {
		tmp = x - (x * (z - (y * z)));
	} else {
		tmp = z * (x * (y + -1.0));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= 500000000000.0:
		tmp = x - (x * (z - (y * z)))
	else:
		tmp = z * (x * (y + -1.0))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= 500000000000.0)
		tmp = Float64(x - Float64(x * Float64(z - 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 <= 500000000000.0)
		tmp = x - (x * (z - (y * z)));
	else
		tmp = z * (x * (y + -1.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, 500000000000.0], N[(x - N[(x * N[(z - N[(y * z), $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 500000000000:\\
\;\;\;\;x - x \cdot \left(z - 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 2 regimes
  2. if z < 5e11

    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. sub-neg98.9%

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

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

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

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

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

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

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

    if 5e11 < z

    1. Initial program 89.9%

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(y - 1\right)\right) \cdot x} \]
      2. associate-*r*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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.2%

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

Alternative 2: 98.5% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 93.3%

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(y - 1\right)\right) \cdot x} \]
      2. associate-*r*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 -5.3e12 < z < 1

    1. Initial program 99.8%

      \[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 98.0%

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

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

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

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

Alternative 3: 86.5% accurate, 0.5× speedup?

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

    1. Initial program 93.4%

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(y - 1\right)\right) \cdot x} \]
      2. associate-*r*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 -1.21999999999999997e-4 < z < 1.49999999999999987e-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. Step-by-step derivation
      1. add-cube-cbrt99.7%

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

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

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

        \[\leadsto x + {\left(\sqrt[3]{\color{blue}{\left(y - 1\right) \cdot \left(x \cdot z\right)}}\right)}^{3} \]
      5. sub-neg96.7%

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

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

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

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

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

        \[\leadsto \color{blue}{x - x \cdot z} \]
    8. Simplified77.9%

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

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

Alternative 4: 86.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+15} \lor \neg \left(y \leq 7.6 \cdot 10^{+17}\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\

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


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

    1. Initial program 92.6%

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

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

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

    if -2e15 < y < 7.6e17

    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. Step-by-step derivation
      1. add-cube-cbrt99.3%

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

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

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

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

        \[\leadsto x + {\left(\sqrt[3]{\color{blue}{\left(y + \left(-1\right)\right)} \cdot \left(x \cdot z\right)}\right)}^{3} \]
      6. metadata-eval99.3%

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

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

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

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

        \[\leadsto \color{blue}{x - x \cdot z} \]
    8. Simplified97.0%

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

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

Alternative 5: 86.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+14} \lor \neg \left(y \leq 3.4 \cdot 10^{+18}\right):\\
\;\;\;\;y \cdot \left(x \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 < -2.8e14 or 3.4e18 < y

    1. Initial program 92.6%

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

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

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

    if -2.8e14 < y < 3.4e18

    1. Initial program 100.0%

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

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

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

Alternative 6: 83.0% accurate, 0.6× speedup?

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

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

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

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

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

    if -4.2e14 < y < 2.8e82

    1. Initial program 99.3%

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

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

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

Alternative 7: 64.2% 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.4%

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(y - 1\right)\right) \cdot x} \]
      2. associate-*r*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 54.0%

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

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

      \[\leadsto z \cdot \color{blue}{\left(-x\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 76.2%

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

    \[\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 8: 61.5% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\

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


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

    1. Initial program 97.0%

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

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

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

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

    if -3.40000000000000015e-10 < 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 77.3%

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

    if 1 < z

    1. Initial program 89.9%

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(y - 1\right)\right) \cdot x} \]
      2. associate-*r*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 59.2%

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

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

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

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

Alternative 9: 97.7% accurate, 0.6× speedup?

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

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


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

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

    if 5e11 < z

    1. Initial program 89.9%

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(y - 1\right)\right) \cdot x} \]
      2. associate-*r*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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.2%

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

Alternative 10: 97.7% accurate, 0.6× speedup?

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

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


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

    1. Initial program 98.9%

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

    if 5e11 < z

    1. Initial program 89.9%

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(y - 1\right)\right) \cdot x} \]
      2. associate-*r*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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.1%

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

Alternative 11: 98.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x + \color{blue}{{\left(\sqrt[3]{\left(y + -1\right) \cdot \left(x \cdot z\right)}\right)}^{3}} \]
  6. Step-by-step derivation
    1. rem-cube-cbrt98.4%

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

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

Alternative 12: 37.4% 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.6%

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

    \[\leadsto \color{blue}{x} \]
  4. 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 2024106 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
  :precision binary64

  :alt
  (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))))