Average Error: 3.4 → 0.1
Time: 3.2s
Precision: binary64
\[ \begin{array}{c}[y, z] = \mathsf{sort}([y, z])\\ \end{array} \]
\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+277}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+242}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(z, -y, 1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* z (- x)))))
   (if (<= (* y z) -2e+277)
     t_0
     (if (<= (* y z) 2e+242) (* x (fma z (- y) 1.0)) t_0))))
double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
double code(double x, double y, double z) {
	double t_0 = y * (z * -x);
	double tmp;
	if ((y * z) <= -2e+277) {
		tmp = t_0;
	} else if ((y * z) <= 2e+242) {
		tmp = x * fma(z, -y, 1.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(y * z)))
end
function code(x, y, z)
	t_0 = Float64(y * Float64(z * Float64(-x)))
	tmp = 0.0
	if (Float64(y * z) <= -2e+277)
		tmp = t_0;
	elseif (Float64(y * z) <= 2e+242)
		tmp = Float64(x * fma(z, Float64(-y), 1.0));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -2e+277], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 2e+242], N[(x * N[(z * (-y) + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+277}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+242}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(z, -y, 1\right)\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 y z) < -2.00000000000000001e277 or 2.0000000000000001e242 < (*.f64 y z)

    1. Initial program 41.8

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

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

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

    if -2.00000000000000001e277 < (*.f64 y z) < 2.0000000000000001e242

    1. Initial program 0.1

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Applied egg-rr1.4

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{1 - y \cdot z}\right)}^{2} \cdot \left(\sqrt[3]{1 - y \cdot z} \cdot x\right)} \]
    4. Applied egg-rr0.1

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

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

Reproduce

herbie shell --seed 2022160 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
  :precision binary64
  (* x (- 1.0 (* y z))))