Average Error: 3.3 → 2.5
Time: 2.7s
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}\;x \leq -1.6898890574526774 \cdot 10^{-119}:\\ \;\;\;\;\mathsf{fma}\left(-1, x \cdot \left(y \cdot z\right), x\right)\\ \mathbf{elif}\;x \leq 1.0343249380691399 \cdot 10^{-209}:\\ \;\;\;\;x - y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.6898890574526774e-119)
   (fma -1.0 (* x (* y z)) x)
   (if (<= x 1.0343249380691399e-209)
     (- x (* y (* x z)))
     (* x (- 1.0 (* y z))))))
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 (x <= -1.6898890574526774e-119) {
		tmp = fma(-1.0, (x * (y * z)), x);
	} else if (x <= 1.0343249380691399e-209) {
		tmp = x - (y * (x * z));
	} else {
		tmp = x * (1.0 - (y * z));
	}
	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 (x <= -1.6898890574526774e-119)
		tmp = fma(-1.0, Float64(x * Float64(y * z)), x);
	elseif (x <= 1.0343249380691399e-209)
		tmp = Float64(x - Float64(y * Float64(x * z)));
	else
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	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[x, -1.6898890574526774e-119], N[(-1.0 * N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[x, 1.0343249380691399e-209], N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \leq -1.6898890574526774 \cdot 10^{-119}:\\
\;\;\;\;\mathsf{fma}\left(-1, x \cdot \left(y \cdot z\right), x\right)\\

\mathbf{elif}\;x \leq 1.0343249380691399 \cdot 10^{-209}:\\
\;\;\;\;x - y \cdot \left(x \cdot z\right)\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 3 regimes
  2. if x < -1.6898890574526774e-119

    1. Initial program 1.3

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

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

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

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

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

    if -1.6898890574526774e-119 < x < 1.03432493806913992e-209

    1. Initial program 7.4

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

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

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

    if 1.03432493806913992e-209 < x

    1. Initial program 2.1

      \[x \cdot \left(1 - y \cdot z\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.5

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

Reproduce

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