Average Error: 3.5 → 1.9
Time: 2.5s
Precision: binary64
\[ \begin{array}{c}[y, z] = \mathsf{sort}([y, z])\\ \end{array} \]
\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+230}:\\ \;\;\;\;x - y \cdot \left(z \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(y \cdot z\right) \cdot x, -1, x\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) -5e+230) (- x (* y (* z x))) (fma (* (* y z) x) -1.0 x)))
double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= -5e+230) {
		tmp = x - (y * (z * x));
	} else {
		tmp = fma(((y * z) * x), -1.0, x);
	}
	return tmp;
}
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(y * z)))
end
function code(x, y, z)
	tmp = 0.0
	if (Float64(y * z) <= -5e+230)
		tmp = Float64(x - Float64(y * Float64(z * x)));
	else
		tmp = fma(Float64(Float64(y * z) * x), -1.0, x);
	end
	return tmp
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -5e+230], N[(x - N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision] * -1.0 + x), $MachinePrecision]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+230}:\\
\;\;\;\;x - y \cdot \left(z \cdot x\right)\\

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


\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) < -5.0000000000000003e230

    1. Initial program 33.4

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

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

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

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

    if -5.0000000000000003e230 < (*.f64 y z)

    1. Initial program 2.0

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

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

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

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

Reproduce

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