?

Average Error: 5.28% → 0.83%
Time: 6.0s
Precision: binary64
Cost: 1480

?

\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+298}:\\ \;\;\;\;x - x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (- 1.0 (* y z)))))
   (if (<= t_0 (- INFINITY))
     (* y (* x (- z)))
     (if (<= t_0 2e+298) (- x (* x (* y z))) (* z (* x (- y)))))))
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 = x * (1.0 - (y * z));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = y * (x * -z);
	} else if (t_0 <= 2e+298) {
		tmp = x - (x * (y * z));
	} else {
		tmp = z * (x * -y);
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
public static double code(double x, double y, double z) {
	double t_0 = x * (1.0 - (y * z));
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = y * (x * -z);
	} else if (t_0 <= 2e+298) {
		tmp = x - (x * (y * z));
	} else {
		tmp = z * (x * -y);
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - (y * z))
def code(x, y, z):
	t_0 = x * (1.0 - (y * z))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = y * (x * -z)
	elif t_0 <= 2e+298:
		tmp = x - (x * (y * z))
	else:
		tmp = z * (x * -y)
	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(x * Float64(1.0 - Float64(y * z)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(y * Float64(x * Float64(-z)));
	elseif (t_0 <= 2e+298)
		tmp = Float64(x - Float64(x * Float64(y * z)));
	else
		tmp = Float64(z * Float64(x * Float64(-y)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - (y * z));
end
function tmp_2 = code(x, y, z)
	t_0 = x * (1.0 - (y * z));
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = y * (x * -z);
	elseif (t_0 <= 2e+298)
		tmp = x - (x * (y * z));
	else
		tmp = z * (x * -y);
	end
	tmp_2 = 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[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+298], N[(x - N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision]]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+298}:\\
\;\;\;\;x - x \cdot \left(y \cdot z\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

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

    1. Initial program 100

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

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

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

      [Start]0.45

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

      mul-1-neg [=>]0.45

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

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

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

      distribute-lft-neg-in [=>]0.45

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

    if -inf.0 < (*.f64 x (-.f64 1 (*.f64 y z))) < 1.9999999999999999e298

    1. Initial program 0.16

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

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

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

      [Start]0.16

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

      sub-neg [=>]0.16

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

      +-commutative [<=]0.16

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

      distribute-lft1-in [<=]0.15

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

      distribute-lft-neg-out [=>]0.15

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

      associate-*r* [<=]7.48

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

      mul-1-neg [<=]7.48

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

      *-commutative [=>]7.48

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

      associate-*l* [=>]7.48

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

      fma-def [=>]7.48

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

      associate-*l* [=>]7.48

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

      *-commutative [=>]7.48

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

      neg-mul-1 [<=]7.48

      \[ \mathsf{fma}\left(y, z \cdot \color{blue}{\left(-x\right)}, x\right) \]
    4. Taylor expanded in y around 0 7.48

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

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

      [Start]7.48

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

      associate-*r* [=>]0.15

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

      mul-1-neg [=>]0.15

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

      +-commutative [<=]0.15

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

      sub-neg [<=]0.15

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

      *-commutative [=>]0.15

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

    if 1.9999999999999999e298 < (*.f64 x (-.f64 1 (*.f64 y z)))

    1. Initial program 74

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

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

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

      [Start]17.76

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

      mul-1-neg [=>]17.76

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

      associate-*r* [=>]88.51

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

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

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

      *-commutative [=>]88.51

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

      associate-*l* [=>]19.46

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

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

Alternatives

Alternative 1
Error0.83%
Cost1480
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+298}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \end{array} \]
Alternative 2
Error34.5%
Cost1044
\[\begin{array}{l} t_0 := x \cdot \left(y \cdot \left(-z\right)\right)\\ t_1 := y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{if}\;z \leq -1.22 \cdot 10^{-126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+82}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+157}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.45 \cdot 10^{+218}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error33.58%
Cost1044
\[\begin{array}{l} t_0 := z \cdot \left(x \cdot \left(-y\right)\right)\\ t_1 := y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{if}\;z \leq -1.22 \cdot 10^{-126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{+82}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+155}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+157}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8.4 \cdot 10^{+220}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error35.7%
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -1.22 \cdot 10^{-126} \lor \neg \left(z \leq 5.9 \cdot 10^{+82}\right):\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error39.56%
Cost64
\[x \]

Error

Reproduce?

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