?

Average Error: 3.3 → 0.3
Time: 11.2s
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:\\ \;\;\;\;-z \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \cdot z \leq 10^{+141}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) (- INFINITY))
   (- (* z (* x y)))
   (if (<= (* y z) 1e+141) (* x (- 1.0 (* y z))) (* (* 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 tmp;
	if ((y * z) <= -((double) INFINITY)) {
		tmp = -(z * (x * y));
	} else if ((y * z) <= 1e+141) {
		tmp = x * (1.0 - (y * z));
	} 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 tmp;
	if ((y * z) <= -Double.POSITIVE_INFINITY) {
		tmp = -(z * (x * y));
	} else if ((y * z) <= 1e+141) {
		tmp = x * (1.0 - (y * z));
	} else {
		tmp = (z * x) * -y;
	}
	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 = -(z * (x * y))
	elif (y * z) <= 1e+141:
		tmp = x * (1.0 - (y * z))
	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)
	tmp = 0.0
	if (Float64(y * z) <= Float64(-Inf))
		tmp = Float64(-Float64(z * Float64(x * y)));
	elseif (Float64(y * z) <= 1e+141)
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	else
		tmp = Float64(Float64(z * x) * Float64(-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)
	tmp = 0.0;
	if ((y * z) <= -Inf)
		tmp = -(z * (x * y));
	elseif ((y * z) <= 1e+141)
		tmp = x * (1.0 - (y * z));
	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_] := If[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], (-N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]), If[LessEqual[N[(y * z), $MachinePrecision], 1e+141], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * x), $MachinePrecision] * (-y)), $MachinePrecision]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -\infty:\\
\;\;\;\;-z \cdot \left(x \cdot y\right)\\

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

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

      [Start]0.3

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

      rational.json-simplify-2 [=>]0.3

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

      rational.json-simplify-43 [=>]0.3

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

      rational.json-simplify-9 [=>]0.3

      \[ \left(z \cdot x\right) \cdot \color{blue}{\left(-y\right)} \]
    4. Applied egg-rr0.2

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

    if -inf.0 < (*.f64 y z) < 1.00000000000000002e141

    1. Initial program 0.1

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

    if 1.00000000000000002e141 < (*.f64 y z)

    1. Initial program 16.9

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

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

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

      [Start]2.3

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

      rational.json-simplify-2 [=>]2.3

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

      rational.json-simplify-43 [=>]2.3

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

      rational.json-simplify-9 [=>]2.3

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

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

Alternatives

Alternative 1
Error2.0
Cost1424
\[\begin{array}{l} t_0 := -x \cdot \left(y \cdot z\right)\\ t_1 := -z \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \cdot z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \cdot z \leq 10^{+149}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error3.6
Cost1164
\[\begin{array}{l} t_0 := \left(z \cdot x\right) \cdot \left(-y\right)\\ \mathbf{if}\;y \cdot z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \cdot z \leq 10^{+141}:\\ \;\;\;\;-x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error4.9
Cost904
\[\begin{array}{l} t_0 := -x \cdot \left(y \cdot z\right)\\ \mathbf{if}\;y \cdot z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \cdot z \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error25.5
Cost64
\[x \]

Error

Reproduce?

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