?

Average Error: 5.43% → 2.75%
Time: 6.6s
Precision: binary64
Cost: 713

?

\[ \begin{array}{c}[y, z] = \mathsf{sort}([y, z])\\ \end{array} \]
\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} \mathbf{if}\;x \leq -9.8 \cdot 10^{+48} \lor \neg \left(x \leq 3.5 \cdot 10^{+23}\right):\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \left(x \cdot z\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -9.8e+48) (not (<= x 3.5e+23)))
   (* x (- 1.0 (* y z)))
   (- x (* y (* x z)))))
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 ((x <= -9.8e+48) || !(x <= 3.5e+23)) {
		tmp = x * (1.0 - (y * z));
	} else {
		tmp = x - (y * (x * z));
	}
	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 ((x <= (-9.8d+48)) .or. (.not. (x <= 3.5d+23))) then
        tmp = x * (1.0d0 - (y * z))
    else
        tmp = x - (y * (x * z))
    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 ((x <= -9.8e+48) || !(x <= 3.5e+23)) {
		tmp = x * (1.0 - (y * z));
	} else {
		tmp = x - (y * (x * z));
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - (y * z))
def code(x, y, z):
	tmp = 0
	if (x <= -9.8e+48) or not (x <= 3.5e+23):
		tmp = x * (1.0 - (y * z))
	else:
		tmp = x - (y * (x * z))
	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 ((x <= -9.8e+48) || !(x <= 3.5e+23))
		tmp = Float64(x * Float64(1.0 - Float64(y * z)));
	else
		tmp = Float64(x - Float64(y * Float64(x * z)));
	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 ((x <= -9.8e+48) || ~((x <= 3.5e+23)))
		tmp = x * (1.0 - (y * z));
	else
		tmp = x - (y * (x * z));
	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[Or[LessEqual[x, -9.8e+48], N[Not[LessEqual[x, 3.5e+23]], $MachinePrecision]], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{+48} \lor \neg \left(x \leq 3.5 \cdot 10^{+23}\right):\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(x \cdot z\right)\\


\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 x < -9.80000000000000059e48 or 3.5000000000000002e23 < x

    1. Initial program 0.13

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

    if -9.80000000000000059e48 < x < 3.5000000000000002e23

    1. Initial program 8.26

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

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

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

      [Start]8.26

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

      *-commutative [=>]8.26

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

      distribute-rgt-out-- [<=]8.25

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

      *-lft-identity [=>]8.25

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

      associate-*r* [<=]4.15

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.8 \cdot 10^{+48} \lor \neg \left(x \leq 3.5 \cdot 10^{+23}\right):\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.98%
Cost708
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq 5 \cdot 10^{+180}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \end{array} \]
Alternative 2
Error28.49%
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{-77} \lor \neg \left(z \leq 6.5 \cdot 10^{+72}\right):\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error27.38%
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -1.02 \cdot 10^{-63}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+72}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \end{array} \]
Alternative 4
Error27.23%
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{-76}:\\ \;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+72}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \end{array} \]
Alternative 5
Error39.78%
Cost64
\[x \]

Error

Reproduce?

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