Average Error: 3.4 → 1.8
Time: 6.5s
Precision: binary64
Cost: 964
\[ \begin{array}{c}[y, z] = \mathsf{sort}([y, z])\\ \end{array} \]
\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - y \cdot z\right) \leq -4 \cdot 10^{+305}:\\ \;\;\;\;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
 (if (<= (* x (- 1.0 (* y z))) -4e+305) (* 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 tmp;
	if ((x * (1.0 - (y * z))) <= -4e+305) {
		tmp = z * (y * -x);
	} else {
		tmp = x - (x * (y * z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x * (1.0d0 - (y * z))
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * (1.0d0 - (y * z))) <= (-4d+305)) then
        tmp = z * (y * -x)
    else
        tmp = x - (x * (y * z))
    end if
    code = tmp
end function
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 ((x * (1.0 - (y * z))) <= -4e+305) {
		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):
	tmp = 0
	if (x * (1.0 - (y * z))) <= -4e+305:
		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)
	tmp = 0.0
	if (Float64(x * Float64(1.0 - Float64(y * z))) <= -4e+305)
		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)
	tmp = 0.0;
	if ((x * (1.0 - (y * z))) <= -4e+305)
		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_] := If[LessEqual[N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e+305], 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}
\mathbf{if}\;x \cdot \left(1 - y \cdot z\right) \leq -4 \cdot 10^{+305}:\\
\;\;\;\;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))) < -3.9999999999999998e305

    1. Initial program 59.1

      \[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. Simplified3.6

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

    if -3.9999999999999998e305 < (*.f64 x (-.f64 1 (*.f64 y z)))

    1. Initial program 1.8

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

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

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

Alternatives

Alternative 1
Error17.8
Cost1177
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;z \leq -6.5 \cdot 10^{-124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+15}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{+27}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+58}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+84} \lor \neg \left(z \leq 8.2 \cdot 10^{+132}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error1.8
Cost964
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ \mathbf{if}\;t_0 \leq -4 \cdot 10^{+305}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error3.1
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{+133} \lor \neg \left(y \leq -5 \cdot 10^{+32}\right):\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 4
Error17.6
Cost649
\[\begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{+100} \lor \neg \left(y \leq 9.6 \cdot 10^{-119}\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error17.1
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+100}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 8.1 \cdot 10^{-54}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x \cdot z\right)\\ \end{array} \]
Alternative 6
Error25.2
Cost64
\[x \]

Error

Reproduce

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