?

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

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

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

    1. Initial program 57.1

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

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

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

      [Start]0.2

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

      mul-1-neg [=>]0.2

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

      *-commutative [=>]0.2

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

      associate-*l* [=>]0.2

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

      distribute-rgt-neg-in [=>]0.2

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

      *-commutative [<=]0.2

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

      distribute-rgt-neg-in [=>]0.2

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

    if -9.99999999999999981e295 < (*.f64 y z) < 5.0000000000000001e94

    1. Initial program 0.1

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

    if 5.0000000000000001e94 < (*.f64 y z)

    1. Initial program 14.4

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Simplified14.4

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

      [Start]14.4

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

      cancel-sign-sub-inv [=>]14.4

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

      +-commutative [=>]14.4

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

      *-commutative [=>]14.4

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

      fma-def [=>]14.4

      \[ x \cdot \color{blue}{\mathsf{fma}\left(z, -y, 1\right)} \]
    3. Taylor expanded in z around inf 5.2

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

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

      [Start]5.2

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

      associate-*r* [=>]5.2

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

      *-commutative [=>]5.2

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

      mul-1-neg [=>]5.2

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

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

Alternatives

Alternative 1
Error19.6
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+98} \lor \neg \left(y \leq -6.5 \cdot 10^{+65}\right) \land \left(y \leq -0.11 \lor \neg \left(y \leq 4.6 \cdot 10^{-103}\right)\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error18.5
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{+78} \lor \neg \left(y \leq -6.2 \cdot 10^{+64}\right) \land \left(y \leq -200 \lor \neg \left(y \leq 5.2 \cdot 10^{-23}\right)\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error18.1
Cost912
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -1 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -850:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-103}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\ \end{array} \]
Alternative 4
Error25.0
Cost64
\[x \]

Error

Reproduce?

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