| Alternative 1 | |
|---|---|
| Error | 2.0 |
| Cost | 649 |
\[\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}
\]
(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}
Results
if y < -1e153 or 4e104 < y Initial program 0.3
Simplified48.2
Taylor expanded in y around inf 48.2
Simplified0.3
if -1e153 < y < 4e104Initial program 0.1
Simplified0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 2.0 |
| Cost | 649 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 448 |
| Alternative 3 | |
|---|---|
| Error | 21.4 |
| Cost | 192 |
| Alternative 4 | |
|---|---|
| Error | 61.7 |
| Cost | 64 |
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)))