Average Error: 0.1 → 0.1
Time: 6.7s
Precision: binary64
Cost: 713
\[\left(x \cdot y\right) \cdot \left(1 - y\right) \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+153} \lor \neg \left(y \leq 4 \cdot 10^{+104}\right):\\ \;\;\;\;y \cdot \left(x \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \left(1 - y\right)\right)\\ \end{array} \]
(FPCore (x y) :precision binary64 (* (* x y) (- 1.0 y)))
(FPCore (x y)
 :precision binary64
 (if (or (<= y -1e+153) (not (<= y 4e+104)))
   (* y (* x (- y)))
   (* x (* y (- 1.0 y)))))
double code(double x, double y) {
	return (x * y) * (1.0 - y);
}
double code(double x, double y) {
	double tmp;
	if ((y <= -1e+153) || !(y <= 4e+104)) {
		tmp = y * (x * -y);
	} else {
		tmp = x * (y * (1.0 - y));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x * y) * (1.0d0 - y)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-1d+153)) .or. (.not. (y <= 4d+104))) then
        tmp = y * (x * -y)
    else
        tmp = x * (y * (1.0d0 - y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return (x * y) * (1.0 - y);
}
public static double code(double x, double y) {
	double tmp;
	if ((y <= -1e+153) || !(y <= 4e+104)) {
		tmp = y * (x * -y);
	} else {
		tmp = x * (y * (1.0 - y));
	}
	return tmp;
}
def code(x, y):
	return (x * y) * (1.0 - y)
def code(x, y):
	tmp = 0
	if (y <= -1e+153) or not (y <= 4e+104):
		tmp = y * (x * -y)
	else:
		tmp = x * (y * (1.0 - y))
	return tmp
function code(x, y)
	return Float64(Float64(x * y) * Float64(1.0 - y))
end
function code(x, y)
	tmp = 0.0
	if ((y <= -1e+153) || !(y <= 4e+104))
		tmp = Float64(y * Float64(x * Float64(-y)));
	else
		tmp = Float64(x * Float64(y * Float64(1.0 - y)));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = (x * y) * (1.0 - y);
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -1e+153) || ~((y <= 4e+104)))
		tmp = y * (x * -y);
	else
		tmp = x * (y * (1.0 - y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[Or[LessEqual[y, -1e+153], N[Not[LessEqual[y, 4e+104]], $MachinePrecision]], N[(y * N[(x * (-y)), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(x \cdot y\right) \cdot \left(1 - y\right)
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+153} \lor \neg \left(y \leq 4 \cdot 10^{+104}\right):\\
\;\;\;\;y \cdot \left(x \cdot \left(-y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot \left(1 - 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 2 regimes
  2. if y < -1e153 or 4e104 < y

    1. Initial program 0.3

      \[\left(x \cdot y\right) \cdot \left(1 - y\right) \]
    2. Simplified48.2

      \[\leadsto \color{blue}{x \cdot \left(y \cdot \left(1 - y\right)\right)} \]
      Proof
      (*.f64 x (*.f64 y (-.f64 1 y))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) (-.f64 1 y))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in y around inf 48.2

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

      \[\leadsto \color{blue}{y \cdot \left(x \cdot \left(-y\right)\right)} \]
      Proof
      (*.f64 y (*.f64 x (neg.f64 y))): 0 points increase in error, 0 points decrease in error
      (*.f64 y (Rewrite<= *-commutative_binary64 (*.f64 (neg.f64 y) x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y (neg.f64 y)) x)): 7 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite=> distribute-rgt-neg-out_binary64 (neg.f64 (*.f64 y y))) x): 0 points increase in error, 7 points decrease in error
      (*.f64 (neg.f64 (Rewrite<= unpow2_binary64 (pow.f64 y 2))) x): 0 points increase in error, 7 points decrease in error
      (*.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (pow.f64 y 2))) x): 0 points increase in error, 5 points decrease in error
      (Rewrite<= associate-*r*_binary64 (*.f64 -1 (*.f64 (pow.f64 y 2) x))): 0 points increase in error, 0 points decrease in error

    if -1e153 < y < 4e104

    1. Initial program 0.1

      \[\left(x \cdot y\right) \cdot \left(1 - y\right) \]
    2. Simplified0.1

      \[\leadsto \color{blue}{x \cdot \left(y \cdot \left(1 - y\right)\right)} \]
      Proof
      (*.f64 x (*.f64 y (-.f64 1 y))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) (-.f64 1 y))): 0 points increase in error, 0 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+153} \lor \neg \left(y \leq 4 \cdot 10^{+104}\right):\\ \;\;\;\;y \cdot \left(x \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \left(1 - y\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.0
Cost649
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y \cdot \left(x \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Error0.1
Cost448
\[\left(1 - y\right) \cdot \left(x \cdot y\right) \]
Alternative 3
Error21.4
Cost192
\[x \cdot y \]
Alternative 4
Error61.7
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (x y)
  :name "Statistics.Distribution.Binomial:$cvariance from math-functions-0.1.5.2"
  :precision binary64
  (* (* x y) (- 1.0 y)))