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

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

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

    1. Initial program 24.9

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

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

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

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

      \[\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

    if -5.00000000000000049e198 < (*.f64 y z) < 1.9999999999999998e125

    1. Initial program 0.1

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

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

      \[\leadsto \color{blue}{x - y \cdot \left(z \cdot x\right)} \]
      Proof
      (-.f64 x (*.f64 y (*.f64 z x))): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 x)) (*.f64 y (*.f64 z x))): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1 x) (Rewrite=> associate-*r*_binary64 (*.f64 (*.f64 y z) x))): 30 points increase in error, 29 points decrease in error
      (Rewrite=> distribute-rgt-out--_binary64 (*.f64 x (-.f64 1 (*.f64 y z)))): 5 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 1 (*.f64 y z)) x)): 0 points increase in error, 0 points decrease in error
    4. Taylor expanded in x around 0 0.1

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

      \[\leadsto \color{blue}{x - \left(y \cdot z\right) \cdot x} \]
      Proof
      (-.f64 x (*.f64 (*.f64 y z) x)): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 x)) (*.f64 (*.f64 y z) x)): 0 points increase in error, 0 points decrease in error
      (Rewrite=> distribute-rgt-out--_binary64 (*.f64 x (-.f64 1 (*.f64 y z)))): 5 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 1 (*.f64 y z)) x)): 0 points increase in error, 0 points decrease in error

    if 1.9999999999999998e125 < (*.f64 y z)

    1. Initial program 16.0

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

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

      \[\leadsto \color{blue}{z \cdot \left(x \cdot \left(-y\right)\right)} \]
      Proof
      (*.f64 z (*.f64 x (neg.f64 y))): 0 points increase in error, 0 points decrease in error
      (*.f64 z (*.f64 x (Rewrite=> neg-mul-1_binary64 (*.f64 -1 y)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z x) (*.f64 -1 y))): 47 points increase in error, 48 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 -1 y) (*.f64 z x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r*_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.5

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

Alternatives

Alternative 1
Error16.5
Cost912
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -2.2 \cdot 10^{+138}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{+123}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.739124318404653 \cdot 10^{-121}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error16.8
Cost912
\[\begin{array}{l} t_0 := z \cdot \left(x \cdot \left(-y\right)\right)\\ \mathbf{if}\;y \leq -2.2 \cdot 10^{+138}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{+123}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.42 \cdot 10^{+86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.739124318404653 \cdot 10^{-121}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 3
Error17.0
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+138}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{+123}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -9 \cdot 10^{+61}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 1.739124318404653 \cdot 10^{-121}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 4
Error25.6
Cost64
\[x \]

Error

Reproduce

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