
(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.5e-16) (- (/ m (/ v m)) m) (* m (* (/ m v) (- 1.0 m)))))
double code(double m, double v) {
double tmp;
if (m <= 1.5e-16) {
tmp = (m / (v / m)) - m;
} else {
tmp = m * ((m / v) * (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.5d-16) then
tmp = (m / (v / m)) - m
else
tmp = m * ((m / v) * (1.0d0 - m))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.5e-16) {
tmp = (m / (v / m)) - m;
} else {
tmp = m * ((m / v) * (1.0 - m));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.5e-16: tmp = (m / (v / m)) - m else: tmp = m * ((m / v) * (1.0 - m)) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.5e-16) tmp = Float64(Float64(m / Float64(v / m)) - m); else tmp = Float64(m * Float64(Float64(m / v) * Float64(1.0 - m))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.5e-16) tmp = (m / (v / m)) - m; else tmp = m * ((m / v) * (1.0 - m)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.5e-16], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m * N[(N[(m / v), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.5 \cdot 10^{-16}:\\
\;\;\;\;\frac{m}{\frac{v}{m}} - m\\
\mathbf{else}:\\
\;\;\;\;m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right)\right)\\
\end{array}
\end{array}
if m < 1.49999999999999997e-16Initial program 99.7%
Taylor expanded in m around 0
distribute-lft-out--N/A
associate-/l*N/A
unpow2N/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6484.0
Applied rewrites84.0%
Applied rewrites99.8%
if 1.49999999999999997e-16 < m Initial program 99.9%
Taylor expanded in m around inf
distribute-lft-out--N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
unpow2N/A
associate-*r*N/A
associate-*r/N/A
*-rgt-identityN/A
distribute-lft-out--N/A
div-subN/A
associate-/l*N/A
lower-/.f64N/A
distribute-rgt-out--N/A
*-lft-identityN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f6499.8
Applied rewrites99.8%
Applied rewrites99.9%
Final simplification99.8%
(FPCore (m v) :precision binary64 (if (<= (* m (+ -1.0 (/ (* m (- 1.0 m)) v))) -2e+74) (* (/ m v) (* m (- m))) (fma m (/ m v) (- m))))
double code(double m, double v) {
double tmp;
if ((m * (-1.0 + ((m * (1.0 - m)) / v))) <= -2e+74) {
tmp = (m / v) * (m * -m);
} else {
tmp = fma(m, (m / v), -m);
}
return tmp;
}
function code(m, v) tmp = 0.0 if (Float64(m * Float64(-1.0 + Float64(Float64(m * Float64(1.0 - m)) / v))) <= -2e+74) tmp = Float64(Float64(m / v) * Float64(m * Float64(-m))); else tmp = fma(m, Float64(m / v), Float64(-m)); end return tmp end
code[m_, v_] := If[LessEqual[N[(m * N[(-1.0 + N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e+74], N[(N[(m / v), $MachinePrecision] * N[(m * (-m)), $MachinePrecision]), $MachinePrecision], N[(m * N[(m / v), $MachinePrecision] + (-m)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \cdot \left(-1 + \frac{m \cdot \left(1 - m\right)}{v}\right) \leq -2 \cdot 10^{+74}:\\
\;\;\;\;\frac{m}{v} \cdot \left(m \cdot \left(-m\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(m, \frac{m}{v}, -m\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) m) < -1.9999999999999999e74Initial program 99.9%
Taylor expanded in m around inf
associate-*r/N/A
lower-/.f64N/A
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6498.0
Applied rewrites98.0%
Applied rewrites98.0%
if -1.9999999999999999e74 < (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) m) Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in m around 0
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6498.7
Applied rewrites98.7%
Final simplification98.3%
(FPCore (m v) :precision binary64 (if (<= (* m (+ -1.0 (/ (* m (- 1.0 m)) v))) -5e-305) (- m) (* m (/ m v))))
double code(double m, double v) {
double tmp;
if ((m * (-1.0 + ((m * (1.0 - m)) / v))) <= -5e-305) {
tmp = -m;
} else {
tmp = 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) + ((m * (1.0d0 - m)) / v))) <= (-5d-305)) then
tmp = -m
else
tmp = m * (m / v)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if ((m * (-1.0 + ((m * (1.0 - m)) / v))) <= -5e-305) {
tmp = -m;
} else {
tmp = m * (m / v);
}
return tmp;
}
def code(m, v): tmp = 0 if (m * (-1.0 + ((m * (1.0 - m)) / v))) <= -5e-305: tmp = -m else: tmp = m * (m / v) return tmp
function code(m, v) tmp = 0.0 if (Float64(m * Float64(-1.0 + Float64(Float64(m * Float64(1.0 - m)) / v))) <= -5e-305) tmp = Float64(-m); else tmp = Float64(m * Float64(m / v)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if ((m * (-1.0 + ((m * (1.0 - m)) / v))) <= -5e-305) tmp = -m; else tmp = m * (m / v); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[N[(m * N[(-1.0 + N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-305], (-m), N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \cdot \left(-1 + \frac{m \cdot \left(1 - m\right)}{v}\right) \leq -5 \cdot 10^{-305}:\\
\;\;\;\;-m\\
\mathbf{else}:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\end{array}
\end{array}
if (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) m) < -4.99999999999999985e-305Initial program 99.9%
Taylor expanded in m around 0
mul-1-negN/A
lower-neg.f6434.2
Applied rewrites34.2%
if -4.99999999999999985e-305 < (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) m) Initial program 99.5%
Taylor expanded in m around inf
distribute-lft-out--N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
unpow2N/A
associate-*r*N/A
associate-*r/N/A
*-rgt-identityN/A
distribute-lft-out--N/A
div-subN/A
associate-/l*N/A
lower-/.f64N/A
distribute-rgt-out--N/A
*-lft-identityN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f6494.4
Applied rewrites94.4%
Taylor expanded in m around 0
Applied rewrites92.2%
Final simplification47.3%
(FPCore (m v) :precision binary64 (if (<= (* m (+ -1.0 (/ (* m (- 1.0 m)) v))) -5e-305) (- m) (/ (* m m) v)))
double code(double m, double v) {
double tmp;
if ((m * (-1.0 + ((m * (1.0 - m)) / v))) <= -5e-305) {
tmp = -m;
} else {
tmp = (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) + ((m * (1.0d0 - m)) / v))) <= (-5d-305)) then
tmp = -m
else
tmp = (m * m) / v
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if ((m * (-1.0 + ((m * (1.0 - m)) / v))) <= -5e-305) {
tmp = -m;
} else {
tmp = (m * m) / v;
}
return tmp;
}
def code(m, v): tmp = 0 if (m * (-1.0 + ((m * (1.0 - m)) / v))) <= -5e-305: tmp = -m else: tmp = (m * m) / v return tmp
function code(m, v) tmp = 0.0 if (Float64(m * Float64(-1.0 + Float64(Float64(m * Float64(1.0 - m)) / v))) <= -5e-305) tmp = Float64(-m); else tmp = Float64(Float64(m * m) / v); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if ((m * (-1.0 + ((m * (1.0 - m)) / v))) <= -5e-305) tmp = -m; else tmp = (m * m) / v; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[N[(m * N[(-1.0 + N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-305], (-m), N[(N[(m * m), $MachinePrecision] / v), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \cdot \left(-1 + \frac{m \cdot \left(1 - m\right)}{v}\right) \leq -5 \cdot 10^{-305}:\\
\;\;\;\;-m\\
\mathbf{else}:\\
\;\;\;\;\frac{m \cdot m}{v}\\
\end{array}
\end{array}
if (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) m) < -4.99999999999999985e-305Initial program 99.9%
Taylor expanded in m around 0
mul-1-negN/A
lower-neg.f6434.2
Applied rewrites34.2%
if -4.99999999999999985e-305 < (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) m) Initial program 99.5%
Taylor expanded in m around 0
distribute-lft-out--N/A
associate-/l*N/A
unpow2N/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6468.9
Applied rewrites68.9%
Taylor expanded in m around inf
Applied rewrites67.8%
Final simplification41.8%
(FPCore (m v) :precision binary64 (if (<= m 1.5e-16) (fma m (/ m v) (- m)) (* m (* (/ m v) (- 1.0 m)))))
double code(double m, double v) {
double tmp;
if (m <= 1.5e-16) {
tmp = fma(m, (m / v), -m);
} else {
tmp = m * ((m / v) * (1.0 - m));
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 1.5e-16) tmp = fma(m, Float64(m / v), Float64(-m)); else tmp = Float64(m * Float64(Float64(m / v) * Float64(1.0 - m))); end return tmp end
code[m_, v_] := If[LessEqual[m, 1.5e-16], N[(m * N[(m / v), $MachinePrecision] + (-m)), $MachinePrecision], N[(m * N[(N[(m / v), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.5 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(m, \frac{m}{v}, -m\right)\\
\mathbf{else}:\\
\;\;\;\;m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right)\right)\\
\end{array}
\end{array}
if m < 1.49999999999999997e-16Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in m around 0
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6499.8
Applied rewrites99.8%
if 1.49999999999999997e-16 < m Initial program 99.9%
Taylor expanded in m around inf
distribute-lft-out--N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
associate-*r/N/A
rgt-mult-inverseN/A
unpow2N/A
associate-*r*N/A
associate-*r/N/A
*-rgt-identityN/A
distribute-lft-out--N/A
div-subN/A
associate-/l*N/A
lower-/.f64N/A
distribute-rgt-out--N/A
*-lft-identityN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f6499.8
Applied rewrites99.8%
Applied rewrites99.9%
Final simplification99.8%
(FPCore (m v) :precision binary64 (fma (fma m (- m) m) (/ m v) (- m)))
double code(double m, double v) {
return fma(fma(m, -m, m), (m / v), -m);
}
function code(m, v) return fma(fma(m, Float64(-m), m), Float64(m / v), Float64(-m)) end
code[m_, v_] := N[(N[(m * (-m) + m), $MachinePrecision] * N[(m / v), $MachinePrecision] + (-m)), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(m, -m, m\right), \frac{m}{v}, -m\right)
\end{array}
Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (fma m (/ m v) (- m)) (/ (* m (- m)) m)))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = fma(m, (m / v), -m);
} else {
tmp = (m * -m) / m;
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = fma(m, Float64(m / v), Float64(-m)); else tmp = Float64(Float64(m * Float64(-m)) / m); end return tmp end
code[m_, v_] := If[LessEqual[m, 1.0], N[(m * N[(m / v), $MachinePrecision] + (-m)), $MachinePrecision], N[(N[(m * (-m)), $MachinePrecision] / m), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;\mathsf{fma}\left(m, \frac{m}{v}, -m\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{m \cdot \left(-m\right)}{m}\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in m around 0
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6498.7
Applied rewrites98.7%
if 1 < m Initial program 99.9%
Taylor expanded in m around 0
mul-1-negN/A
lower-neg.f645.8
Applied rewrites5.8%
Applied rewrites52.1%
Final simplification74.3%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (fma m (/ m v) (- m)) (- m)))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = fma(m, (m / v), -m);
} else {
tmp = -m;
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = fma(m, Float64(m / v), Float64(-m)); else tmp = Float64(-m); end return tmp end
code[m_, v_] := If[LessEqual[m, 1.0], N[(m * N[(m / v), $MachinePrecision] + (-m)), $MachinePrecision], (-m)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;\mathsf{fma}\left(m, \frac{m}{v}, -m\right)\\
\mathbf{else}:\\
\;\;\;\;-m\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in m around 0
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6498.7
Applied rewrites98.7%
if 1 < m Initial program 99.9%
Taylor expanded in m around 0
mul-1-negN/A
lower-neg.f645.8
Applied rewrites5.8%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (- (* m (/ m v)) m) (- m)))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m * (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 (m <= 1.0d0) then
tmp = (m * (m / v)) - m
else
tmp = -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;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (m * (m / v)) - m else: tmp = -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); 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; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], (-m)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\
\mathbf{else}:\\
\;\;\;\;-m\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
Taylor expanded in m around 0
distribute-lft-out--N/A
associate-/l*N/A
unpow2N/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6483.4
Applied rewrites83.4%
Applied rewrites98.7%
if 1 < m Initial program 99.9%
Taylor expanded in m around 0
mul-1-negN/A
lower-neg.f645.8
Applied rewrites5.8%
Final simplification50.1%
(FPCore (m v) :precision binary64 (* m (fma (/ m v) (- 1.0 m) -1.0)))
double code(double m, double v) {
return m * fma((m / v), (1.0 - m), -1.0);
}
function code(m, v) return Float64(m * fma(Float64(m / v), Float64(1.0 - m), -1.0)) end
code[m_, v_] := N[(m * N[(N[(m / v), $MachinePrecision] * N[(1.0 - m), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
m \cdot \mathsf{fma}\left(\frac{m}{v}, 1 - m, -1\right)
\end{array}
Initial program 99.8%
lift--.f64N/A
sub-negN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-eval99.8
Applied rewrites99.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%
Taylor expanded in m around 0
mul-1-negN/A
lower-neg.f6427.0
Applied rewrites27.0%
herbie shell --seed 2024234
(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))