Average Error: 3.3 → 0.3
Time: 5.5s
Precision: binary64
Cost: 968
\[ \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:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+150}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) (- INFINITY))
   (* y (* z (- x)))
   (if (<= (* y z) 2e+150) (* x (- 1.0 (* y z))) (* z (* y (- 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 = y * (z * -x);
	} else if ((y * z) <= 2e+150) {
		tmp = x * (1.0 - (y * z));
	} else {
		tmp = z * (y * -x);
	}
	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 tmp;
	if ((y * z) <= -Double.POSITIVE_INFINITY) {
		tmp = y * (z * -x);
	} else if ((y * z) <= 2e+150) {
		tmp = x * (1.0 - (y * z));
	} else {
		tmp = z * (y * -x);
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - (y * z))
def code(x, y, z):
	tmp = 0
	if (y * z) <= -math.inf:
		tmp = y * (z * -x)
	elif (y * z) <= 2e+150:
		tmp = x * (1.0 - (y * z))
	else:
		tmp = z * (y * -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(y * Float64(z * Float64(-x)));
	elseif (Float64(y * z) <= 2e+150)
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	else
		tmp = Float64(z * Float64(y * Float64(-x)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - (y * z));
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y * z) <= -Inf)
		tmp = y * (z * -x);
	elseif ((y * z) <= 2e+150)
		tmp = x * (1.0 - (y * z));
	else
		tmp = z * (y * -x);
	end
	tmp_2 = 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[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 2e+150], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\

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

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

    1. Initial program 64.0

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Applied egg-rr64.0

      \[\leadsto \color{blue}{\frac{\left(1 - {\left(y \cdot z\right)}^{2}\right) \cdot x}{1 + y \cdot z}} \]
    3. Taylor expanded in y around inf 0.2

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

      \[\leadsto \color{blue}{y \cdot \left(x \cdot \left(-z\right)\right)} \]
      Proof
      (*.f64 y (*.f64 x (neg.f64 z))): 0 points increase in error, 0 points decrease in error
      (*.f64 y (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 x z)))): 0 points increase in error, 0 points decrease in error
      (*.f64 y (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 z x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 y (*.f64 z x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 y (*.f64 z x)))): 0 points increase in error, 0 points decrease in error

    if -inf.0 < (*.f64 y z) < 1.99999999999999996e150

    1. Initial program 0.1

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

    if 1.99999999999999996e150 < (*.f64 y z)

    1. Initial program 18.0

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

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

      \[\leadsto \color{blue}{z \cdot \left(x \cdot \left(-y\right)\right)} \]
      Proof
      (*.f64 z (*.f64 x (neg.f64 y))): 0 points increase in error, 0 points decrease in error
      (*.f64 z (*.f64 x (Rewrite=> neg-mul-1_binary64 (*.f64 -1 y)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z x) (*.f64 -1 y))): 53 points increase in error, 58 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 -1 y) (*.f64 z x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r*_binary64 (*.f64 -1 (*.f64 y (*.f64 z x)))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.3

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

Alternatives

Alternative 1
Error4.6
Cost712
\[\begin{array}{l} t_0 := x - y \cdot \left(z \cdot x\right)\\ \mathbf{if}\;y \leq -3.0567512747501128 \cdot 10^{-192}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.2605160727067166 \cdot 10^{-276}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error17.2
Cost648
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;z \leq -5.877945840677768 \cdot 10^{-14}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+77}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error17.2
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -5.877945840677768 \cdot 10^{-14}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+77}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 4
Error25.4
Cost64
\[x \]

Error

Reproduce

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