?

Average Accuracy: 95.1% → 99.4%
Time: 10.2s
Precision: binary64
Cost: 7304

?

\[ \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 -\infty:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+148}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(z, -y, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-y\right) \cdot \left(z \cdot x\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) (- INFINITY))
   (* z (* y (- x)))
   (if (<= (* y z) 5e+148) (* x (fma z (- y) 1.0)) (* (- y) (* z 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) <= -((double) INFINITY)) {
		tmp = z * (y * -x);
	} else if ((y * z) <= 5e+148) {
		tmp = x * fma(z, -y, 1.0);
	} else {
		tmp = -y * (z * 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) <= Float64(-Inf))
		tmp = Float64(z * Float64(y * Float64(-x)));
	elseif (Float64(y * z) <= 5e+148)
		tmp = Float64(x * fma(z, Float64(-y), 1.0));
	else
		tmp = Float64(Float64(-y) * Float64(z * 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], (-Infinity)], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 5e+148], N[(x * N[(z * (-y) + 1.0), $MachinePrecision]), $MachinePrecision], N[((-y) * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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

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


\end{array}

Error?

Derivation?

  1. Split input into 3 regimes
  2. if (*.f64 y z) < -inf.0

    1. Initial program 0.0%

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

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

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

      [Start]99.7

      \[ -1 \cdot \left(y \cdot \left(z \cdot x\right)\right) \]

      mul-1-neg [=>]99.7

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

      *-commutative [=>]99.7

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

      associate-*l* [=>]99.7

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

      distribute-rgt-neg-in [=>]99.7

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

      *-commutative [<=]99.7

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

      distribute-rgt-neg-in [=>]99.7

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

    if -inf.0 < (*.f64 y z) < 5.00000000000000024e148

    1. Initial program 99.9%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Simplified99.9%

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

      [Start]99.9

      \[ x \cdot \left(1 - y \cdot z\right) \]

      cancel-sign-sub-inv [=>]99.9

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

      +-commutative [=>]99.9

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

      *-commutative [=>]99.9

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

      fma-def [=>]99.9

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

    if 5.00000000000000024e148 < (*.f64 y z)

    1. Initial program 73.2%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Simplified73.2%

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

      [Start]73.2

      \[ x \cdot \left(1 - y \cdot z\right) \]

      cancel-sign-sub-inv [=>]73.2

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

      +-commutative [=>]73.2

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

      *-commutative [=>]73.2

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

      fma-def [=>]73.2

      \[ x \cdot \color{blue}{\mathsf{fma}\left(z, -y, 1\right)} \]
    3. Taylor expanded in z around inf 94.5%

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

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

      [Start]94.5

      \[ -1 \cdot \left(y \cdot \left(z \cdot x\right)\right) \]

      associate-*r* [=>]94.5

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

      *-commutative [=>]94.5

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

      mul-1-neg [=>]94.5

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

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

Alternatives

Alternative 1
Accuracy99.8%
Cost1224
\[\begin{array}{l} t_0 := 1 - y \cdot z\\ \mathbf{if}\;t_0 \leq -4 \cdot 10^{+285}:\\ \;\;\;\;\left(-y\right) \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+290}:\\ \;\;\;\;x \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 2
Accuracy99.4%
Cost968
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+148}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(-y\right) \cdot \left(z \cdot x\right)\\ \end{array} \]
Alternative 3
Accuracy70.3%
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{+136} \lor \neg \left(y \leq -1.95 \cdot 10^{+73}\right) \land \left(y \leq -6.8 \cdot 10^{+47} \lor \neg \left(y \leq 9 \cdot 10^{-20}\right)\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy72.6%
Cost912
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -9.8 \cdot 10^{+132}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4 \cdot 10^{+72}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -4.2 \cdot 10^{+48}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-25}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Accuracy72.3%
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+133}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq -4.7 \cdot 10^{+73}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{+46}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 1.28 \cdot 10^{-21}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\left(-y\right) \cdot \left(z \cdot x\right)\\ \end{array} \]
Alternative 6
Accuracy60.2%
Cost64
\[x \]

Error

Reproduce?

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