
(FPCore (m v) :precision binary64 (* (- (/ (* m (- 1.0 m)) v) 1.0) (- 1.0 m)))
double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * (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) * (1.0d0 - m)
end function
public static double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m);
}
def code(m, v): return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m)
function code(m, v) return Float64(Float64(Float64(Float64(m * Float64(1.0 - m)) / v) - 1.0) * Float64(1.0 - m)) end
function tmp = code(m, v) tmp = (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m); 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]
\begin{array}{l}
\\
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (m v) :precision binary64 (* (- (/ (* m (- 1.0 m)) v) 1.0) (- 1.0 m)))
double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * (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) * (1.0d0 - m)
end function
public static double code(double m, double v) {
return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m);
}
def code(m, v): return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m)
function code(m, v) return Float64(Float64(Float64(Float64(m * Float64(1.0 - m)) / v) - 1.0) * Float64(1.0 - m)) end
function tmp = code(m, v) tmp = (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m); 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]
\begin{array}{l}
\\
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right)
\end{array}
(FPCore (m v) :precision binary64 (fma (pow (- 1.0 m) 2.0) (/ m v) (fma -1.0 m -1.0)))
double code(double m, double v) {
return fma(pow((1.0 - m), 2.0), (m / v), fma(-1.0, m, -1.0));
}
function code(m, v) return fma((Float64(1.0 - m) ^ 2.0), Float64(m / v), fma(-1.0, m, -1.0)) end
code[m_, v_] := N[(N[Power[N[(1.0 - m), $MachinePrecision], 2.0], $MachinePrecision] * N[(m / v), $MachinePrecision] + N[(-1.0 * m + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left({\left(1 - m\right)}^{2}, \frac{m}{v}, \mathsf{fma}\left(-1, m, -1\right)\right)
\end{array}
Initial program 99.9%
Applied rewrites100.0%
(FPCore (m v) :precision binary64 (if (<= (* (- (/ (* (- 1.0 m) m) v) 1.0) (- 1.0 m)) -0.5) -1.0 (+ (/ m v) m)))
double code(double m, double v) {
double tmp;
if ((((((1.0 - m) * m) / v) - 1.0) * (1.0 - m)) <= -0.5) {
tmp = -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 ((((((1.0d0 - m) * m) / v) - 1.0d0) * (1.0d0 - m)) <= (-0.5d0)) then
tmp = -1.0d0
else
tmp = (m / v) + m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if ((((((1.0 - m) * m) / v) - 1.0) * (1.0 - m)) <= -0.5) {
tmp = -1.0;
} else {
tmp = (m / v) + m;
}
return tmp;
}
def code(m, v): tmp = 0 if (((((1.0 - m) * m) / v) - 1.0) * (1.0 - m)) <= -0.5: tmp = -1.0 else: tmp = (m / v) + m return tmp
function code(m, v) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(1.0 - m) * m) / v) - 1.0) * Float64(1.0 - m)) <= -0.5) tmp = -1.0; else tmp = Float64(Float64(m / v) + m); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if ((((((1.0 - m) * m) / v) - 1.0) * (1.0 - m)) <= -0.5) tmp = -1.0; else tmp = (m / v) + m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[N[(N[(N[(N[(N[(1.0 - m), $MachinePrecision] * m), $MachinePrecision] / v), $MachinePrecision] - 1.0), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision], -0.5], -1.0, N[(N[(m / v), $MachinePrecision] + m), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\frac{\left(1 - m\right) \cdot m}{v} - 1\right) \cdot \left(1 - m\right) \leq -0.5:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} + m\\
\end{array}
\end{array}
if (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) (-.f64 #s(literal 1 binary64) m)) < -0.5Initial program 100.0%
Taylor expanded in m around 0
Applied rewrites93.7%
if -0.5 < (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) (-.f64 #s(literal 1 binary64) m)) Initial program 99.9%
Taylor expanded in m around 0
lower--.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
lower-+.f64N/A
lower-/.f6467.3
Applied rewrites67.3%
Taylor expanded in m around inf
Applied rewrites66.2%
Final simplification73.5%
(FPCore (m v) :precision binary64 (if (<= (* (- (/ (* (- 1.0 m) m) v) 1.0) (- 1.0 m)) -0.5) -1.0 (/ m v)))
double code(double m, double v) {
double tmp;
if ((((((1.0 - m) * m) / v) - 1.0) * (1.0 - m)) <= -0.5) {
tmp = -1.0;
} else {
tmp = m / v;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if ((((((1.0d0 - m) * m) / v) - 1.0d0) * (1.0d0 - m)) <= (-0.5d0)) then
tmp = -1.0d0
else
tmp = m / v
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if ((((((1.0 - m) * m) / v) - 1.0) * (1.0 - m)) <= -0.5) {
tmp = -1.0;
} else {
tmp = m / v;
}
return tmp;
}
def code(m, v): tmp = 0 if (((((1.0 - m) * m) / v) - 1.0) * (1.0 - m)) <= -0.5: tmp = -1.0 else: tmp = m / v return tmp
function code(m, v) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(1.0 - m) * m) / v) - 1.0) * Float64(1.0 - m)) <= -0.5) tmp = -1.0; else tmp = Float64(m / v); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if ((((((1.0 - m) * m) / v) - 1.0) * (1.0 - m)) <= -0.5) tmp = -1.0; else tmp = m / v; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[N[(N[(N[(N[(N[(1.0 - m), $MachinePrecision] * m), $MachinePrecision] / v), $MachinePrecision] - 1.0), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision], -0.5], -1.0, N[(m / v), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\frac{\left(1 - m\right) \cdot m}{v} - 1\right) \cdot \left(1 - m\right) \leq -0.5:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v}\\
\end{array}
\end{array}
if (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) (-.f64 #s(literal 1 binary64) m)) < -0.5Initial program 100.0%
Taylor expanded in m around 0
Applied rewrites93.7%
if -0.5 < (*.f64 (-.f64 (/.f64 (*.f64 m (-.f64 #s(literal 1 binary64) m)) v) #s(literal 1 binary64)) (-.f64 #s(literal 1 binary64) m)) Initial program 99.9%
Taylor expanded in m around 0
lower--.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
lower-+.f64N/A
lower-/.f6467.3
Applied rewrites67.3%
Taylor expanded in v around 0
Applied rewrites66.2%
Final simplification73.5%
(FPCore (m v) :precision binary64 (if (<= m 5e-9) (/ (fma (fma -2.0 m v) m (- m v)) v) (/ (* (* (- 1.0 m) m) (- 1.0 m)) v)))
double code(double m, double v) {
double tmp;
if (m <= 5e-9) {
tmp = fma(fma(-2.0, m, v), m, (m - v)) / v;
} else {
tmp = (((1.0 - m) * m) * (1.0 - m)) / v;
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 5e-9) tmp = Float64(fma(fma(-2.0, m, v), m, Float64(m - v)) / v); else tmp = Float64(Float64(Float64(Float64(1.0 - m) * m) * Float64(1.0 - m)) / v); end return tmp end
code[m_, v_] := If[LessEqual[m, 5e-9], N[(N[(N[(-2.0 * m + v), $MachinePrecision] * m + N[(m - v), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision], N[(N[(N[(N[(1.0 - m), $MachinePrecision] * m), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(-2, m, v\right), m, m - v\right)}{v}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(1 - m\right) \cdot m\right) \cdot \left(1 - m\right)}{v}\\
\end{array}
\end{array}
if m < 5.0000000000000001e-9Initial program 100.0%
Taylor expanded in m around 0
Applied rewrites52.8%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites100.0%
if 5.0000000000000001e-9 < m Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites0.7%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in v around 0
Applied rewrites99.9%
Final simplification99.9%
(FPCore (m v) :precision binary64 (if (<= m 0.62) (/ (fma (fma -2.0 m v) m (- m v)) v) (* (- m) (* (/ m v) (- 1.0 m)))))
double code(double m, double v) {
double tmp;
if (m <= 0.62) {
tmp = fma(fma(-2.0, m, v), m, (m - v)) / v;
} else {
tmp = -m * ((m / v) * (1.0 - m));
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 0.62) tmp = Float64(fma(fma(-2.0, m, v), m, Float64(m - v)) / v); else tmp = Float64(Float64(-m) * Float64(Float64(m / v) * Float64(1.0 - m))); end return tmp end
code[m_, v_] := If[LessEqual[m, 0.62], N[(N[(N[(-2.0 * m + v), $MachinePrecision] * m + N[(m - v), $MachinePrecision]), $MachinePrecision] / v), $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 0.62:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(-2, m, v\right), m, m - v\right)}{v}\\
\mathbf{else}:\\
\;\;\;\;\left(-m\right) \cdot \left(\frac{m}{v} \cdot \left(1 - m\right)\right)\\
\end{array}
\end{array}
if m < 0.619999999999999996Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites51.1%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites98.6%
if 0.619999999999999996 < m Initial program 99.9%
Taylor expanded in v around 0
associate-/l*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
div-subN/A
lower-/.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in m around inf
mul-1-negN/A
lower-neg.f6498.0
Applied rewrites98.0%
Applied rewrites98.0%
Final simplification98.3%
(FPCore (m v) :precision binary64 (if (<= m 0.62) (/ (fma (fma -2.0 m v) m (- m v)) v) (/ (* (* (- m) m) (- 1.0 m)) v)))
double code(double m, double v) {
double tmp;
if (m <= 0.62) {
tmp = fma(fma(-2.0, m, v), m, (m - v)) / v;
} else {
tmp = ((-m * m) * (1.0 - m)) / v;
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 0.62) tmp = Float64(fma(fma(-2.0, m, v), m, Float64(m - v)) / v); else tmp = Float64(Float64(Float64(Float64(-m) * m) * Float64(1.0 - m)) / v); end return tmp end
code[m_, v_] := If[LessEqual[m, 0.62], N[(N[(N[(-2.0 * m + v), $MachinePrecision] * m + N[(m - v), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision], N[(N[(N[((-m) * m), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.62:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(-2, m, v\right), m, m - v\right)}{v}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(-m\right) \cdot m\right) \cdot \left(1 - m\right)}{v}\\
\end{array}
\end{array}
if m < 0.619999999999999996Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites51.1%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites98.6%
if 0.619999999999999996 < m Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites0.7%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in m around inf
Applied rewrites98.0%
Final simplification98.3%
(FPCore (m v) :precision binary64 (if (<= m 0.62) (/ (fma (fma -2.0 m v) m (- m v)) v) (* (/ (- 1.0 m) v) (* (- m) m))))
double code(double m, double v) {
double tmp;
if (m <= 0.62) {
tmp = fma(fma(-2.0, m, v), m, (m - v)) / v;
} else {
tmp = ((1.0 - m) / v) * (-m * m);
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 0.62) tmp = Float64(fma(fma(-2.0, m, v), m, Float64(m - v)) / v); else tmp = Float64(Float64(Float64(1.0 - m) / v) * Float64(Float64(-m) * m)); end return tmp end
code[m_, v_] := If[LessEqual[m, 0.62], N[(N[(N[(-2.0 * m + v), $MachinePrecision] * m + N[(m - v), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision], N[(N[(N[(1.0 - m), $MachinePrecision] / v), $MachinePrecision] * N[((-m) * m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.62:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(-2, m, v\right), m, m - v\right)}{v}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - m}{v} \cdot \left(\left(-m\right) \cdot m\right)\\
\end{array}
\end{array}
if m < 0.619999999999999996Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites51.1%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites98.6%
if 0.619999999999999996 < m Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites0.7%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in m around inf
Applied rewrites98.0%
Applied rewrites98.0%
Final simplification98.3%
(FPCore (m v) :precision binary64 (if (<= m 0.62) (fma (fma -2.0 m 1.0) (/ m v) -1.0) (* (/ (- 1.0 m) v) (* (- m) m))))
double code(double m, double v) {
double tmp;
if (m <= 0.62) {
tmp = fma(fma(-2.0, m, 1.0), (m / v), -1.0);
} else {
tmp = ((1.0 - m) / v) * (-m * m);
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 0.62) tmp = fma(fma(-2.0, m, 1.0), Float64(m / v), -1.0); else tmp = Float64(Float64(Float64(1.0 - m) / v) * Float64(Float64(-m) * m)); end return tmp end
code[m_, v_] := If[LessEqual[m, 0.62], N[(N[(-2.0 * m + 1.0), $MachinePrecision] * N[(m / v), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(1.0 - m), $MachinePrecision] / v), $MachinePrecision] * N[((-m) * m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.62:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-2, m, 1\right), \frac{m}{v}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - m}{v} \cdot \left(\left(-m\right) \cdot m\right)\\
\end{array}
\end{array}
if m < 0.619999999999999996Initial program 99.9%
Taylor expanded in m around 0
distribute-rgt-inN/A
*-lft-identityN/A
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
*-rgt-identityN/A
distribute-lft1-inN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites98.6%
Taylor expanded in m around 0
Applied rewrites98.6%
if 0.619999999999999996 < m Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites0.7%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in m around inf
Applied rewrites98.0%
Applied rewrites98.0%
Final simplification98.3%
(FPCore (m v) :precision binary64 (if (<= m 0.42) (fma (fma -2.0 m 1.0) (/ m v) -1.0) (* (* (/ (- m) v) m) (- m))))
double code(double m, double v) {
double tmp;
if (m <= 0.42) {
tmp = fma(fma(-2.0, m, 1.0), (m / v), -1.0);
} else {
tmp = ((-m / v) * m) * -m;
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 0.42) tmp = fma(fma(-2.0, m, 1.0), Float64(m / v), -1.0); else tmp = Float64(Float64(Float64(Float64(-m) / v) * m) * Float64(-m)); end return tmp end
code[m_, v_] := If[LessEqual[m, 0.42], N[(N[(-2.0 * m + 1.0), $MachinePrecision] * N[(m / v), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[((-m) / v), $MachinePrecision] * m), $MachinePrecision] * (-m)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.42:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-2, m, 1\right), \frac{m}{v}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-m}{v} \cdot m\right) \cdot \left(-m\right)\\
\end{array}
\end{array}
if m < 0.419999999999999984Initial program 99.9%
Taylor expanded in m around 0
distribute-rgt-inN/A
*-lft-identityN/A
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
*-rgt-identityN/A
distribute-lft1-inN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites98.6%
Taylor expanded in m around 0
Applied rewrites98.6%
if 0.419999999999999984 < m Initial program 99.9%
Taylor expanded in v around 0
associate-/l*N/A
div-subN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
div-subN/A
lower-/.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in m around inf
mul-1-negN/A
lower-neg.f6498.0
Applied rewrites98.0%
Taylor expanded in m around inf
Applied rewrites98.0%
(FPCore (m v) :precision binary64 (if (<= m 0.42) (fma (fma -2.0 m 1.0) (/ m v) -1.0) (/ (* (* (- m) m) (- m)) v)))
double code(double m, double v) {
double tmp;
if (m <= 0.42) {
tmp = fma(fma(-2.0, m, 1.0), (m / v), -1.0);
} else {
tmp = ((-m * m) * -m) / v;
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 0.42) tmp = fma(fma(-2.0, m, 1.0), Float64(m / v), -1.0); else tmp = Float64(Float64(Float64(Float64(-m) * m) * Float64(-m)) / v); end return tmp end
code[m_, v_] := If[LessEqual[m, 0.42], N[(N[(-2.0 * m + 1.0), $MachinePrecision] * N[(m / v), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[((-m) * m), $MachinePrecision] * (-m)), $MachinePrecision] / v), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.42:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-2, m, 1\right), \frac{m}{v}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(-m\right) \cdot m\right) \cdot \left(-m\right)}{v}\\
\end{array}
\end{array}
if m < 0.419999999999999984Initial program 99.9%
Taylor expanded in m around 0
distribute-rgt-inN/A
*-lft-identityN/A
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
*-rgt-identityN/A
distribute-lft1-inN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites98.6%
Taylor expanded in m around 0
Applied rewrites98.6%
if 0.419999999999999984 < m Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites0.7%
Taylor expanded in v around 0
lower-/.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in m around inf
Applied rewrites98.0%
Taylor expanded in m around inf
Applied rewrites98.0%
Final simplification98.3%
(FPCore (m v) :precision binary64 (* (/ (- m (fma m m v)) v) (- 1.0 m)))
double code(double m, double v) {
return ((m - fma(m, m, v)) / v) * (1.0 - m);
}
function code(m, v) return Float64(Float64(Float64(m - fma(m, m, v)) / v) * Float64(1.0 - m)) end
code[m_, v_] := N[(N[(N[(m - N[(m * m + v), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{m - \mathsf{fma}\left(m, m, v\right)}{v} \cdot \left(1 - m\right)
\end{array}
Initial program 99.9%
Taylor expanded in v around 0
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-rgt-identityN/A
unpow2N/A
associate--l-N/A
lower--.f64N/A
unpow2N/A
lower-fma.f6499.9
Applied rewrites99.9%
(FPCore (m v) :precision binary64 (if (<= m 1.12e+148) (- (+ (/ m v) m) 1.0) (/ (fma m m -1.0) 1.0)))
double code(double m, double v) {
double tmp;
if (m <= 1.12e+148) {
tmp = ((m / v) + m) - 1.0;
} else {
tmp = fma(m, m, -1.0) / 1.0;
}
return tmp;
}
function code(m, v) tmp = 0.0 if (m <= 1.12e+148) tmp = Float64(Float64(Float64(m / v) + m) - 1.0); else tmp = Float64(fma(m, m, -1.0) / 1.0); end return tmp end
code[m_, v_] := If[LessEqual[m, 1.12e+148], N[(N[(N[(m / v), $MachinePrecision] + m), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(m * m + -1.0), $MachinePrecision] / 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.12 \cdot 10^{+148}:\\
\;\;\;\;\left(\frac{m}{v} + m\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(m, m, -1\right)}{1}\\
\end{array}
\end{array}
if m < 1.12e148Initial program 99.9%
Taylor expanded in m around 0
lower--.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
lower-+.f64N/A
lower-/.f6475.8
Applied rewrites75.8%
if 1.12e148 < m Initial program 100.0%
Taylor expanded in v around inf
mul-1-negN/A
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower--.f646.7
Applied rewrites6.7%
Applied rewrites93.3%
Taylor expanded in m around 0
Applied rewrites93.9%
(FPCore (m v) :precision binary64 (- (+ (/ m v) m) 1.0))
double code(double m, double v) {
return ((m / v) + m) - 1.0;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = ((m / v) + m) - 1.0d0
end function
public static double code(double m, double v) {
return ((m / v) + m) - 1.0;
}
def code(m, v): return ((m / v) + m) - 1.0
function code(m, v) return Float64(Float64(Float64(m / v) + m) - 1.0) end
function tmp = code(m, v) tmp = ((m / v) + m) - 1.0; end
code[m_, v_] := N[(N[(N[(m / v), $MachinePrecision] + m), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{m}{v} + m\right) - 1
\end{array}
Initial program 99.9%
Taylor expanded in m around 0
lower--.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
lower-+.f64N/A
lower-/.f6476.0
Applied rewrites76.0%
(FPCore (m v) :precision binary64 (- (/ m v) 1.0))
double code(double m, double v) {
return (m / v) - 1.0;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = (m / v) - 1.0d0
end function
public static double code(double m, double v) {
return (m / v) - 1.0;
}
def code(m, v): return (m / v) - 1.0
function code(m, v) return Float64(Float64(m / v) - 1.0) end
function tmp = code(m, v) tmp = (m / v) - 1.0; end
code[m_, v_] := N[(N[(m / v), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{m}{v} - 1
\end{array}
Initial program 99.9%
Taylor expanded in m around 0
lower--.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*l/N/A
*-lft-identityN/A
*-lft-identityN/A
lower-+.f64N/A
lower-/.f6476.0
Applied rewrites76.0%
Taylor expanded in v around 0
Applied rewrites76.0%
(FPCore (m v) :precision binary64 (- m 1.0))
double code(double m, double v) {
return m - 1.0;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = m - 1.0d0
end function
public static double code(double m, double v) {
return m - 1.0;
}
def code(m, v): return m - 1.0
function code(m, v) return Float64(m - 1.0) end
function tmp = code(m, v) tmp = m - 1.0; end
code[m_, v_] := N[(m - 1.0), $MachinePrecision]
\begin{array}{l}
\\
m - 1
\end{array}
Initial program 99.9%
Taylor expanded in v around inf
mul-1-negN/A
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower--.f6428.0
Applied rewrites28.0%
(FPCore (m v) :precision binary64 -1.0)
double code(double m, double v) {
return -1.0;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = -1.0d0
end function
public static double code(double m, double v) {
return -1.0;
}
def code(m, v): return -1.0
function code(m, v) return -1.0 end
function tmp = code(m, v) tmp = -1.0; end
code[m_, v_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 99.9%
Taylor expanded in m around 0
Applied rewrites25.5%
herbie shell --seed 2024253
(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)))