Average Error: 3.4 → 0.3
Time: 3.1s
Precision: binary64
\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ t_1 := x - y \cdot \left(x \cdot z\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 10^{+290}:\\ \;\;\;\;x - x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (- 1.0 (* y z)))) (t_1 (- x (* y (* x z)))))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 1e+290) (- x (* x (* y z))) t_1))))
double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
double code(double x, double y, double z) {
	double t_0 = x * (1.0 - (y * z));
	double t_1 = x - (y * (x * z));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= 1e+290) {
		tmp = x - (x * (y * z));
	} else {
		tmp = t_1;
	}
	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 t_0 = x * (1.0 - (y * z));
	double t_1 = x - (y * (x * z));
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_0 <= 1e+290) {
		tmp = x - (x * (y * z));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - (y * z))
def code(x, y, z):
	t_0 = x * (1.0 - (y * z))
	t_1 = x - (y * (x * z))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = t_1
	elif t_0 <= 1e+290:
		tmp = x - (x * (y * z))
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(y * z)))
end
function code(x, y, z)
	t_0 = Float64(x * Float64(1.0 - Float64(y * z)))
	t_1 = Float64(x - Float64(y * Float64(x * z)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_0 <= 1e+290)
		tmp = Float64(x - Float64(x * Float64(y * z)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - (y * z));
end
function tmp_2 = code(x, y, z)
	t_0 = x * (1.0 - (y * z));
	t_1 = x - (y * (x * z));
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = t_1;
	elseif (t_0 <= 1e+290)
		tmp = x - (x * (y * z));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 1e+290], N[(x - N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
t_1 := x - y \cdot \left(x \cdot z\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\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))) < -inf.0 or 1.00000000000000006e290 < (*.f64 x (-.f64 1 (*.f64 y z)))

    1. Initial program 50.5

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

      \[\leadsto \color{blue}{x + x \cdot \left(y \cdot \left(-z\right)\right)} \]
    3. Taylor expanded in x around 0 50.5

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

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

    if -inf.0 < (*.f64 x (-.f64 1 (*.f64 y z))) < 1.00000000000000006e290

    1. Initial program 0.1

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

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

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

Reproduce

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