?

Average Accuracy: 94.8% → 99.6%
Time: 8.3s
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 -2 \cdot 10^{+245}:\\ \;\;\;\;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}:\\ \;\;\;\;\frac{1}{\frac{1}{x - y \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) -2e+245)
   (* z (* y (- x)))
   (if (<= (* y z) 5e+148)
     (* x (fma z (- y) 1.0))
     (/ 1.0 (/ 1.0 (- x (* 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) <= -2e+245) {
		tmp = z * (y * -x);
	} else if ((y * z) <= 5e+148) {
		tmp = x * fma(z, -y, 1.0);
	} else {
		tmp = 1.0 / (1.0 / (x - (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) <= -2e+245)
		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(1.0 / Float64(1.0 / Float64(x - 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], -2e+245], 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[(1.0 / N[(1.0 / N[(x - N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+245}:\\
\;\;\;\;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}:\\
\;\;\;\;\frac{1}{\frac{1}{x - y \cdot \left(z \cdot x\right)}}\\


\end{array}

Error?

Derivation?

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

    1. Initial program 45.2%

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

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

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

      [Start]99.1

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

      mul-1-neg [=>]99.1

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

      *-commutative [=>]99.1

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

      associate-*l* [=>]99.3

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

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

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

      *-commutative [<=]99.3

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

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

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

    if -2.00000000000000009e245 < (*.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 70.9%

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

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

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

      [Start]70.9

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

      *-commutative [=>]70.9

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

      distribute-rgt-out-- [<=]70.9

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

      *-lft-identity [=>]70.9

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

      *-commutative [=>]70.9

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

      associate-*l* [=>]95.3

      \[ x - \color{blue}{z \cdot \left(y \cdot x\right)} \]
    4. Applied egg-rr93.7%

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

      [Start]95.3

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

      add-cube-cbrt [=>]93.7

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

      pow3 [=>]93.7

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

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

      [Start]93.7

      \[ {\left(\sqrt[3]{x - z \cdot \left(y \cdot x\right)}\right)}^{3} \]

      rem-cube-cbrt [=>]95.3

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

      flip-- [=>]48.0

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

      clear-num [=>]47.9

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

      *-un-lft-identity [=>]47.9

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

      associate-/l* [=>]48.0

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

      flip-- [<=]95.2

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

      *-commutative [=>]95.2

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

      associate-*l* [=>]97.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+245}:\\ \;\;\;\;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}:\\ \;\;\;\;\frac{1}{\frac{1}{x - y \cdot \left(z \cdot x\right)}}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.6%
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+245}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+148}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{x - y \cdot \left(z \cdot x\right)}}\\ \end{array} \]
Alternative 2
Accuracy99.6%
Cost968
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+245}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+139}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 3
Accuracy71.5%
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+204} \lor \neg \left(y \leq -5.8 \cdot 10^{+171} \lor \neg \left(y \leq -9 \cdot 10^{+84}\right) \land y \leq 2.7 \cdot 10^{-69}\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy73.3%
Cost912
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -4.7 \cdot 10^{+204}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5 \cdot 10^{+172}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{+84}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-69}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Accuracy72.7%
Cost912
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{+211}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6 \cdot 10^{+172}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{+83}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-48}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Accuracy60.5%
Cost64
\[x \]

Error

Reproduce?

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