Average Error: 3.3 → 0.3
Time: 10.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 -5 \cdot 10^{+193}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+194}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z \cdot x\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) -5e+193)
   (* z (* y (- x)))
   (if (<= (* y z) 2e+194) (* x (- 1.0 (* y z))) (* 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) <= -5e+193) {
		tmp = z * (y * -x);
	} else if ((y * z) <= 2e+194) {
		tmp = x * (1.0 - (y * z));
	} 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) :: tmp
    if ((y * z) <= (-5d+193)) then
        tmp = z * (y * -x)
    else if ((y * z) <= 2d+194) then
        tmp = x * (1.0d0 - (y * z))
    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 tmp;
	if ((y * z) <= -5e+193) {
		tmp = z * (y * -x);
	} else if ((y * z) <= 2e+194) {
		tmp = x * (1.0 - (y * z));
	} else {
		tmp = 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) <= -5e+193:
		tmp = z * (y * -x)
	elif (y * z) <= 2e+194:
		tmp = x * (1.0 - (y * z))
	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)
	tmp = 0.0
	if (Float64(y * z) <= -5e+193)
		tmp = Float64(z * Float64(y * Float64(-x)));
	elseif (Float64(y * z) <= 2e+194)
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	else
		tmp = Float64(y * Float64(-Float64(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) <= -5e+193)
		tmp = z * (y * -x);
	elseif ((y * z) <= 2e+194)
		tmp = x * (1.0 - (y * z));
	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_] := If[LessEqual[N[(y * z), $MachinePrecision], -5e+193], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 2e+194], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-N[(z * x), $MachinePrecision])), $MachinePrecision]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+193}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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

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

    1. Initial program 27.7

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

      \[\leadsto \color{blue}{\frac{\left(1 - {\left(y \cdot z\right)}^{2}\right) \cdot x}{1 + y \cdot z}} \]
    3. Applied egg-rr64.0

      \[\leadsto \frac{\color{blue}{x + \left(-{\left(y \cdot z\right)}^{2}\right) \cdot x}}{1 + y \cdot z} \]
    4. Taylor expanded in y around inf 1.1

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

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot \left(-z\right)} \]
      Proof
      (*.f64 (*.f64 y x) (neg.f64 z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 y x) z))): 0 points increase in error, 0 points decrease in error
      (neg.f64 (Rewrite<= associate-*r*_binary64 (*.f64 y (*.f64 x z)))): 54 points increase in error, 58 points decrease in error
      (neg.f64 (*.f64 y (Rewrite<= *-commutative_binary64 (*.f64 z x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 y (*.f64 z x)))): 0 points increase in error, 0 points decrease in error

    if -4.99999999999999972e193 < (*.f64 y z) < 1.99999999999999989e194

    1. Initial program 0.1

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

    if 1.99999999999999989e194 < (*.f64 y z)

    1. Initial program 24.0

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

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

      \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(-x\right)} \]
      Proof
      (*.f64 (*.f64 y z) (neg.f64 x)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 y z) x))): 0 points increase in error, 0 points decrease in error
      (neg.f64 (Rewrite<= associate-*r*_binary64 (*.f64 y (*.f64 z x)))): 48 points increase in error, 47 points decrease in error
      (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 y (*.f64 z x)))): 0 points increase in error, 0 points decrease in error
    4. Taylor expanded in y around 0 1.9

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

      \[\leadsto \color{blue}{y \cdot \left(-z \cdot x\right)} \]
      Proof
      (*.f64 y (neg.f64 (*.f64 z x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 y (*.f64 z x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 y (*.f64 z x)))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.3

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

Alternatives

Alternative 1
Error3.2
Cost1164
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -500:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \cdot z \leq 1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+194}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z \cdot x\right)\\ \end{array} \]
Alternative 2
Error18.2
Cost912
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -1.4 \cdot 10^{+195}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+127}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{+89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.3314068149684212 \cdot 10^{-18}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error17.5
Cost912
\[\begin{array}{l} t_0 := y \cdot \left(-z \cdot x\right)\\ \mathbf{if}\;y \leq -1.4 \cdot 10^{+195}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{+178}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{+89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.3314068149684212 \cdot 10^{-18}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error3.7
Cost904
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq 50000000000:\\ \;\;\;\;x - y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+194}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z \cdot x\right)\\ \end{array} \]
Alternative 5
Error25.3
Cost64
\[x \]

Error

Reproduce

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