
(FPCore (m v) :precision binary64 (* (- (/ (* m (- 1.0 m)) v) 1.0) m))
double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * m;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = (((m * (1.0d0 - m)) / v) - 1.0d0) * m
end function
public static double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * m;
}
def code(m, v): return (((m * (1.0 - m)) / v) - 1.0) * m
function code(m, v) return Float64(Float64(Float64(Float64(m * Float64(1.0 - m)) / v) - 1.0) * m) end
function tmp = code(m, v) tmp = (((m * (1.0 - m)) / v) - 1.0) * m; end
code[m_, v_] := N[(N[(N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] - 1.0), $MachinePrecision] * m), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (m v) :precision binary64 (* (- (/ (* m (- 1.0 m)) v) 1.0) m))
double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * m;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = (((m * (1.0d0 - m)) / v) - 1.0d0) * m
end function
public static double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * m;
}
def code(m, v): return (((m * (1.0 - m)) / v) - 1.0) * m
function code(m, v) return Float64(Float64(Float64(Float64(m * Float64(1.0 - m)) / v) - 1.0) * m) end
function tmp = code(m, v) tmp = (((m * (1.0 - m)) / v) - 1.0) * m; end
code[m_, v_] := N[(N[(N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] - 1.0), $MachinePrecision] * m), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m
\end{array}
(FPCore (m v) :precision binary64 (if (<= m 1.05e-39) (- (* m (/ m v)) m) (/ m (/ (/ v m) (- 1.0 m)))))
double code(double m, double v) {
double tmp;
if (m <= 1.05e-39) {
tmp = (m * (m / v)) - m;
} else {
tmp = m / ((v / m) / (1.0 - m));
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.05d-39) then
tmp = (m * (m / v)) - m
else
tmp = m / ((v / m) / (1.0d0 - m))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.05e-39) {
tmp = (m * (m / v)) - m;
} else {
tmp = m / ((v / m) / (1.0 - m));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.05e-39: tmp = (m * (m / v)) - m else: tmp = m / ((v / m) / (1.0 - m)) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.05e-39) tmp = Float64(Float64(m * Float64(m / v)) - m); else tmp = Float64(m / Float64(Float64(v / m) / Float64(1.0 - m))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.05e-39) tmp = (m * (m / v)) - m; else tmp = m / ((v / m) / (1.0 - m)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.05e-39], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m / N[(N[(v / m), $MachinePrecision] / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.05 \cdot 10^{-39}:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{\frac{\frac{v}{m}}{1 - m}}\\
\end{array}
\end{array}
if m < 1.04999999999999997e-39Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
associate-*r/99.7%
fma-def99.7%
metadata-eval99.7%
Simplified99.7%
metadata-eval99.7%
fma-neg99.7%
associate-*r/99.7%
*-commutative99.7%
associate-/l*99.7%
Applied egg-rr99.7%
sub-neg99.7%
metadata-eval99.7%
distribute-rgt-in99.7%
associate-/r/99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
associate-/r/99.7%
div-inv99.7%
clear-num99.7%
associate-*r*99.7%
neg-mul-199.7%
Applied egg-rr99.7%
Taylor expanded in m around 0 86.2%
unpow286.2%
associate-*r/99.7%
Simplified99.7%
if 1.04999999999999997e-39 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.8%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.8%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 99.9%
unpow299.9%
associate-*r*99.8%
associate-*r/99.9%
associate-*r/99.9%
Simplified99.9%
*-commutative99.9%
associate-/r/99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.8%
(FPCore (m v)
:precision binary64
(let* ((t_0 (/ m (/ v m))))
(if (<= m 2.25e-187)
(- m)
(if (<= m 2.2e-88)
t_0
(if (<= m 3.2e-85) (- m) (if (<= m 1.0) t_0 (/ m (/ (- v) m))))))))
double code(double m, double v) {
double t_0 = m / (v / m);
double tmp;
if (m <= 2.25e-187) {
tmp = -m;
} else if (m <= 2.2e-88) {
tmp = t_0;
} else if (m <= 3.2e-85) {
tmp = -m;
} else if (m <= 1.0) {
tmp = t_0;
} else {
tmp = m / (-v / m);
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: t_0
real(8) :: tmp
t_0 = m / (v / m)
if (m <= 2.25d-187) then
tmp = -m
else if (m <= 2.2d-88) then
tmp = t_0
else if (m <= 3.2d-85) then
tmp = -m
else if (m <= 1.0d0) then
tmp = t_0
else
tmp = m / (-v / m)
end if
code = tmp
end function
public static double code(double m, double v) {
double t_0 = m / (v / m);
double tmp;
if (m <= 2.25e-187) {
tmp = -m;
} else if (m <= 2.2e-88) {
tmp = t_0;
} else if (m <= 3.2e-85) {
tmp = -m;
} else if (m <= 1.0) {
tmp = t_0;
} else {
tmp = m / (-v / m);
}
return tmp;
}
def code(m, v): t_0 = m / (v / m) tmp = 0 if m <= 2.25e-187: tmp = -m elif m <= 2.2e-88: tmp = t_0 elif m <= 3.2e-85: tmp = -m elif m <= 1.0: tmp = t_0 else: tmp = m / (-v / m) return tmp
function code(m, v) t_0 = Float64(m / Float64(v / m)) tmp = 0.0 if (m <= 2.25e-187) tmp = Float64(-m); elseif (m <= 2.2e-88) tmp = t_0; elseif (m <= 3.2e-85) tmp = Float64(-m); elseif (m <= 1.0) tmp = t_0; else tmp = Float64(m / Float64(Float64(-v) / m)); end return tmp end
function tmp_2 = code(m, v) t_0 = m / (v / m); tmp = 0.0; if (m <= 2.25e-187) tmp = -m; elseif (m <= 2.2e-88) tmp = t_0; elseif (m <= 3.2e-85) tmp = -m; elseif (m <= 1.0) tmp = t_0; else tmp = m / (-v / m); end tmp_2 = tmp; end
code[m_, v_] := Block[{t$95$0 = N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, 2.25e-187], (-m), If[LessEqual[m, 2.2e-88], t$95$0, If[LessEqual[m, 3.2e-85], (-m), If[LessEqual[m, 1.0], t$95$0, N[(m / N[((-v) / m), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{m}{\frac{v}{m}}\\
\mathbf{if}\;m \leq 2.25 \cdot 10^{-187}:\\
\;\;\;\;-m\\
\mathbf{elif}\;m \leq 2.2 \cdot 10^{-88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;m \leq 3.2 \cdot 10^{-85}:\\
\;\;\;\;-m\\
\mathbf{elif}\;m \leq 1:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{\frac{-v}{m}}\\
\end{array}
\end{array}
if m < 2.2499999999999999e-187 or 2.20000000000000005e-88 < m < 3.20000000000000027e-85Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/80.6%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/100.0%
associate-*r*100.0%
*-commutative100.0%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 79.7%
neg-mul-179.7%
Simplified79.7%
if 2.2499999999999999e-187 < m < 2.20000000000000005e-88 or 3.20000000000000027e-85 < m < 1Initial program 99.6%
*-commutative99.6%
sub-neg99.6%
distribute-lft-in99.6%
*-commutative99.6%
associate-*l/91.6%
associate-*r/99.6%
*-lft-identity99.6%
associate-*l/99.5%
associate-*r*99.5%
*-commutative99.5%
distribute-rgt-out99.5%
associate-*r/99.6%
associate-/l*99.6%
/-rgt-identity99.6%
associate-*l/99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in v around 0 63.1%
unpow263.1%
associate-*r*63.1%
associate-*r/70.2%
associate-*r/70.1%
Simplified70.1%
*-commutative70.1%
associate-/r/70.1%
clear-num70.1%
un-div-inv70.4%
Applied egg-rr70.4%
Taylor expanded in m around 0 69.8%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 99.9%
unpow299.9%
associate-*r*99.9%
associate-*r/99.9%
associate-*r/99.9%
Simplified99.9%
*-commutative99.9%
associate-/r/99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in m around 0 0.1%
associate-/r/0.1%
associate-*l/0.1%
add-sqr-sqrt0.1%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.0%
add-sqr-sqrt81.8%
neg-mul-181.8%
times-frac81.8%
Applied egg-rr81.8%
*-commutative81.8%
times-frac81.8%
associate-/l*81.8%
*-commutative81.8%
neg-mul-181.8%
Simplified81.8%
Final simplification77.4%
(FPCore (m v) :precision binary64 (if (or (<= v 5.1e-223) (and (not (<= v 2.3e-173)) (<= v 2.6e-145))) (* m (/ m v)) (- m)))
double code(double m, double v) {
double tmp;
if ((v <= 5.1e-223) || (!(v <= 2.3e-173) && (v <= 2.6e-145))) {
tmp = m * (m / v);
} else {
tmp = -m;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if ((v <= 5.1d-223) .or. (.not. (v <= 2.3d-173)) .and. (v <= 2.6d-145)) then
tmp = m * (m / v)
else
tmp = -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if ((v <= 5.1e-223) || (!(v <= 2.3e-173) && (v <= 2.6e-145))) {
tmp = m * (m / v);
} else {
tmp = -m;
}
return tmp;
}
def code(m, v): tmp = 0 if (v <= 5.1e-223) or (not (v <= 2.3e-173) and (v <= 2.6e-145)): tmp = m * (m / v) else: tmp = -m return tmp
function code(m, v) tmp = 0.0 if ((v <= 5.1e-223) || (!(v <= 2.3e-173) && (v <= 2.6e-145))) tmp = Float64(m * Float64(m / v)); else tmp = Float64(-m); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if ((v <= 5.1e-223) || (~((v <= 2.3e-173)) && (v <= 2.6e-145))) tmp = m * (m / v); else tmp = -m; end tmp_2 = tmp; end
code[m_, v_] := If[Or[LessEqual[v, 5.1e-223], And[N[Not[LessEqual[v, 2.3e-173]], $MachinePrecision], LessEqual[v, 2.6e-145]]], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision], (-m)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 5.1 \cdot 10^{-223} \lor \neg \left(v \leq 2.3 \cdot 10^{-173}\right) \land v \leq 2.6 \cdot 10^{-145}:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\mathbf{else}:\\
\;\;\;\;-m\\
\end{array}
\end{array}
if v < 5.09999999999999974e-223 or 2.29999999999999988e-173 < v < 2.6e-145Initial program 99.6%
*-commutative99.6%
sub-neg99.6%
distribute-lft-in99.6%
*-commutative99.6%
associate-*l/83.8%
associate-*r/99.7%
*-lft-identity99.7%
associate-*l/99.7%
associate-*r*99.7%
*-commutative99.7%
distribute-rgt-out99.6%
associate-*r/99.6%
associate-/l*99.6%
/-rgt-identity99.6%
associate-*l/99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in v around 0 78.5%
unpow278.5%
associate-*r*78.5%
associate-*r/90.6%
associate-*r/90.7%
Simplified90.7%
Taylor expanded in m around 0 33.4%
unpow233.4%
associate-*r/45.6%
Simplified45.6%
if 5.09999999999999974e-223 < v < 2.29999999999999988e-173 or 2.6e-145 < v Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/98.8%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.8%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 43.5%
neg-mul-143.5%
Simplified43.5%
Final simplification44.3%
(FPCore (m v) :precision binary64 (if (or (<= v 2.45e-223) (and (not (<= v 8.2e-174)) (<= v 7e-146))) (/ m (/ v m)) (- m)))
double code(double m, double v) {
double tmp;
if ((v <= 2.45e-223) || (!(v <= 8.2e-174) && (v <= 7e-146))) {
tmp = m / (v / m);
} else {
tmp = -m;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if ((v <= 2.45d-223) .or. (.not. (v <= 8.2d-174)) .and. (v <= 7d-146)) then
tmp = m / (v / m)
else
tmp = -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if ((v <= 2.45e-223) || (!(v <= 8.2e-174) && (v <= 7e-146))) {
tmp = m / (v / m);
} else {
tmp = -m;
}
return tmp;
}
def code(m, v): tmp = 0 if (v <= 2.45e-223) or (not (v <= 8.2e-174) and (v <= 7e-146)): tmp = m / (v / m) else: tmp = -m return tmp
function code(m, v) tmp = 0.0 if ((v <= 2.45e-223) || (!(v <= 8.2e-174) && (v <= 7e-146))) tmp = Float64(m / Float64(v / m)); else tmp = Float64(-m); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if ((v <= 2.45e-223) || (~((v <= 8.2e-174)) && (v <= 7e-146))) tmp = m / (v / m); else tmp = -m; end tmp_2 = tmp; end
code[m_, v_] := If[Or[LessEqual[v, 2.45e-223], And[N[Not[LessEqual[v, 8.2e-174]], $MachinePrecision], LessEqual[v, 7e-146]]], N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision], (-m)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 2.45 \cdot 10^{-223} \lor \neg \left(v \leq 8.2 \cdot 10^{-174}\right) \land v \leq 7 \cdot 10^{-146}:\\
\;\;\;\;\frac{m}{\frac{v}{m}}\\
\mathbf{else}:\\
\;\;\;\;-m\\
\end{array}
\end{array}
if v < 2.45e-223 or 8.2000000000000002e-174 < v < 7.0000000000000003e-146Initial program 99.6%
*-commutative99.6%
sub-neg99.6%
distribute-lft-in99.6%
*-commutative99.6%
associate-*l/83.8%
associate-*r/99.7%
*-lft-identity99.7%
associate-*l/99.7%
associate-*r*99.7%
*-commutative99.7%
distribute-rgt-out99.6%
associate-*r/99.6%
associate-/l*99.6%
/-rgt-identity99.6%
associate-*l/99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in v around 0 78.5%
unpow278.5%
associate-*r*78.5%
associate-*r/90.6%
associate-*r/90.7%
Simplified90.7%
*-commutative90.7%
associate-/r/90.6%
clear-num90.6%
un-div-inv90.8%
Applied egg-rr90.8%
Taylor expanded in m around 0 45.7%
if 2.45e-223 < v < 8.2000000000000002e-174 or 7.0000000000000003e-146 < v Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/98.8%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.8%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 43.5%
neg-mul-143.5%
Simplified43.5%
Final simplification44.4%
(FPCore (m v) :precision binary64 (if (<= m 1e-30) (- (* m (/ m v)) m) (* m (* m (/ (- 1.0 m) v)))))
double code(double m, double v) {
double tmp;
if (m <= 1e-30) {
tmp = (m * (m / v)) - m;
} else {
tmp = m * (m * ((1.0 - m) / v));
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1d-30) then
tmp = (m * (m / v)) - m
else
tmp = m * (m * ((1.0d0 - m) / v))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1e-30) {
tmp = (m * (m / v)) - m;
} else {
tmp = m * (m * ((1.0 - m) / v));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1e-30: tmp = (m * (m / v)) - m else: tmp = m * (m * ((1.0 - m) / v)) return tmp
function code(m, v) tmp = 0.0 if (m <= 1e-30) tmp = Float64(Float64(m * Float64(m / v)) - m); else tmp = Float64(m * Float64(m * Float64(Float64(1.0 - m) / v))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1e-30) tmp = (m * (m / v)) - m; else tmp = m * (m * ((1.0 - m) / v)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1e-30], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m * N[(m * N[(N[(1.0 - m), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 10^{-30}:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\
\mathbf{else}:\\
\;\;\;\;m \cdot \left(m \cdot \frac{1 - m}{v}\right)\\
\end{array}
\end{array}
if m < 1e-30Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
associate-*r/99.7%
fma-def99.7%
metadata-eval99.7%
Simplified99.7%
metadata-eval99.7%
fma-neg99.7%
associate-*r/99.7%
*-commutative99.7%
associate-/l*99.7%
Applied egg-rr99.7%
sub-neg99.7%
metadata-eval99.7%
distribute-rgt-in99.7%
associate-/r/99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
associate-/r/99.7%
div-inv99.7%
clear-num99.7%
associate-*r*99.7%
neg-mul-199.7%
Applied egg-rr99.7%
Taylor expanded in m around 0 86.5%
unpow286.5%
associate-*r/99.7%
Simplified99.7%
if 1e-30 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 99.9%
unpow299.9%
associate-*r*99.9%
associate-*r/99.9%
associate-*r/99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (m v) :precision binary64 (* m (+ (* (/ m v) (- 1.0 m)) -1.0)))
double code(double m, double v) {
return m * (((m / v) * (1.0 - m)) + -1.0);
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = m * (((m / v) * (1.0d0 - m)) + (-1.0d0))
end function
public static double code(double m, double v) {
return m * (((m / v) * (1.0 - m)) + -1.0);
}
def code(m, v): return m * (((m / v) * (1.0 - m)) + -1.0)
function code(m, v) return Float64(m * Float64(Float64(Float64(m / v) * Float64(1.0 - m)) + -1.0)) end
function tmp = code(m, v) tmp = m * (((m / v) * (1.0 - m)) + -1.0); end
code[m_, v_] := N[(m * N[(N[(N[(m / v), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + -1\right)
\end{array}
Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in99.8%
*-commutative99.8%
associate-*l/92.8%
associate-*r/99.8%
*-lft-identity99.8%
associate-*l/99.8%
associate-*r*99.8%
*-commutative99.8%
distribute-rgt-out99.8%
associate-*r/99.8%
associate-/l*99.8%
/-rgt-identity99.8%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (* m (+ (/ m v) -1.0)) (* m (* m (/ (- m) v)))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = m * ((m / v) + -1.0);
} else {
tmp = m * (m * (-m / v));
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.0d0) then
tmp = m * ((m / v) + (-1.0d0))
else
tmp = m * (m * (-m / v))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = m * ((m / v) + -1.0);
} else {
tmp = m * (m * (-m / v));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = m * ((m / v) + -1.0) else: tmp = m * (m * (-m / v)) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(m * Float64(Float64(m / v) + -1.0)); else tmp = Float64(m * Float64(m * Float64(Float64(-m) / v))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = m * ((m / v) + -1.0); else tmp = m * (m * (-m / v)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(m * N[(N[(m / v), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(m * N[(m * N[((-m) / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;m \cdot \left(m \cdot \frac{-m}{v}\right)\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
associate-*r/99.7%
fma-def99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 99.3%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 99.9%
unpow299.9%
associate-*r*99.9%
associate-*r/99.9%
associate-*r/99.9%
Simplified99.9%
*-commutative99.9%
associate-/r/99.9%
div-sub39.0%
frac-sub41.0%
*-un-lft-identity41.0%
pow241.0%
Applied egg-rr41.0%
associate-*l/95.8%
associate-/l*95.8%
Simplified95.8%
Taylor expanded in m around inf 97.7%
*-commutative97.7%
unpow297.7%
associate-*r/97.7%
associate-*l*97.7%
associate-*l/97.7%
*-commutative97.7%
mul-1-neg97.7%
Simplified97.7%
Final simplification98.6%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (- (* m (/ m v)) m) (* m (* m (/ (- m) v)))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m * (m / v)) - m;
} else {
tmp = m * (m * (-m / v));
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.0d0) then
tmp = (m * (m / v)) - m
else
tmp = m * (m * (-m / v))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m * (m / v)) - m;
} else {
tmp = m * (m * (-m / v));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (m * (m / v)) - m else: tmp = m * (m * (-m / v)) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(Float64(m * Float64(m / v)) - m); else tmp = Float64(m * Float64(m * Float64(Float64(-m) / v))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = (m * (m / v)) - m; else tmp = m * (m * (-m / v)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m * N[(m * N[((-m) / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\
\mathbf{else}:\\
\;\;\;\;m \cdot \left(m \cdot \frac{-m}{v}\right)\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
associate-*r/99.7%
fma-def99.7%
metadata-eval99.7%
Simplified99.7%
metadata-eval99.7%
fma-neg99.7%
associate-*r/99.7%
*-commutative99.7%
associate-/l*99.7%
Applied egg-rr99.7%
sub-neg99.7%
metadata-eval99.7%
distribute-rgt-in99.7%
associate-/r/99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
associate-/r/99.7%
div-inv99.7%
clear-num99.7%
associate-*r*99.7%
neg-mul-199.7%
Applied egg-rr99.7%
Taylor expanded in m around 0 86.7%
unpow286.7%
associate-*r/99.4%
Simplified99.4%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 99.9%
unpow299.9%
associate-*r*99.9%
associate-*r/99.9%
associate-*r/99.9%
Simplified99.9%
*-commutative99.9%
associate-/r/99.9%
div-sub39.0%
frac-sub41.0%
*-un-lft-identity41.0%
pow241.0%
Applied egg-rr41.0%
associate-*l/95.8%
associate-/l*95.8%
Simplified95.8%
Taylor expanded in m around inf 97.7%
*-commutative97.7%
unpow297.7%
associate-*r/97.7%
associate-*l*97.7%
associate-*l/97.7%
*-commutative97.7%
mul-1-neg97.7%
Simplified97.7%
Final simplification98.6%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (* m (+ (/ m v) -1.0)) (/ m (/ (- v) m))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = m * ((m / v) + -1.0);
} else {
tmp = m / (-v / m);
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.0d0) then
tmp = m * ((m / v) + (-1.0d0))
else
tmp = m / (-v / m)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = m * ((m / v) + -1.0);
} else {
tmp = m / (-v / m);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = m * ((m / v) + -1.0) else: tmp = m / (-v / m) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(m * Float64(Float64(m / v) + -1.0)); else tmp = Float64(m / Float64(Float64(-v) / m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = m * ((m / v) + -1.0); else tmp = m / (-v / m); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(m * N[(N[(m / v), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(m / N[((-v) / m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{\frac{-v}{m}}\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
associate-*r/99.7%
fma-def99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 99.3%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 99.9%
unpow299.9%
associate-*r*99.9%
associate-*r/99.9%
associate-*r/99.9%
Simplified99.9%
*-commutative99.9%
associate-/r/99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in m around 0 0.1%
associate-/r/0.1%
associate-*l/0.1%
add-sqr-sqrt0.1%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.0%
add-sqr-sqrt81.8%
neg-mul-181.8%
times-frac81.8%
Applied egg-rr81.8%
*-commutative81.8%
times-frac81.8%
associate-/l*81.8%
*-commutative81.8%
neg-mul-181.8%
Simplified81.8%
Final simplification91.5%
(FPCore (m v) :precision binary64 (- m))
double code(double m, double v) {
return -m;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = -m
end function
public static double code(double m, double v) {
return -m;
}
def code(m, v): return -m
function code(m, v) return Float64(-m) end
function tmp = code(m, v) tmp = -m; end
code[m_, v_] := (-m)
\begin{array}{l}
\\
-m
\end{array}
Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in99.8%
*-commutative99.8%
associate-*l/92.8%
associate-*r/99.8%
*-lft-identity99.8%
associate-*l/99.8%
associate-*r*99.8%
*-commutative99.8%
distribute-rgt-out99.8%
associate-*r/99.8%
associate-/l*99.8%
/-rgt-identity99.8%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in m around 0 30.0%
neg-mul-130.0%
Simplified30.0%
Final simplification30.0%
herbie shell --seed 2023227
(FPCore (m v)
:name "a 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) m))