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

Percentage Accurate: 95.6% → 98.4%
Time: 8.1s
Alternatives: 12
Speedup: 0.8×

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.6% 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: 98.4% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 89.6%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Step-by-step derivation
      1. *-commutative89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0600000000000001 < z < 1.55e17

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

Alternative 2: 63.7% accurate, 0.5× 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 -3.2 \cdot 10^{+185}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.1 \cdot 10^{+95}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+88}:\\ \;\;\;\;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 -3.2e+185)
     t_0
     (if (<= z -1.1e+153)
       t_1
       (if (<= z -5.1e+95)
         t_0
         (if (<= z -6.8e-69)
           t_1
           (if (<= z 6.8e-13) x (if (<= z 5.5e+88) 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 <= -3.2e+185) {
		tmp = t_0;
	} else if (z <= -1.1e+153) {
		tmp = t_1;
	} else if (z <= -5.1e+95) {
		tmp = t_0;
	} else if (z <= -6.8e-69) {
		tmp = t_1;
	} else if (z <= 6.8e-13) {
		tmp = x;
	} else if (z <= 5.5e+88) {
		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 <= (-3.2d+185)) then
        tmp = t_0
    else if (z <= (-1.1d+153)) then
        tmp = t_1
    else if (z <= (-5.1d+95)) then
        tmp = t_0
    else if (z <= (-6.8d-69)) then
        tmp = t_1
    else if (z <= 6.8d-13) then
        tmp = x
    else if (z <= 5.5d+88) 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 <= -3.2e+185) {
		tmp = t_0;
	} else if (z <= -1.1e+153) {
		tmp = t_1;
	} else if (z <= -5.1e+95) {
		tmp = t_0;
	} else if (z <= -6.8e-69) {
		tmp = t_1;
	} else if (z <= 6.8e-13) {
		tmp = x;
	} else if (z <= 5.5e+88) {
		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 <= -3.2e+185:
		tmp = t_0
	elif z <= -1.1e+153:
		tmp = t_1
	elif z <= -5.1e+95:
		tmp = t_0
	elif z <= -6.8e-69:
		tmp = t_1
	elif z <= 6.8e-13:
		tmp = x
	elif z <= 5.5e+88:
		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 <= -3.2e+185)
		tmp = t_0;
	elseif (z <= -1.1e+153)
		tmp = t_1;
	elseif (z <= -5.1e+95)
		tmp = t_0;
	elseif (z <= -6.8e-69)
		tmp = t_1;
	elseif (z <= 6.8e-13)
		tmp = x;
	elseif (z <= 5.5e+88)
		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 <= -3.2e+185)
		tmp = t_0;
	elseif (z <= -1.1e+153)
		tmp = t_1;
	elseif (z <= -5.1e+95)
		tmp = t_0;
	elseif (z <= -6.8e-69)
		tmp = t_1;
	elseif (z <= 6.8e-13)
		tmp = x;
	elseif (z <= 5.5e+88)
		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, -3.2e+185], t$95$0, If[LessEqual[z, -1.1e+153], t$95$1, If[LessEqual[z, -5.1e+95], t$95$0, If[LessEqual[z, -6.8e-69], t$95$1, If[LessEqual[z, 6.8e-13], x, If[LessEqual[z, 5.5e+88], 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 -3.2 \cdot 10^{+185}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -1.1 \cdot 10^{+153}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -5.1 \cdot 10^{+95}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -6.8 \cdot 10^{-69}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 6.8 \cdot 10^{-13}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 5.5 \cdot 10^{+88}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.20000000000000006e185 or -1.1e153 < z < -5.10000000000000003e95 or 5.5e88 < z

    1. Initial program 88.9%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \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) \]
    4. Simplified99.9%

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

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

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

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

    if -3.20000000000000006e185 < z < -1.1e153 or -5.10000000000000003e95 < z < -6.80000000000000016e-69 or 6.80000000000000031e-13 < z < 5.5e88

    1. Initial program 94.0%

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

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

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

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

    if -6.80000000000000016e-69 < z < 6.80000000000000031e-13

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+185}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{+153}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -5.1 \cdot 10^{+95}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-69}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+88}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \]

Alternative 3: 97.6% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 79.7%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Step-by-step derivation
      1. *-commutative79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e197 < (*.f64 (-.f64 1 y) z)

    1. Initial program 98.6%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Step-by-step derivation
      1. *-commutative98.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 97.3% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999983e66 < (*.f64 (-.f64 1 y) z)

    1. Initial program 98.5%

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

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

Alternative 5: 85.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{-67} \lor \neg \left(z \leq 4.8 \cdot 10^{-13}\right):\\
\;\;\;\;z \cdot \left(\left(y + -1\right) \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.19999999999999998e-67 or 4.7999999999999997e-13 < z

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

    if -7.19999999999999998e-67 < z < 4.7999999999999997e-13

    1. Initial program 99.9%

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

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

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

Alternative 6: 85.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.9 \cdot 10^{-65} \lor \neg \left(z \leq 2.1 \cdot 10^{-11}\right):\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.89999999999999991e-65 or 2.0999999999999999e-11 < z

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.89999999999999991e-65 < z < 2.0999999999999999e-11

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.9 \cdot 10^{-65} \lor \neg \left(z \leq 2.1 \cdot 10^{-11}\right):\\ \;\;\;\;z \cdot \left(y \cdot x - x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]

Alternative 7: 85.5% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 1.6 \cdot 10^{-11}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\

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


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

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.49999999999999981e-66 < z < 1.59999999999999997e-11

    1. Initial program 99.9%

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

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

    if 1.59999999999999997e-11 < z

    1. Initial program 93.6%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Step-by-step derivation
      1. *-commutative93.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 83.0% accurate, 1.0× speedup?

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

    1. Initial program 90.5%

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

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

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

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

    if -2.70000000000000004e115 < y < 2.15e15

    1. Initial program 98.6%

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

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

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

Alternative 9: 85.0% accurate, 1.0× speedup?

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

    1. Initial program 90.5%

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

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

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

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

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

    if -7.80000000000000065e116 < y < 1.9e14

    1. Initial program 98.6%

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

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

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

Alternative 10: 85.0% accurate, 1.0× speedup?

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

    1. Initial program 90.5%

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

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

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

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

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

    if -2.70000000000000011e113 < y < 1.8e15

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{+113} \lor \neg \left(y \leq 1.8 \cdot 10^{+15}\right):\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot x\\ \end{array} \]

Alternative 11: 63.9% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 89.6%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \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) \]
    4. Simplified99.9%

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

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

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

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

    if -29 < z < 8e13

    1. Initial program 99.9%

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

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

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

Alternative 12: 38.7% accurate, 9.0× speedup?

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

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

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification38.0%

    \[\leadsto x \]

Developer target: 99.7% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023310 
(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))))