
(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 11 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.25e-23) (- (/ m (/ v m)) m) (* (/ m v) (* m (- 1.0 m)))))
double code(double m, double v) {
double tmp;
if (m <= 1.25e-23) {
tmp = (m / (v / m)) - 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.25d-23) then
tmp = (m / (v / m)) - 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.25e-23) {
tmp = (m / (v / m)) - m;
} else {
tmp = (m / v) * (m * (1.0 - m));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.25e-23: tmp = (m / (v / m)) - m else: tmp = (m / v) * (m * (1.0 - m)) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.25e-23) tmp = Float64(Float64(m / Float64(v / m)) - m); else tmp = Float64(Float64(m / v) * Float64(m * Float64(1.0 - m))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.25e-23) tmp = (m / (v / m)) - m; else tmp = (m / v) * (m * (1.0 - m)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.25e-23], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.25 \cdot 10^{-23}:\\
\;\;\;\;\frac{m}{\frac{v}{m}} - m\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(m \cdot \left(1 - m\right)\right)\\
\end{array}
\end{array}
if m < 1.2500000000000001e-23Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 99.8%
sub-neg99.8%
metadata-eval99.8%
distribute-lft-in99.8%
*-commutative99.8%
neg-mul-199.8%
unsub-neg99.8%
associate-/l*85.3%
unpow285.3%
Simplified85.3%
unpow285.3%
add-sqr-sqrt85.1%
sqrt-unprod47.8%
sqr-neg47.8%
sqrt-unprod0.0%
add-sqr-sqrt55.5%
associate-*l/55.4%
add-sqr-sqrt0.0%
sqrt-unprod48.3%
sqr-neg48.3%
sqrt-unprod99.5%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
*-commutative99.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
if 1.2500000000000001e-23 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in v around 0 99.9%
*-commutative99.9%
associate-*r/99.8%
*-lft-identity99.8%
associate-*l/99.8%
associate-/r/99.8%
associate-*r/99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt1-in99.9%
*-rgt-identity99.9%
sub-neg99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.8%
clear-num99.8%
unpow299.8%
associate-*r/99.9%
associate-*r*99.9%
/-rgt-identity99.9%
associate-/r/99.9%
associate-/l/99.9%
associate-*r/99.9%
associate-*l/99.9%
associate-/l/99.9%
associate-/r/99.9%
/-rgt-identity99.9%
associate-*l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (m v)
:precision binary64
(if (<= m 1.85e-177)
(- m)
(if (<= m 2e-133)
(/ m (/ v m))
(if (<= m 2.4e-125)
(- m)
(if (<= m 1.0) (* m (/ m v)) (* (/ m v) (- m)))))))
double code(double m, double v) {
double tmp;
if (m <= 1.85e-177) {
tmp = -m;
} else if (m <= 2e-133) {
tmp = m / (v / m);
} else if (m <= 2.4e-125) {
tmp = -m;
} else if (m <= 1.0) {
tmp = m * (m / v);
} 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.85d-177) then
tmp = -m
else if (m <= 2d-133) then
tmp = m / (v / m)
else if (m <= 2.4d-125) then
tmp = -m
else if (m <= 1.0d0) then
tmp = m * (m / v)
else
tmp = (m / v) * -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.85e-177) {
tmp = -m;
} else if (m <= 2e-133) {
tmp = m / (v / m);
} else if (m <= 2.4e-125) {
tmp = -m;
} else if (m <= 1.0) {
tmp = m * (m / v);
} else {
tmp = (m / v) * -m;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.85e-177: tmp = -m elif m <= 2e-133: tmp = m / (v / m) elif m <= 2.4e-125: tmp = -m elif m <= 1.0: tmp = m * (m / v) else: tmp = (m / v) * -m return tmp
function code(m, v) tmp = 0.0 if (m <= 1.85e-177) tmp = Float64(-m); elseif (m <= 2e-133) tmp = Float64(m / Float64(v / m)); elseif (m <= 2.4e-125) tmp = Float64(-m); elseif (m <= 1.0) tmp = Float64(m * Float64(m / v)); else tmp = Float64(Float64(m / v) * Float64(-m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.85e-177) tmp = -m; elseif (m <= 2e-133) tmp = m / (v / m); elseif (m <= 2.4e-125) tmp = -m; elseif (m <= 1.0) tmp = m * (m / v); else tmp = (m / v) * -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.85e-177], (-m), If[LessEqual[m, 2e-133], N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2.4e-125], (-m), If[LessEqual[m, 1.0], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * (-m)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.85 \cdot 10^{-177}:\\
\;\;\;\;-m\\
\mathbf{elif}\;m \leq 2 \cdot 10^{-133}:\\
\;\;\;\;\frac{m}{\frac{v}{m}}\\
\mathbf{elif}\;m \leq 2.4 \cdot 10^{-125}:\\
\;\;\;\;-m\\
\mathbf{elif}\;m \leq 1:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(-m\right)\\
\end{array}
\end{array}
if m < 1.84999999999999997e-177 or 2.0000000000000001e-133 < m < 2.4000000000000001e-125Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in m around 0 81.8%
neg-mul-181.8%
Simplified81.8%
if 1.84999999999999997e-177 < m < 2.0000000000000001e-133Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 99.7%
sub-neg99.7%
metadata-eval99.7%
distribute-lft-in99.7%
*-commutative99.7%
neg-mul-199.7%
unsub-neg99.7%
associate-/l*66.1%
unpow266.1%
Simplified66.1%
Taylor expanded in m around inf 34.6%
*-un-lft-identity34.6%
add-sqr-sqrt34.4%
sqrt-unprod2.3%
sqr-neg2.3%
sqrt-unprod0.0%
add-sqr-sqrt4.2%
neg-mul-14.2%
times-frac4.2%
metadata-eval4.2%
unpow24.2%
add-sqr-sqrt4.2%
sqrt-unprod2.4%
sqr-neg2.4%
sqrt-unprod0.0%
add-sqr-sqrt34.6%
associate-*r/67.8%
*-commutative67.8%
*-commutative67.8%
associate-*l*67.8%
Applied egg-rr3.7%
add-sqr-sqrt0.0%
sqrt-unprod34.8%
sqr-neg34.8%
sqrt-unprod67.5%
add-sqr-sqrt67.8%
associate-/r/67.9%
Applied egg-rr67.9%
if 2.4000000000000001e-125 < m < 1Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
associate-/l*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in m around 0 90.3%
sub-neg90.3%
metadata-eval90.3%
distribute-lft-in90.3%
*-commutative90.3%
neg-mul-190.3%
unsub-neg90.3%
associate-/l*90.4%
unpow290.4%
Simplified90.4%
Taylor expanded in m around inf 78.5%
unpow290.4%
add-sqr-sqrt89.8%
sqrt-unprod44.2%
sqr-neg44.2%
sqrt-unprod0.0%
add-sqr-sqrt13.0%
associate-*l/13.0%
add-sqr-sqrt0.0%
sqrt-unprod44.2%
sqr-neg44.2%
sqrt-unprod89.7%
add-sqr-sqrt90.3%
Applied egg-rr78.3%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 0.1%
sub-neg0.1%
metadata-eval0.1%
distribute-lft-in0.1%
*-commutative0.1%
neg-mul-10.1%
unsub-neg0.1%
associate-/l*0.1%
unpow20.1%
Simplified0.1%
Taylor expanded in m around inf 0.1%
*-un-lft-identity0.1%
add-sqr-sqrt0.1%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.0%
add-sqr-sqrt82.5%
neg-mul-182.5%
times-frac82.5%
metadata-eval82.5%
unpow282.5%
add-sqr-sqrt82.5%
sqrt-unprod83.7%
sqr-neg83.7%
sqrt-unprod0.0%
add-sqr-sqrt0.1%
associate-*r/0.1%
*-commutative0.1%
*-commutative0.1%
associate-*l*0.1%
Applied egg-rr82.5%
Final simplification80.7%
(FPCore (m v) :precision binary64 (if (or (<= v 1.25e-238) (and (not (<= v 2.65e-204)) (<= v 4.9e-191))) (/ m (/ v m)) (- m)))
double code(double m, double v) {
double tmp;
if ((v <= 1.25e-238) || (!(v <= 2.65e-204) && (v <= 4.9e-191))) {
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 <= 1.25d-238) .or. (.not. (v <= 2.65d-204)) .and. (v <= 4.9d-191)) 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 <= 1.25e-238) || (!(v <= 2.65e-204) && (v <= 4.9e-191))) {
tmp = m / (v / m);
} else {
tmp = -m;
}
return tmp;
}
def code(m, v): tmp = 0 if (v <= 1.25e-238) or (not (v <= 2.65e-204) and (v <= 4.9e-191)): tmp = m / (v / m) else: tmp = -m return tmp
function code(m, v) tmp = 0.0 if ((v <= 1.25e-238) || (!(v <= 2.65e-204) && (v <= 4.9e-191))) 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 <= 1.25e-238) || (~((v <= 2.65e-204)) && (v <= 4.9e-191))) tmp = m / (v / m); else tmp = -m; end tmp_2 = tmp; end
code[m_, v_] := If[Or[LessEqual[v, 1.25e-238], And[N[Not[LessEqual[v, 2.65e-204]], $MachinePrecision], LessEqual[v, 4.9e-191]]], N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision], (-m)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 1.25 \cdot 10^{-238} \lor \neg \left(v \leq 2.65 \cdot 10^{-204}\right) \land v \leq 4.9 \cdot 10^{-191}:\\
\;\;\;\;\frac{m}{\frac{v}{m}}\\
\mathbf{else}:\\
\;\;\;\;-m\\
\end{array}
\end{array}
if v < 1.25e-238 or 2.6499999999999999e-204 < v < 4.9e-191Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 51.4%
sub-neg51.4%
metadata-eval51.4%
distribute-lft-in51.4%
*-commutative51.4%
neg-mul-151.4%
unsub-neg51.4%
associate-/l*32.7%
unpow232.7%
Simplified32.7%
Taylor expanded in m around inf 29.4%
*-un-lft-identity29.4%
add-sqr-sqrt29.2%
sqrt-unprod1.2%
sqr-neg1.2%
sqrt-unprod0.0%
add-sqr-sqrt46.5%
neg-mul-146.5%
times-frac46.5%
metadata-eval46.5%
unpow246.5%
add-sqr-sqrt46.5%
sqrt-unprod45.2%
sqr-neg45.2%
sqrt-unprod0.0%
add-sqr-sqrt29.4%
associate-*r/47.8%
*-commutative47.8%
*-commutative47.8%
associate-*l*47.8%
Applied egg-rr46.3%
add-sqr-sqrt0.0%
sqrt-unprod29.3%
sqr-neg29.3%
sqrt-unprod47.7%
add-sqr-sqrt47.8%
associate-/r/47.9%
Applied egg-rr47.9%
if 1.25e-238 < v < 2.6499999999999999e-204 or 4.9e-191 < v Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 33.9%
neg-mul-133.9%
Simplified33.9%
Final simplification38.1%
(FPCore (m v) :precision binary64 (if (or (<= v 1.25e-238) (and (not (<= v 9.2e-205)) (<= v 1e-190))) (* m (/ m v)) (- m)))
double code(double m, double v) {
double tmp;
if ((v <= 1.25e-238) || (!(v <= 9.2e-205) && (v <= 1e-190))) {
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 <= 1.25d-238) .or. (.not. (v <= 9.2d-205)) .and. (v <= 1d-190)) 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 <= 1.25e-238) || (!(v <= 9.2e-205) && (v <= 1e-190))) {
tmp = m * (m / v);
} else {
tmp = -m;
}
return tmp;
}
def code(m, v): tmp = 0 if (v <= 1.25e-238) or (not (v <= 9.2e-205) and (v <= 1e-190)): tmp = m * (m / v) else: tmp = -m return tmp
function code(m, v) tmp = 0.0 if ((v <= 1.25e-238) || (!(v <= 9.2e-205) && (v <= 1e-190))) 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 <= 1.25e-238) || (~((v <= 9.2e-205)) && (v <= 1e-190))) tmp = m * (m / v); else tmp = -m; end tmp_2 = tmp; end
code[m_, v_] := If[Or[LessEqual[v, 1.25e-238], And[N[Not[LessEqual[v, 9.2e-205]], $MachinePrecision], LessEqual[v, 1e-190]]], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision], (-m)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 1.25 \cdot 10^{-238} \lor \neg \left(v \leq 9.2 \cdot 10^{-205}\right) \land v \leq 10^{-190}:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\mathbf{else}:\\
\;\;\;\;-m\\
\end{array}
\end{array}
if v < 1.25e-238 or 9.1999999999999997e-205 < v < 1e-190Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 51.4%
sub-neg51.4%
metadata-eval51.4%
distribute-lft-in51.4%
*-commutative51.4%
neg-mul-151.4%
unsub-neg51.4%
associate-/l*32.7%
unpow232.7%
Simplified32.7%
Taylor expanded in m around inf 29.4%
unpow232.7%
add-sqr-sqrt32.6%
sqrt-unprod1.2%
sqr-neg1.2%
sqrt-unprod0.0%
add-sqr-sqrt49.9%
associate-*l/49.8%
add-sqr-sqrt0.0%
sqrt-unprod1.7%
sqr-neg1.7%
sqrt-unprod51.1%
add-sqr-sqrt51.4%
Applied egg-rr47.8%
if 1.25e-238 < v < 9.1999999999999997e-205 or 1e-190 < v Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 33.9%
neg-mul-133.9%
Simplified33.9%
Final simplification38.1%
(FPCore (m v) :precision binary64 (if (<= m 2.9e-15) (- (* m (/ m v)) m) (* m (* m (/ (- 1.0 m) v)))))
double code(double m, double v) {
double tmp;
if (m <= 2.9e-15) {
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 <= 2.9d-15) 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 <= 2.9e-15) {
tmp = (m * (m / v)) - m;
} else {
tmp = m * (m * ((1.0 - m) / v));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 2.9e-15: tmp = (m * (m / v)) - m else: tmp = m * (m * ((1.0 - m) / v)) return tmp
function code(m, v) tmp = 0.0 if (m <= 2.9e-15) 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 <= 2.9e-15) tmp = (m * (m / v)) - m; else tmp = m * (m * ((1.0 - m) / v)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 2.9e-15], 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 2.9 \cdot 10^{-15}:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\
\mathbf{else}:\\
\;\;\;\;m \cdot \left(m \cdot \frac{1 - m}{v}\right)\\
\end{array}
\end{array}
if m < 2.90000000000000019e-15Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 99.8%
sub-neg99.8%
metadata-eval99.8%
distribute-lft-in99.8%
*-commutative99.8%
neg-mul-199.8%
unsub-neg99.8%
associate-/l*85.9%
unpow285.9%
Simplified85.9%
unpow285.9%
add-sqr-sqrt85.7%
sqrt-unprod49.3%
sqr-neg49.3%
sqrt-unprod0.0%
add-sqr-sqrt53.0%
associate-*l/52.9%
add-sqr-sqrt0.0%
sqrt-unprod49.9%
sqr-neg49.9%
sqrt-unprod99.5%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
if 2.90000000000000019e-15 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in v around 0 99.9%
*-commutative99.9%
associate-*r/99.8%
*-lft-identity99.8%
associate-*l/99.9%
associate-/r/99.9%
associate-*r/99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt1-in99.9%
*-rgt-identity99.9%
sub-neg99.9%
Simplified99.9%
associate-/r/99.9%
unpow299.9%
associate-*r*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (- (* m (/ m v)) m) (* m (* (/ m v) (- m)))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m * (m / v)) - m;
} else {
tmp = m * ((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)) - m
else
tmp = m * ((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)) - m;
} else {
tmp = m * ((m / v) * -m);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (m * (m / v)) - m else: tmp = m * ((m / v) * -m) 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(Float64(m / v) * Float64(-m))); 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 / v) * -m); 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[(N[(m / v), $MachinePrecision] * (-m)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\
\mathbf{else}:\\
\;\;\;\;m \cdot \left(\frac{m}{v} \cdot \left(-m\right)\right)\\
\end{array}
\end{array}
if m < 1Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 96.4%
sub-neg96.4%
metadata-eval96.4%
distribute-lft-in96.5%
*-commutative96.5%
neg-mul-196.5%
unsub-neg96.5%
associate-/l*83.4%
unpow283.4%
Simplified83.4%
unpow283.4%
add-sqr-sqrt83.2%
sqrt-unprod47.7%
sqr-neg47.7%
sqrt-unprod0.0%
add-sqr-sqrt49.8%
associate-*l/49.7%
add-sqr-sqrt0.0%
sqrt-unprod48.2%
sqr-neg48.2%
sqrt-unprod96.2%
add-sqr-sqrt96.5%
Applied egg-rr96.5%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in v around 0 99.9%
*-commutative99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-/r/99.9%
associate-*r/100.0%
sub-neg100.0%
+-commutative100.0%
distribute-rgt1-in100.0%
*-rgt-identity100.0%
sub-neg100.0%
Simplified100.0%
associate-/r/99.9%
unpow299.9%
associate-*r*99.9%
Applied egg-rr99.9%
Taylor expanded in m around inf 98.8%
neg-mul-198.8%
distribute-neg-frac298.8%
Simplified98.8%
Final simplification97.7%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (- (* m (/ m v)) m) (* (/ m v) (- m))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m * (m / v)) - m;
} 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)) - m
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)) - m;
} else {
tmp = (m / v) * -m;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (m * (m / v)) - m else: tmp = (m / v) * -m return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(Float64(m * Float64(m / v)) - m); else tmp = Float64(Float64(m / v) * Float64(-m)); 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 / v) * -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * (-m)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(-m\right)\\
\end{array}
\end{array}
if m < 1Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 96.4%
sub-neg96.4%
metadata-eval96.4%
distribute-lft-in96.5%
*-commutative96.5%
neg-mul-196.5%
unsub-neg96.5%
associate-/l*83.4%
unpow283.4%
Simplified83.4%
unpow283.4%
add-sqr-sqrt83.2%
sqrt-unprod47.7%
sqr-neg47.7%
sqrt-unprod0.0%
add-sqr-sqrt49.8%
associate-*l/49.7%
add-sqr-sqrt0.0%
sqrt-unprod48.2%
sqr-neg48.2%
sqrt-unprod96.2%
add-sqr-sqrt96.5%
Applied egg-rr96.5%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 0.1%
sub-neg0.1%
metadata-eval0.1%
distribute-lft-in0.1%
*-commutative0.1%
neg-mul-10.1%
unsub-neg0.1%
associate-/l*0.1%
unpow20.1%
Simplified0.1%
Taylor expanded in m around inf 0.1%
*-un-lft-identity0.1%
add-sqr-sqrt0.1%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.0%
add-sqr-sqrt82.5%
neg-mul-182.5%
times-frac82.5%
metadata-eval82.5%
unpow282.5%
add-sqr-sqrt82.5%
sqrt-unprod83.7%
sqr-neg83.7%
sqrt-unprod0.0%
add-sqr-sqrt0.1%
associate-*r/0.1%
*-commutative0.1%
*-commutative0.1%
associate-*l*0.1%
Applied egg-rr82.5%
Final simplification88.8%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (* m (+ -1.0 (/ m v))) (* (/ m v) (- m))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = m * (-1.0 + (m / v));
} 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 * ((-1.0d0) + (m / v))
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 * (-1.0 + (m / v));
} else {
tmp = (m / v) * -m;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = m * (-1.0 + (m / v)) else: tmp = (m / v) * -m return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(m * Float64(-1.0 + Float64(m / v))); else tmp = Float64(Float64(m / v) * Float64(-m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = m * (-1.0 + (m / v)); else tmp = (m / v) * -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(m * N[(-1.0 + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * (-m)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \left(-1 + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(-m\right)\\
\end{array}
\end{array}
if m < 1Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 96.4%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 0.1%
sub-neg0.1%
metadata-eval0.1%
distribute-lft-in0.1%
*-commutative0.1%
neg-mul-10.1%
unsub-neg0.1%
associate-/l*0.1%
unpow20.1%
Simplified0.1%
Taylor expanded in m around inf 0.1%
*-un-lft-identity0.1%
add-sqr-sqrt0.1%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.0%
add-sqr-sqrt82.5%
neg-mul-182.5%
times-frac82.5%
metadata-eval82.5%
unpow282.5%
add-sqr-sqrt82.5%
sqrt-unprod83.7%
sqr-neg83.7%
sqrt-unprod0.0%
add-sqr-sqrt0.1%
associate-*r/0.1%
*-commutative0.1%
*-commutative0.1%
associate-*l*0.1%
Applied egg-rr82.5%
Final simplification88.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(m / Float64(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[(m / N[(v / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
m \cdot \left(\frac{m}{\frac{v}{1 - m}} + -1\right)
\end{array}
Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
(FPCore (m v) :precision binary64 (* m (+ -1.0 (* m (/ (- 1.0 m) v)))))
double code(double m, double v) {
return m * (-1.0 + (m * ((1.0 - m) / v)));
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = m * ((-1.0d0) + (m * ((1.0d0 - m) / v)))
end function
public static double code(double m, double v) {
return m * (-1.0 + (m * ((1.0 - m) / v)));
}
def code(m, v): return m * (-1.0 + (m * ((1.0 - m) / v)))
function code(m, v) return Float64(m * Float64(-1.0 + Float64(m * Float64(Float64(1.0 - m) / v)))) end
function tmp = code(m, v) tmp = m * (-1.0 + (m * ((1.0 - m) / v))); end
code[m_, v_] := N[(m * N[(-1.0 + N[(m * N[(N[(1.0 - m), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
m \cdot \left(-1 + m \cdot \frac{1 - m}{v}\right)
\end{array}
Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(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%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in m around 0 25.8%
neg-mul-125.8%
Simplified25.8%
herbie shell --seed 2024089
(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))