Average Error: 3.3 → 0.2
Time: 4.9s
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} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+230}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+180}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* z (- x)))))
   (if (<= (* y z) -5e+230)
     t_0
     (if (<= (* y z) 5e+180) (* x (- 1.0 (* y z))) t_0))))
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 = y * (z * -x);
	double tmp;
	if ((y * z) <= -5e+230) {
		tmp = t_0;
	} else if ((y * z) <= 5e+180) {
		tmp = x * (1.0 - (y * z));
	} else {
		tmp = t_0;
	}
	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 = y * (z * -x)
    if ((y * z) <= (-5d+230)) then
        tmp = t_0
    else if ((y * z) <= 5d+180) then
        tmp = x * (1.0d0 - (y * z))
    else
        tmp = t_0
    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 = y * (z * -x);
	double tmp;
	if ((y * z) <= -5e+230) {
		tmp = t_0;
	} else if ((y * z) <= 5e+180) {
		tmp = x * (1.0 - (y * z));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - (y * z))
def code(x, y, z):
	t_0 = y * (z * -x)
	tmp = 0
	if (y * z) <= -5e+230:
		tmp = t_0
	elif (y * z) <= 5e+180:
		tmp = x * (1.0 - (y * z))
	else:
		tmp = t_0
	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(y * Float64(z * Float64(-x)))
	tmp = 0.0
	if (Float64(y * z) <= -5e+230)
		tmp = t_0;
	elseif (Float64(y * z) <= 5e+180)
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	else
		tmp = t_0;
	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 = y * (z * -x);
	tmp = 0.0;
	if ((y * z) <= -5e+230)
		tmp = t_0;
	elseif ((y * z) <= 5e+180)
		tmp = x * (1.0 - (y * z));
	else
		tmp = t_0;
	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[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -5e+230], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 5e+180], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+230}:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\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) < -5.0000000000000003e230 or 4.9999999999999996e180 < (*.f64 y z)

    1. Initial program 26.9

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

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

      \[\leadsto \color{blue}{y \cdot \left(x \cdot \left(-z\right)\right)} \]
      Proof
      (*.f64 y (*.f64 x (neg.f64 z))): 0 points increase in error, 0 points decrease in error
      (*.f64 y (Rewrite<= *-commutative_binary64 (*.f64 (neg.f64 z) x))): 0 points increase in error, 0 points decrease in error
      (*.f64 y (Rewrite=> distribute-lft-neg-out_binary64 (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.0000000000000003e230 < (*.f64 y z) < 4.9999999999999996e180

    1. Initial program 0.1

      \[x \cdot \left(1 - y \cdot z\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

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

Alternatives

Alternative 1
Error16.8
Cost912
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -1.85 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{+85}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.56 \cdot 10^{+49}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-62}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error17.1
Cost912
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -1.85 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5.6 \cdot 10^{+85}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{+48}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-62}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error17.2
Cost912
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -1.85 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.05 \cdot 10^{+85}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -7.1 \cdot 10^{+47}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-62}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error25.0
Cost64
\[x \]

Error

Reproduce

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