?

Average Error: 5.12% → 0.37%
Time: 7.4s
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 -\infty \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+173}\right):\\ \;\;\;\;z \cdot \left(y \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 (or (<= (* y z) (- INFINITY)) (not (<= (* y z) 2e+173)))
   (* z (* y (- 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)) || !((y * z) <= 2e+173)) {
		tmp = z * (y * -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) || !((y * z) <= 2e+173)) {
		tmp = z * (y * -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) or not ((y * z) <= 2e+173):
		tmp = z * (y * -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)) || !(Float64(y * z) <= 2e+173))
		tmp = Float64(z * Float64(y * 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) || ~(((y * z) <= 2e+173)))
		tmp = z * (y * -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[Or[LessEqual[N[(y * z), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(y * z), $MachinePrecision], 2e+173]], $MachinePrecision]], N[(z * N[(y * (-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 \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+173}\right):\\
\;\;\;\;z \cdot \left(y \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 or 2e173 < (*.f64 y z)

    1. Initial program 51.69

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

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

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

      [Start]2.87

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

      mul-1-neg [=>]2.87

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

      associate-*r* [=>]51.69

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

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

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

      *-commutative [=>]51.69

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

      associate-*l* [=>]2.52

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

    if -inf.0 < (*.f64 y z) < 2e173

    1. Initial program 0.16

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

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

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

      [Start]0.16

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

      *-commutative [<=]0.16

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

      distribute-rgt-out-- [<=]0.14

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

      *-lft-identity [=>]0.14

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

      associate-*r* [<=]7.88

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

      \[\leadsto x - \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(z \cdot x\right)\right)} - 1\right)} \]
    5. Simplified0.14

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

      [Start]33.39

      \[ x - \left(e^{\mathsf{log1p}\left(y \cdot \left(z \cdot x\right)\right)} - 1\right) \]

      expm1-def [=>]23.47

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

      expm1-log1p [=>]7.88

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

      associate-*r* [=>]0.14

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

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

Alternatives

Alternative 1
Error0.38%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -\infty \lor \neg \left(y \cdot z \leq 2 \cdot 10^{+173}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]
Alternative 2
Error26.36%
Cost781
\[\begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+271}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{+137} \lor \neg \left(y \leq 7 \cdot 10^{-71}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error28.7%
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{-147} \lor \neg \left(z \leq 2.35 \cdot 10^{+115}\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error26.91%
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{-129} \lor \neg \left(z \leq 5.9 \cdot 10^{+110}\right):\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error39.27%
Cost64
\[x \]

Error

Reproduce?

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