Average Error: 3.2 → 1.6
Time: 39.3s
Precision: binary64
Cost: 708
\[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{else}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot x\\ \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))) (- 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) <= -((double) INFINITY)) {
		tmp = y * (z * -x);
	} else {
		tmp = x - ((y * z) * 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 {
		tmp = x - ((y * z) * 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)
	else:
		tmp = 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) <= Float64(-Inf))
		tmp = Float64(y * Float64(z * Float64(-x)));
	else
		tmp = Float64(x - Float64(Float64(y * z) * 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);
	else
		tmp = x - ((y * z) * 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], N[(x - N[(N[(y * z), $MachinePrecision] * 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{else}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\


\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 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.2

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(z \cdot x\right)\right)} \]
    3. 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<= *-commutative_binary64 (*.f64 (neg.f64 z) x))): 0 points increase in error, 0 points decrease in error
      (*.f64 y (Rewrite=> distribute-lft-neg-out_binary64 (neg.f64 (*.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. Initial program 1.6

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{x \cdot \left(1 - y \cdot z\right)}\right)}^{3}} \]
    3. Applied egg-rr1.6

      \[\leadsto \color{blue}{x + \left(y \cdot \left(-z\right)\right) \cdot x} \]
    4. Simplified1.6

      \[\leadsto \color{blue}{x - x \cdot \left(y \cdot z\right)} \]
      Proof
      (-.f64 x (*.f64 x (*.f64 y z))): 0 points increase in error, 0 points decrease in error
      (-.f64 x (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 y z) x))): 0 points increase in error, 0 points decrease in error
      (-.f64 x (Rewrite<= associate-*r*_binary64 (*.f64 y (*.f64 z x)))): 28 points increase in error, 17 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 x (neg.f64 (*.f64 y (*.f64 z x))))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (neg.f64 (Rewrite=> associate-*r*_binary64 (*.f64 (*.f64 y z) x)))): 17 points increase in error, 28 points decrease in error
      (+.f64 x (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 (*.f64 y z)) x))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (*.f64 (Rewrite<= distribute-rgt-neg-out_binary64 (*.f64 y (neg.f64 z))) x)): 0 points increase in error, 0 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot x\\ \end{array} \]

Alternatives

Alternative 1
Error1.6
Cost708
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]
Alternative 2
Error21.8
Cost648
\[\begin{array}{l} t_0 := \left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{if}\;z \leq -2.45 \cdot 10^{-96}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{+94}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error21.0
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{-96}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+93}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \end{array} \]
Alternative 4
Error20.2
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{-96}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+93}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 5
Error25.5
Cost64
\[x \]

Error

Reproduce

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