?

Average Error: 5.22% → 0.59%
Time: 7.8s
Precision: binary64
Cost: 969

?

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

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


\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.00000000000000033e192 or 5.9999999999999996e132 < (*.f64 y z)

    1. Initial program 30.9

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

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

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

      [Start]2.93

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

      mul-1-neg [=>]2.93

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

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

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

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

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

    if -5.00000000000000033e192 < (*.f64 y z) < 5.9999999999999996e132

    1. Initial program 0.13

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

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

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

      [Start]0.13

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

      *-commutative [=>]0.13

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

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

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

      *-lft-identity [=>]0.12

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

      associate-*r* [<=]8.18

      \[ x - \color{blue}{y \cdot \left(z \cdot x\right)} \]
    4. Applied egg-rr30.83

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

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

      [Start]30.83

      \[ x - \left(e^{\mathsf{log1p}\left(y \cdot \left(z \cdot x\right)\right)} - 1\right) \]

      expm1-def [=>]22.03

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

      expm1-log1p [=>]8.18

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

      associate-*r* [=>]0.12

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+192} \lor \neg \left(y \cdot z \leq 6 \cdot 10^{+132}\right):\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot x\\ \end{array} \]

Alternatives

Alternative 1
Error0.59%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+192} \lor \neg \left(y \cdot z \leq 6 \cdot 10^{+132}\right):\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \end{array} \]
Alternative 2
Error32.89%
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{+213} \lor \neg \left(y \leq -3.6 \cdot 10^{+202} \lor \neg \left(y \leq -3 \cdot 10^{+72}\right) \land y \leq 2.8 \cdot 10^{-38}\right):\\ \;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error29.88%
Cost649
\[\begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{+69} \lor \neg \left(y \leq 2.6 \cdot 10^{-39}\right):\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error30.22%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{+69}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(-y\right)\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-38}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\ \end{array} \]
Alternative 5
Error39.86%
Cost64
\[x \]

Error

Reproduce?

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