?

Average Error: 5.33% → 0.35%
Time: 6.1s
Precision: binary64
Cost: 1481

?

\[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 \lor \neg \left(t_0 \leq 2 \cdot 10^{+304}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \left(y \cdot z\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 (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+304)))
     (* z (* y (- x)))
     (- x (* x (* 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 t_0 = x * (1.0 - (y * z));
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 2e+304)) {
		tmp = z * (y * -x);
	} else {
		tmp = x - (x * (y * z));
	}
	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) || !(t_0 <= 2e+304)) {
		tmp = z * (y * -x);
	} else {
		tmp = x - (x * (y * z));
	}
	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) or not (t_0 <= 2e+304):
		tmp = z * (y * -x)
	else:
		tmp = x - (x * (y * z))
	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)) || !(t_0 <= 2e+304))
		tmp = Float64(z * Float64(y * Float64(-x)));
	else
		tmp = Float64(x - Float64(x * Float64(y * z)));
	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) || ~((t_0 <= 2e+304)))
		tmp = z * (y * -x);
	else
		tmp = x - (x * (y * z));
	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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 2e+304]], $MachinePrecision]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(y * z), $MachinePrecision]), $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 \lor \neg \left(t_0 \leq 2 \cdot 10^{+304}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

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

    1. Initial program 95.18

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

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

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

      [Start]4.47

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

      mul-1-neg [=>]4.47

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

      associate-*r* [=>]98.36

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

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

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

      *-commutative [=>]98.36

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

      associate-*l* [=>]3.77

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

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

    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. Simplified8.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* [<=]8.48

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

      mul-1-neg [<=]8.48

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

      *-commutative [=>]8.48

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

      associate-*l* [=>]8.48

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

      fma-def [=>]8.48

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

      associate-*l* [=>]8.48

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

      *-commutative [=>]8.48

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

      neg-mul-1 [<=]8.48

      \[ \mathsf{fma}\left(y, z \cdot \color{blue}{\left(-x\right)}, x\right) \]
    4. Taylor expanded in y around 0 8.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]8.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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.35

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

Alternatives

Alternative 1
Error0.36%
Cost1481
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{+304}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error37.02%
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -1.95 \cdot 10^{+136} \lor \neg \left(y \leq -1.1 \cdot 10^{+81}\right) \land \left(y \leq -1.25 \cdot 10^{+30} \lor \neg \left(y \leq 5.2 \cdot 10^{-163}\right)\right):\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error36.25%
Cost913
\[\begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+137}:\\ \;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{elif}\;y \leq -6 \cdot 10^{+78}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{+29} \lor \neg \left(y \leq 5.2 \cdot 10^{-163}\right):\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error40.57%
Cost64
\[x \]

Error

Reproduce?

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