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

Percentage Accurate: 96.2% → 98.7%
Time: 9.6s
Alternatives: 10
Speedup: 0.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

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

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\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.0) (not (<= z 1.0)))
   (* (+ y -1.0) (* z x))
   (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		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.0d0)) .or. (.not. (z <= 1.0d0))) 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.0) || !(z <= 1.0)) {
		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.0) or not (z <= 1.0):
		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.0) || !(z <= 1.0))
		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.0) || ~((z <= 1.0)))
		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.0], N[Not[LessEqual[z, 1.0]], $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 \lor \neg \left(z \leq 1\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 or 1 < z

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + -1\right) \cdot \left(z \cdot 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 99.9%

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

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

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

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

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

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

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

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

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

Alternative 2: 83.2% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{+122} \lor \neg \left(y \leq -6.3 \cdot 10^{+75} \lor \neg \left(y \leq -1.75 \cdot 10^{+20}\right) \land y \leq 8.4 \cdot 10^{+14}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.9000000000000001e122 or -6.30000000000000036e75 < y < -1.75e20 or 8.4e14 < y

    1. Initial program 89.4%

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

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

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

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

    if -2.9000000000000001e122 < y < -6.30000000000000036e75 or -1.75e20 < y < 8.4e14

    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.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{+122} \lor \neg \left(y \leq -6.3 \cdot 10^{+75} \lor \neg \left(y \leq -1.75 \cdot 10^{+20}\right) \land y \leq 8.4 \cdot 10^{+14}\right):\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 84.2% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq -1.65 \cdot 10^{+74} \lor \neg \left(y \leq -1.06 \cdot 10^{+20}\right) \land y \leq 800000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\

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


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

    1. Initial program 92.9%

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

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

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

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

    if -3.50000000000000014e122 < y < -1.6500000000000001e74 or -1.06e20 < y < 8e11

    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.4%

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

    if -1.6500000000000001e74 < y < -1.06e20 or 8e11 < y

    1. Initial program 87.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+122}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;y \leq -1.65 \cdot 10^{+74} \lor \neg \left(y \leq -1.06 \cdot 10^{+20}\right) \land y \leq 800000000000:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 64.7% accurate, 0.4× 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 -1.25 \cdot 10^{+25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{-85}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-37}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+20}:\\ \;\;\;\;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 -1.25e+25)
     t_0
     (if (<= z -2.9e-85)
       t_1
       (if (<= z 7.2e-37) x (if (<= z 3.4e+20) 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 <= -1.25e+25) {
		tmp = t_0;
	} else if (z <= -2.9e-85) {
		tmp = t_1;
	} else if (z <= 7.2e-37) {
		tmp = x;
	} else if (z <= 3.4e+20) {
		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 <= (-1.25d+25)) then
        tmp = t_0
    else if (z <= (-2.9d-85)) then
        tmp = t_1
    else if (z <= 7.2d-37) then
        tmp = x
    else if (z <= 3.4d+20) 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 <= -1.25e+25) {
		tmp = t_0;
	} else if (z <= -2.9e-85) {
		tmp = t_1;
	} else if (z <= 7.2e-37) {
		tmp = x;
	} else if (z <= 3.4e+20) {
		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 <= -1.25e+25:
		tmp = t_0
	elif z <= -2.9e-85:
		tmp = t_1
	elif z <= 7.2e-37:
		tmp = x
	elif z <= 3.4e+20:
		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 <= -1.25e+25)
		tmp = t_0;
	elseif (z <= -2.9e-85)
		tmp = t_1;
	elseif (z <= 7.2e-37)
		tmp = x;
	elseif (z <= 3.4e+20)
		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 <= -1.25e+25)
		tmp = t_0;
	elseif (z <= -2.9e-85)
		tmp = t_1;
	elseif (z <= 7.2e-37)
		tmp = x;
	elseif (z <= 3.4e+20)
		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, -1.25e+25], t$95$0, If[LessEqual[z, -2.9e-85], t$95$1, If[LessEqual[z, 7.2e-37], x, If[LessEqual[z, 3.4e+20], 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 -1.25 \cdot 10^{+25}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -2.9 \cdot 10^{-85}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 7.2 \cdot 10^{-37}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 3.4 \cdot 10^{+20}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.25000000000000006e25 or 3.4e20 < z

    1. Initial program 90.3%

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

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

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

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

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

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

    if -1.25000000000000006e25 < z < -2.9000000000000002e-85 or 7.20000000000000014e-37 < z < 3.4e20

    1. Initial program 99.7%

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

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

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

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

    if -2.9000000000000002e-85 < z < 7.20000000000000014e-37

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+25}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{-85}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-37}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+20}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.2% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq -5.6 \cdot 10^{+76}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;y \leq 3100000000:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.7499999999999999e122 or 3.1e9 < y

    1. Initial program 89.0%

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

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

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

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

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

    if -2.7499999999999999e122 < y < -5.5999999999999997e76 or -1.3e20 < y < 3.1e9

    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.4%

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

    if -5.5999999999999997e76 < y < -1.3e20

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.75 \cdot 10^{+122}:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \mathbf{elif}\;y \leq -5.6 \cdot 10^{+76}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+20}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;y \leq 3100000000:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 94.9% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;y \leq 3.6 \cdot 10^{+244}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.6e11 or 2.0000000000000001e-4 < y < 3.6e244

    1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

    if -2.6e11 < y < 2.0000000000000001e-4

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

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

    if 3.6e244 < y

    1. Initial program 56.3%

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

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

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

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

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

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

Alternative 7: 98.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \leq -2 \cdot 10^{+218}:\\ \;\;\;\;\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) -2e+218)
   (* (+ 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) <= -2e+218) {
		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) <= (-2d+218)) 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) <= -2e+218) {
		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) <= -2e+218:
		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) <= -2e+218)
		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) <= -2e+218)
		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], -2e+218], 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 -2 \cdot 10^{+218}:\\
\;\;\;\;\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) < -2.00000000000000017e218

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000017e218 < (*.f64 (-.f64 1 y) z)

    1. Initial program 98.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \leq -2 \cdot 10^{+218}:\\ \;\;\;\;\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} \]
  5. Add Preprocessing

Alternative 8: 98.7% accurate, 0.5× speedup?

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

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

    if -1 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

Alternative 9: 64.6% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 91.3%

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

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

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

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

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

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

    if -1 < z < 1

    1. Initial program 99.9%

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

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

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

Alternative 10: 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.5%

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

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

    \[\leadsto x \]
  5. Add Preprocessing

Developer target: 99.6% 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 2024018 
(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))))