Average Error: 3.3 → 0.1
Time: 6.0s
Precision: binary64
Cost: 969
\[ \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 -5 \cdot 10^{+297} \lor \neg \left(y \cdot z \leq 10^{+259}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* y z) -5e+297) (not (<= (* y z) 1e+259)))
   (* z (* y (- x)))
   (* x (- 1.0 (* 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 (((y * z) <= -5e+297) || !((y * z) <= 1e+259)) {
		tmp = z * (y * -x);
	} else {
		tmp = x * (1.0 - (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 (((y * z) <= (-5d+297)) .or. (.not. ((y * z) <= 1d+259))) then
        tmp = z * (y * -x)
    else
        tmp = x * (1.0d0 - (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 (((y * z) <= -5e+297) || !((y * z) <= 1e+259)) {
		tmp = z * (y * -x);
	} else {
		tmp = x * (1.0 - (y * z));
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - (y * z))
def code(x, y, z):
	tmp = 0
	if ((y * z) <= -5e+297) or not ((y * z) <= 1e+259):
		tmp = z * (y * -x)
	else:
		tmp = x * (1.0 - (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(y * z) <= -5e+297) || !(Float64(y * z) <= 1e+259))
		tmp = Float64(z * Float64(y * Float64(-x)));
	else
		tmp = Float64(x * Float64(1.0 - 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 (((y * z) <= -5e+297) || ~(((y * z) <= 1e+259)))
		tmp = z * (y * -x);
	else
		tmp = x * (1.0 - (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[Or[LessEqual[N[(y * z), $MachinePrecision], -5e+297], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1e+259]], $MachinePrecision]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+297} \lor \neg \left(y \cdot z \leq 10^{+259}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - 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 y z) < -4.9999999999999998e297 or 9.999999999999999e258 < (*.f64 y z)

    1. Initial program 48.0

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

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

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

      [Start]0.4

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

      mul-1-neg [=>]0.4

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

      associate-*r* [=>]48.0

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

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

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

      *-commutative [=>]48.0

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

      associate-*l* [=>]0.4

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

    if -4.9999999999999998e297 < (*.f64 y z) < 9.999999999999999e258

    1. Initial program 0.1

      \[x \cdot \left(1 - y \cdot z\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

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

Alternatives

Alternative 1
Error17.9
Cost1177
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -1.9 \cdot 10^{+225}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.1 \cdot 10^{+200}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -9.2 \cdot 10^{+92}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -4.4 \cdot 10^{+72}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.1 \cdot 10^{+59} \lor \neg \left(y \leq 2.1 \cdot 10^{-102}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error17.7
Cost1177
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -1.9 \cdot 10^{+225}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.1 \cdot 10^{+200}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1 \cdot 10^{+93}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq -1.85 \cdot 10^{+72}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{+59} \lor \neg \left(y \leq 2.3 \cdot 10^{-102}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error18.6
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+225} \lor \neg \left(y \leq -3.1 \cdot 10^{+200}\right) \land \left(y \leq -7 \cdot 10^{+92} \lor \neg \left(y \leq 2.3 \cdot 10^{-102}\right)\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error25.8
Cost64
\[x \]

Error

Reproduce

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