| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 832 |
\[\left(1 - m\right) \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} + -1\right)
\]
(FPCore (m v) :precision binary64 (* (- (/ (* m (- 1.0 m)) v) 1.0) (- 1.0 m)))
(FPCore (m v) :precision binary64 (if (<= m 2.8e-20) (+ -1.0 (+ m (/ m v))) (* (- 1.0 m) (* m (/ (- 1.0 m) v)))))
double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m);
}
double code(double m, double v) {
double tmp;
if (m <= 2.8e-20) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = (1.0 - m) * (m * ((1.0 - m) / v));
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = (((m * (1.0d0 - m)) / v) - 1.0d0) * (1.0d0 - m)
end function
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 2.8d-20) then
tmp = (-1.0d0) + (m + (m / v))
else
tmp = (1.0d0 - m) * (m * ((1.0d0 - m) / v))
end if
code = tmp
end function
public static double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m);
}
public static double code(double m, double v) {
double tmp;
if (m <= 2.8e-20) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = (1.0 - m) * (m * ((1.0 - m) / v));
}
return tmp;
}
def code(m, v): return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m)
def code(m, v): tmp = 0 if m <= 2.8e-20: tmp = -1.0 + (m + (m / v)) else: tmp = (1.0 - m) * (m * ((1.0 - m) / v)) return tmp
function code(m, v) return Float64(Float64(Float64(Float64(m * Float64(1.0 - m)) / v) - 1.0) * Float64(1.0 - m)) end
function code(m, v) tmp = 0.0 if (m <= 2.8e-20) tmp = Float64(-1.0 + Float64(m + Float64(m / v))); else tmp = Float64(Float64(1.0 - m) * Float64(m * Float64(Float64(1.0 - m) / v))); end return tmp end
function tmp = code(m, v) tmp = (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m); end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 2.8e-20) tmp = -1.0 + (m + (m / v)); else tmp = (1.0 - m) * (m * ((1.0 - m) / v)); end tmp_2 = tmp; end
code[m_, v_] := N[(N[(N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] - 1.0), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision]
code[m_, v_] := If[LessEqual[m, 2.8e-20], N[(-1.0 + N[(m + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - m), $MachinePrecision] * N[(m * N[(N[(1.0 - m), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right)
\begin{array}{l}
\mathbf{if}\;m \leq 2.8 \cdot 10^{-20}:\\
\;\;\;\;-1 + \left(m + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - m\right) \cdot \left(m \cdot \frac{1 - m}{v}\right)\\
\end{array}
Results
if m < 2.8000000000000003e-20Initial program 0.0
Simplified0.0
[Start]0.0 | \[ \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right)
\] |
|---|---|
*-commutative [=>]0.0 | \[ \color{blue}{\left(1 - m\right) \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)}
\] |
sub-neg [=>]0.0 | \[ \left(1 - m\right) \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)}
\] |
associate-/l* [=>]0.0 | \[ \left(1 - m\right) \cdot \left(\color{blue}{\frac{m}{\frac{v}{1 - m}}} + \left(-1\right)\right)
\] |
metadata-eval [=>]0.0 | \[ \left(1 - m\right) \cdot \left(\frac{m}{\frac{v}{1 - m}} + \color{blue}{-1}\right)
\] |
Taylor expanded in m around 0 0.1
Simplified0.0
[Start]0.1 | \[ \left(1 + \frac{1}{v}\right) \cdot m - 1
\] |
|---|---|
sub-neg [=>]0.1 | \[ \color{blue}{\left(1 + \frac{1}{v}\right) \cdot m + \left(-1\right)}
\] |
metadata-eval [=>]0.1 | \[ \left(1 + \frac{1}{v}\right) \cdot m + \color{blue}{-1}
\] |
+-commutative [=>]0.1 | \[ \color{blue}{-1 + \left(1 + \frac{1}{v}\right) \cdot m}
\] |
*-commutative [=>]0.1 | \[ -1 + \color{blue}{m \cdot \left(1 + \frac{1}{v}\right)}
\] |
distribute-rgt-in [=>]0.1 | \[ -1 + \color{blue}{\left(1 \cdot m + \frac{1}{v} \cdot m\right)}
\] |
*-lft-identity [=>]0.1 | \[ -1 + \left(\color{blue}{m} + \frac{1}{v} \cdot m\right)
\] |
associate-*l/ [=>]0.0 | \[ -1 + \left(m + \color{blue}{\frac{1 \cdot m}{v}}\right)
\] |
associate-*r/ [<=]0.0 | \[ -1 + \left(m + \color{blue}{1 \cdot \frac{m}{v}}\right)
\] |
*-lft-identity [=>]0.0 | \[ -1 + \left(m + \color{blue}{\frac{m}{v}}\right)
\] |
if 2.8000000000000003e-20 < m Initial program 0.4
Taylor expanded in v around 0 1.2
Applied egg-rr1.1
Applied egg-rr1.2
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 832 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 832 |
| Alternative 3 | |
|---|---|
| Error | 0.1 |
| Cost | 832 |
| Alternative 4 | |
|---|---|
| Error | 2.2 |
| Cost | 708 |
| Alternative 5 | |
|---|---|
| Error | 2.1 |
| Cost | 708 |
| Alternative 6 | |
|---|---|
| Error | 2.1 |
| Cost | 708 |
| Alternative 7 | |
|---|---|
| Error | 24.0 |
| Cost | 588 |
| Alternative 8 | |
|---|---|
| Error | 2.2 |
| Cost | 580 |
| Alternative 9 | |
|---|---|
| Error | 9.4 |
| Cost | 448 |
| Alternative 10 | |
|---|---|
| Error | 36.5 |
| Cost | 192 |
| Alternative 11 | |
|---|---|
| Error | 36.8 |
| Cost | 64 |
herbie shell --seed 2023016
(FPCore (m v)
:name "b parameter of renormalized beta distribution"
:precision binary64
:pre (and (and (< 0.0 m) (< 0.0 v)) (< v 0.25))
(* (- (/ (* m (- 1.0 m)) v) 1.0) (- 1.0 m)))