?

Average Error: 3.4 → 0.7
Time: 7.1s
Precision: binary64
Cost: 1608

?

\[ \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^{+157}:\\ \;\;\;\;y \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;y \cdot z \leq 10^{+127}:\\ \;\;\;\;x \cdot \frac{1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}{y \cdot z + 1}\\ \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) -1e+157)
   (* y (* (- z) x))
   (if (<= (* y z) 1e+127)
     (* x (/ (- 1.0 (* (* y z) (* y z))) (+ (* y z) 1.0)))
     (* 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+157) {
		tmp = y * (-z * x);
	} else if ((y * z) <= 1e+127) {
		tmp = x * ((1.0 - ((y * z) * (y * z))) / ((y * z) + 1.0));
	} 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+157)) then
        tmp = y * (-z * x)
    else if ((y * z) <= 1d+127) then
        tmp = x * ((1.0d0 - ((y * z) * (y * z))) / ((y * z) + 1.0d0))
    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+157) {
		tmp = y * (-z * x);
	} else if ((y * z) <= 1e+127) {
		tmp = x * ((1.0 - ((y * z) * (y * z))) / ((y * z) + 1.0));
	} 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+157:
		tmp = y * (-z * x)
	elif (y * z) <= 1e+127:
		tmp = x * ((1.0 - ((y * z) * (y * z))) / ((y * z) + 1.0))
	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+157)
		tmp = Float64(y * Float64(Float64(-z) * x));
	elseif (Float64(y * z) <= 1e+127)
		tmp = Float64(x * Float64(Float64(1.0 - Float64(Float64(y * z) * Float64(y * z))) / Float64(Float64(y * z) + 1.0)));
	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) <= -1e+157)
		tmp = y * (-z * x);
	elseif ((y * z) <= 1e+127)
		tmp = x * ((1.0 - ((y * z) * (y * z))) / ((y * z) + 1.0));
	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+157], N[(y * N[((-z) * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 1e+127], N[(x * N[(N[(1.0 - N[(N[(y * z), $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] + 1.0), $MachinePrecision]), $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 -1 \cdot 10^{+157}:\\
\;\;\;\;y \cdot \left(\left(-z\right) \cdot x\right)\\

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

\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) < -9.99999999999999983e156

    1. Initial program 20.6

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

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

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

      [Start]2.2

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

      mul-1-neg [=>]2.2

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

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

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

      distribute-lft-neg-in [=>]2.2

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

    if -9.99999999999999983e156 < (*.f64 y z) < 9.99999999999999955e126

    1. Initial program 0.1

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

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

    if 9.99999999999999955e126 < (*.f64 y z)

    1. Initial program 15.6

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

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

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

      [Start]3.2

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

      mul-1-neg [=>]3.2

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

      *-commutative [=>]3.2

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

      associate-*l* [=>]4.0

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

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

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

      *-commutative [<=]4.0

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

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

      \[ z \cdot \color{blue}{\left(y \cdot \left(-x\right)\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^{+157}:\\ \;\;\;\;y \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;y \cdot z \leq 10^{+127}:\\ \;\;\;\;x \cdot \frac{1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}{y \cdot z + 1}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.8
Cost1096
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+178}:\\ \;\;\;\;y \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+99}:\\ \;\;\;\;\frac{x}{\frac{1}{1 - y \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{\frac{-1}{x}}\\ \end{array} \]
Alternative 2
Error0.5
Cost968
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -2 \cdot 10^{+234}:\\ \;\;\;\;y \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;y \cdot z \leq 10^{+127}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \end{array} \]
Alternative 3
Error19.4
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+161} \lor \neg \left(y \leq -4 \cdot 10^{+54}\right) \land \left(y \leq -7.5 \cdot 10^{+29} \lor \neg \left(y \leq 4.1 \cdot 10^{-154}\right)\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error17.8
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -4.7 \cdot 10^{+151} \lor \neg \left(y \leq -4.2 \cdot 10^{+55} \lor \neg \left(y \leq -6 \cdot 10^{+28}\right) \land y \leq 4.1 \cdot 10^{-154}\right):\\ \;\;\;\;y \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error17.8
Cost912
\[\begin{array}{l} t_0 := y \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{if}\;y \leq -4.9 \cdot 10^{+153}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -8 \cdot 10^{+55}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{+29}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-154}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error25.6
Cost64
\[x \]

Error

Reproduce?

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