?

Average Error: 3.2 → 1.2
Time: 9.3s
Precision: binary64
Cost: 1480

?

\[ \begin{array}{c}[y, z] = \mathsf{sort}([y, z])\\ \end{array} \]
\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+291}:\\ \;\;\;\;x - y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;t_0 \leq 10^{+288}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \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)))))
   (if (<= t_0 -5e+291)
     (- x (* y (* z x)))
     (if (<= t_0 1e+288) t_0 (* 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 t_0 = x * (1.0 - (y * z));
	double tmp;
	if (t_0 <= -5e+291) {
		tmp = x - (y * (z * x));
	} else if (t_0 <= 1e+288) {
		tmp = t_0;
	} else {
		tmp = y * (z * -x);
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = x * (1.0d0 - (y * z))
    if (t_0 <= (-5d+291)) then
        tmp = x - (y * (z * x))
    else if (t_0 <= 1d+288) then
        tmp = t_0
    else
        tmp = y * (z * -x)
    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 t_0 = x * (1.0 - (y * z));
	double tmp;
	if (t_0 <= -5e+291) {
		tmp = x - (y * (z * x));
	} else if (t_0 <= 1e+288) {
		tmp = t_0;
	} else {
		tmp = y * (z * -x);
	}
	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))
	tmp = 0
	if t_0 <= -5e+291:
		tmp = x - (y * (z * x))
	elif t_0 <= 1e+288:
		tmp = t_0
	else:
		tmp = 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)
	t_0 = Float64(x * Float64(1.0 - Float64(y * z)))
	tmp = 0.0
	if (t_0 <= -5e+291)
		tmp = Float64(x - Float64(y * Float64(z * x)));
	elseif (t_0 <= 1e+288)
		tmp = t_0;
	else
		tmp = Float64(y * Float64(z * Float64(-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)
	t_0 = x * (1.0 - (y * z));
	tmp = 0.0;
	if (t_0 <= -5e+291)
		tmp = x - (y * (z * x));
	elseif (t_0 <= 1e+288)
		tmp = t_0;
	else
		tmp = 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_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+291], N[(x - N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+288], t$95$0, N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+291}:\\
\;\;\;\;x - y \cdot \left(z \cdot x\right)\\

\mathbf{elif}\;t_0 \leq 10^{+288}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\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 x (-.f64 1 (*.f64 y z))) < -5.0000000000000001e291

    1. Initial program 37.7

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

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

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

      [Start]9.9

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

      rational.json-simplify-1 [=>]9.9

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

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

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

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

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

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

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

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

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

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

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

      [Start]37.7

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

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

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

      rational.json-simplify-1 [=>]37.7

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

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

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

      rational.json-simplify-8 [<=]37.7

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

      rational.json-simplify-1 [<=]37.7

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

      rational.json-simplify-17 [=>]37.7

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

      rational.json-simplify-8 [=>]37.7

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

      rational.json-simplify-43 [<=]37.7

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

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

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

      rational.json-simplify-8 [<=]37.7

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

      rational.json-simplify-12 [=>]37.7

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

      rational.json-simplify-42 [=>]37.7

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

      metadata-eval [=>]37.7

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

      rational.json-simplify-48 [<=]37.7

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

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

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

      rational.json-simplify-6 [=>]37.7

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

      rational.json-simplify-2 [<=]37.7

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

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

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

    if -5.0000000000000001e291 < (*.f64 x (-.f64 1 (*.f64 y z))) < 1e288

    1. Initial program 0.1

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

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

    1. Initial program 38.9

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

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

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

      [Start]16.9

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

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

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

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

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

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

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

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

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

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

Alternatives

Alternative 1
Error1.8
Cost1424
\[\begin{array}{l} t_0 := \left(y \cdot z\right) \cdot \left(-x\right)\\ t_1 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \cdot z \leq -2:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \cdot z \leq 0.05:\\ \;\;\;\;x\\ \mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+184}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error0.2
Cost968
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \cdot z \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+184}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error17.3
Cost648
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{-159}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+140}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error17.1
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{-159}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{elif}\;z \leq 5.3 \cdot 10^{+141}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 5
Error25.0
Cost64
\[x \]

Error

Reproduce?

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