Average Error: 3.2 → 0.3
Time: 10.9s
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:\\ \;\;\;\;\left(x \cdot z\right) \cdot \left(-y\right)\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+304}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) \cdot \left(x \cdot y\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))
     (* (* x z) (- y))
     (if (<= t_0 5e+304) t_0 (* (- 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 = (x * z) * -y;
	} else if (t_0 <= 5e+304) {
		tmp = t_0;
	} 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 = (x * z) * -y;
	} else if (t_0 <= 5e+304) {
		tmp = t_0;
	} 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 = (x * z) * -y
	elif t_0 <= 5e+304:
		tmp = t_0
	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(Float64(x * z) * Float64(-y));
	elseif (t_0 <= 5e+304)
		tmp = t_0;
	else
		tmp = Float64(Float64(-z) * Float64(x * 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 = (x * z) * -y;
	elseif (t_0 <= 5e+304)
		tmp = t_0;
	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[(N[(x * z), $MachinePrecision] * (-y)), $MachinePrecision], If[LessEqual[t$95$0, 5e+304], t$95$0, 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:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(-y\right)\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot \left(x \cdot y\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 64.0

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

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

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

      [Start]0.3

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

      mul-1-neg [=>]0.3

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

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

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

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

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

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

    1. Initial program 0.1

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

    if 4.9999999999999997e304 < (*.f64 x (-.f64 1 (*.f64 y z)))

    1. Initial program 57.7

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

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

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

      [Start]5.1

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

      mul-1-neg [=>]5.1

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

      *-commutative [=>]5.1

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

      associate-*l* [=>]5.1

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

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

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

      *-commutative [<=]5.1

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

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

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

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

Alternatives

Alternative 1
Error27.7
Cost2232
\[\begin{array}{l} t_0 := \left(x \cdot z\right) \cdot \left(-y\right)\\ t_1 := x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{+140}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.9 \cdot 10^{+93}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -0.00182:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-134}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -7.3 \cdot 10^{-193}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-266}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-270}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 10^{-301}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-234}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.000115:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error27.5
Cost2232
\[\begin{array}{l} t_0 := \left(x \cdot z\right) \cdot \left(-y\right)\\ t_1 := x \cdot \left(y \cdot \left(-z\right)\right)\\ t_2 := \left(-z\right) \cdot \left(x \cdot y\right)\\ \mathbf{if}\;x \leq -5 \cdot 10^{+140}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.9 \cdot 10^{+93}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -0.00094:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-134}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-198}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-266}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-270}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 10^{-301}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-232}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{-154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.000115:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error22.2
Cost649
\[\begin{array}{l} \mathbf{if}\;y \leq -0.000195 \lor \neg \left(y \leq 2.15 \cdot 10^{-82}\right):\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error25.4
Cost64
\[x \]

Error

Reproduce

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