
(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 11 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 (* (- 1.0 m) (+ (/ m (/ v (- 1.0 m))) -1.0)))
double code(double m, double v) {
return (1.0 - 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 = (1.0d0 - m) * ((m / (v / (1.0d0 - m))) + (-1.0d0))
end function
public static double code(double m, double v) {
return (1.0 - m) * ((m / (v / (1.0 - m))) + -1.0);
}
def code(m, v): return (1.0 - m) * ((m / (v / (1.0 - m))) + -1.0)
function code(m, v) return Float64(Float64(1.0 - m) * Float64(Float64(m / Float64(v / Float64(1.0 - m))) + -1.0)) end
function tmp = code(m, v) tmp = (1.0 - m) * ((m / (v / (1.0 - m))) + -1.0); end
code[m_, v_] := N[(N[(1.0 - m), $MachinePrecision] * N[(N[(m / N[(v / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - m\right) \cdot \left(\frac{m}{\frac{v}{1 - m}} + -1\right)
\end{array}
Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (m v)
:precision binary64
(if (<= m 1.9e-142)
-1.0
(if (<= m 3.3e-104)
(/ m v)
(if (<= m 1.44e-92) -1.0 (if (<= m 0.28) (/ m v) (* m (/ m v)))))))
double code(double m, double v) {
double tmp;
if (m <= 1.9e-142) {
tmp = -1.0;
} else if (m <= 3.3e-104) {
tmp = m / v;
} else if (m <= 1.44e-92) {
tmp = -1.0;
} else if (m <= 0.28) {
tmp = m / v;
} 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.9d-142) then
tmp = -1.0d0
else if (m <= 3.3d-104) then
tmp = m / v
else if (m <= 1.44d-92) then
tmp = -1.0d0
else if (m <= 0.28d0) then
tmp = m / v
else
tmp = m * (m / v)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.9e-142) {
tmp = -1.0;
} else if (m <= 3.3e-104) {
tmp = m / v;
} else if (m <= 1.44e-92) {
tmp = -1.0;
} else if (m <= 0.28) {
tmp = m / v;
} else {
tmp = m * (m / v);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.9e-142: tmp = -1.0 elif m <= 3.3e-104: tmp = m / v elif m <= 1.44e-92: tmp = -1.0 elif m <= 0.28: tmp = m / v else: tmp = m * (m / v) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.9e-142) tmp = -1.0; elseif (m <= 3.3e-104) tmp = Float64(m / v); elseif (m <= 1.44e-92) tmp = -1.0; elseif (m <= 0.28) tmp = Float64(m / v); else tmp = Float64(m * Float64(m / v)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.9e-142) tmp = -1.0; elseif (m <= 3.3e-104) tmp = m / v; elseif (m <= 1.44e-92) tmp = -1.0; elseif (m <= 0.28) tmp = m / v; else tmp = m * (m / v); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.9e-142], -1.0, If[LessEqual[m, 3.3e-104], N[(m / v), $MachinePrecision], If[LessEqual[m, 1.44e-92], -1.0, If[LessEqual[m, 0.28], N[(m / v), $MachinePrecision], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.9 \cdot 10^{-142}:\\
\;\;\;\;-1\\
\mathbf{elif}\;m \leq 3.3 \cdot 10^{-104}:\\
\;\;\;\;\frac{m}{v}\\
\mathbf{elif}\;m \leq 1.44 \cdot 10^{-92}:\\
\;\;\;\;-1\\
\mathbf{elif}\;m \leq 0.28:\\
\;\;\;\;\frac{m}{v}\\
\mathbf{else}:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\end{array}
\end{array}
if m < 1.89999999999999986e-142 or 3.30000000000000002e-104 < m < 1.4400000000000001e-92Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in m around 0 76.3%
if 1.89999999999999986e-142 < m < 3.30000000000000002e-104 or 1.4400000000000001e-92 < m < 0.28000000000000003Initial program 100.0%
Taylor expanded in m around 0 94.8%
Taylor expanded in v around 0 94.8%
+-commutative94.8%
sub-neg94.8%
metadata-eval94.8%
distribute-neg-in94.8%
associate-*r*94.8%
sub-neg94.8%
metadata-eval94.8%
distribute-neg-in94.8%
distribute-rgt-out94.8%
distribute-neg-in94.8%
metadata-eval94.8%
sub-neg94.8%
neg-mul-194.8%
Simplified94.8%
Taylor expanded in v around 0 77.2%
associate-/l*76.8%
Simplified76.8%
Taylor expanded in m around 0 77.0%
if 0.28000000000000003 < m Initial program 99.9%
Taylor expanded in m around 0 0.3%
*-commutative0.3%
sub-neg0.3%
metadata-eval0.3%
distribute-rgt-in0.3%
*-commutative0.3%
add-sqr-sqrt0.2%
sqrt-unprod77.4%
sqr-neg77.4%
sqrt-unprod77.3%
add-sqr-sqrt77.3%
neg-sub077.3%
associate--r-77.3%
metadata-eval77.3%
neg-mul-177.3%
neg-sub077.3%
associate--r-77.3%
metadata-eval77.3%
Applied egg-rr77.3%
*-commutative77.3%
distribute-lft1-in77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in v around 0 77.3%
sub-neg77.3%
metadata-eval77.3%
+-commutative77.3%
associate-*r/77.3%
Simplified77.3%
Taylor expanded in m around inf 77.4%
Final simplification77.0%
(FPCore (m v)
:precision binary64
(if (<= m 7e-144)
-1.0
(if (<= m 3.2e-104)
(/ m v)
(if (<= m 1.44e-92) -1.0 (* m (/ (+ 1.0 m) v))))))
double code(double m, double v) {
double tmp;
if (m <= 7e-144) {
tmp = -1.0;
} else if (m <= 3.2e-104) {
tmp = m / v;
} else if (m <= 1.44e-92) {
tmp = -1.0;
} else {
tmp = 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 <= 7d-144) then
tmp = -1.0d0
else if (m <= 3.2d-104) then
tmp = m / v
else if (m <= 1.44d-92) then
tmp = -1.0d0
else
tmp = m * ((1.0d0 + m) / v)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 7e-144) {
tmp = -1.0;
} else if (m <= 3.2e-104) {
tmp = m / v;
} else if (m <= 1.44e-92) {
tmp = -1.0;
} else {
tmp = m * ((1.0 + m) / v);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 7e-144: tmp = -1.0 elif m <= 3.2e-104: tmp = m / v elif m <= 1.44e-92: tmp = -1.0 else: tmp = m * ((1.0 + m) / v) return tmp
function code(m, v) tmp = 0.0 if (m <= 7e-144) tmp = -1.0; elseif (m <= 3.2e-104) tmp = Float64(m / v); elseif (m <= 1.44e-92) tmp = -1.0; else tmp = Float64(m * Float64(Float64(1.0 + m) / v)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 7e-144) tmp = -1.0; elseif (m <= 3.2e-104) tmp = m / v; elseif (m <= 1.44e-92) tmp = -1.0; else tmp = m * ((1.0 + m) / v); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 7e-144], -1.0, If[LessEqual[m, 3.2e-104], N[(m / v), $MachinePrecision], If[LessEqual[m, 1.44e-92], -1.0, N[(m * N[(N[(1.0 + m), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 7 \cdot 10^{-144}:\\
\;\;\;\;-1\\
\mathbf{elif}\;m \leq 3.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{m}{v}\\
\mathbf{elif}\;m \leq 1.44 \cdot 10^{-92}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;m \cdot \frac{1 + m}{v}\\
\end{array}
\end{array}
if m < 6.9999999999999997e-144 or 3.19999999999999989e-104 < m < 1.4400000000000001e-92Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in m around 0 76.3%
if 6.9999999999999997e-144 < m < 3.19999999999999989e-104Initial program 100.0%
Taylor expanded in m around 0 100.0%
Taylor expanded in v around 0 100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-neg-in100.0%
associate-*r*100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-neg-in100.0%
distribute-rgt-out100.0%
distribute-neg-in100.0%
metadata-eval100.0%
sub-neg100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in v around 0 80.2%
associate-/l*79.9%
Simplified79.9%
Taylor expanded in m around 0 80.2%
if 1.4400000000000001e-92 < m Initial program 99.9%
Taylor expanded in m around 0 22.6%
*-commutative22.6%
sub-neg22.6%
metadata-eval22.6%
distribute-rgt-in22.6%
*-commutative22.6%
add-sqr-sqrt22.5%
sqrt-unprod81.1%
sqr-neg81.1%
sqrt-unprod58.7%
add-sqr-sqrt62.8%
neg-sub062.8%
associate--r-62.8%
metadata-eval62.8%
neg-mul-162.8%
neg-sub062.8%
associate--r-62.8%
metadata-eval62.8%
Applied egg-rr62.8%
*-commutative62.8%
distribute-lft1-in62.8%
+-commutative62.8%
Simplified62.8%
Taylor expanded in v around 0 59.2%
sub-neg59.2%
metadata-eval59.2%
+-commutative59.2%
associate-*r/59.2%
Simplified59.2%
Applied egg-rr76.9%
/-rgt-identity76.9%
associate-*r/76.9%
hypot-undefine76.9%
hypot-undefine76.9%
rem-square-sqrt76.9%
metadata-eval76.9%
rem-square-sqrt76.9%
*-rgt-identity76.9%
distribute-rgt1-in76.9%
distribute-lft1-in76.9%
*-rgt-identity76.9%
Simplified76.9%
Final simplification77.0%
(FPCore (m v) :precision binary64 (if (<= m 3.3e-142) -1.0 (if (or (<= m 3.3e-104) (not (<= m 1.44e-92))) (/ m v) -1.0)))
double code(double m, double v) {
double tmp;
if (m <= 3.3e-142) {
tmp = -1.0;
} else if ((m <= 3.3e-104) || !(m <= 1.44e-92)) {
tmp = m / v;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 3.3d-142) then
tmp = -1.0d0
else if ((m <= 3.3d-104) .or. (.not. (m <= 1.44d-92))) then
tmp = m / v
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 3.3e-142) {
tmp = -1.0;
} else if ((m <= 3.3e-104) || !(m <= 1.44e-92)) {
tmp = m / v;
} else {
tmp = -1.0;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 3.3e-142: tmp = -1.0 elif (m <= 3.3e-104) or not (m <= 1.44e-92): tmp = m / v else: tmp = -1.0 return tmp
function code(m, v) tmp = 0.0 if (m <= 3.3e-142) tmp = -1.0; elseif ((m <= 3.3e-104) || !(m <= 1.44e-92)) tmp = Float64(m / v); else tmp = -1.0; end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 3.3e-142) tmp = -1.0; elseif ((m <= 3.3e-104) || ~((m <= 1.44e-92))) tmp = m / v; else tmp = -1.0; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 3.3e-142], -1.0, If[Or[LessEqual[m, 3.3e-104], N[Not[LessEqual[m, 1.44e-92]], $MachinePrecision]], N[(m / v), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.3 \cdot 10^{-142}:\\
\;\;\;\;-1\\
\mathbf{elif}\;m \leq 3.3 \cdot 10^{-104} \lor \neg \left(m \leq 1.44 \cdot 10^{-92}\right):\\
\;\;\;\;\frac{m}{v}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if m < 3.2999999999999997e-142 or 3.30000000000000002e-104 < m < 1.4400000000000001e-92Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in m around 0 76.3%
if 3.2999999999999997e-142 < m < 3.30000000000000002e-104 or 1.4400000000000001e-92 < m Initial program 99.9%
Taylor expanded in m around 0 29.2%
Taylor expanded in v around 0 29.2%
+-commutative29.2%
sub-neg29.2%
metadata-eval29.2%
distribute-neg-in29.2%
associate-*r*29.2%
sub-neg29.2%
metadata-eval29.2%
distribute-neg-in29.2%
distribute-rgt-out29.2%
distribute-neg-in29.2%
metadata-eval29.2%
sub-neg29.2%
neg-mul-129.2%
Simplified29.2%
Taylor expanded in v around 0 23.8%
associate-/l*23.7%
Simplified23.7%
Taylor expanded in m around 0 64.2%
Final simplification67.5%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (* (- 1.0 m) (+ -1.0 (/ m v))) (* (- 1.0 m) (- -1.0 (* m (/ m v))))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (1.0 - m) * (-1.0 + (m / v));
} else {
tmp = (1.0 - m) * (-1.0 - (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 = (1.0d0 - m) * ((-1.0d0) + (m / v))
else
tmp = (1.0d0 - m) * ((-1.0d0) - (m * (m / v)))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (1.0 - m) * (-1.0 + (m / v));
} else {
tmp = (1.0 - m) * (-1.0 - (m * (m / v)));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (1.0 - m) * (-1.0 + (m / v)) else: tmp = (1.0 - m) * (-1.0 - (m * (m / v))) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(Float64(1.0 - m) * Float64(-1.0 + Float64(m / v))); else tmp = Float64(Float64(1.0 - m) * Float64(-1.0 - Float64(m * Float64(m / v)))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = (1.0 - m) * (-1.0 + (m / v)); else tmp = (1.0 - m) * (-1.0 - (m * (m / v))); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(1.0 - m), $MachinePrecision] * N[(-1.0 + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - m), $MachinePrecision] * N[(-1.0 - N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;\left(1 - m\right) \cdot \left(-1 + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - m\right) \cdot \left(-1 - m \cdot \frac{m}{v}\right)\\
\end{array}
\end{array}
if m < 1Initial program 100.0%
Taylor expanded in m around 0 97.0%
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 inf 97.8%
neg-mul-197.8%
distribute-neg-frac297.8%
Simplified97.8%
Final simplification97.4%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (* (- 1.0 m) (+ -1.0 (/ m v))) (* (- 1.0 m) (- -1.0 (/ (* m m) v)))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (1.0 - m) * (-1.0 + (m / v));
} else {
tmp = (1.0 - m) * (-1.0 - ((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 = (1.0d0 - m) * ((-1.0d0) + (m / v))
else
tmp = (1.0d0 - m) * ((-1.0d0) - ((m * m) / v))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (1.0 - m) * (-1.0 + (m / v));
} else {
tmp = (1.0 - m) * (-1.0 - ((m * m) / v));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (1.0 - m) * (-1.0 + (m / v)) else: tmp = (1.0 - m) * (-1.0 - ((m * m) / v)) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(Float64(1.0 - m) * Float64(-1.0 + Float64(m / v))); else tmp = Float64(Float64(1.0 - m) * Float64(-1.0 - Float64(Float64(m * m) / v))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = (1.0 - m) * (-1.0 + (m / v)); else tmp = (1.0 - m) * (-1.0 - ((m * m) / v)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(1.0 - m), $MachinePrecision] * N[(-1.0 + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - m), $MachinePrecision] * N[(-1.0 - N[(N[(m * m), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;\left(1 - m\right) \cdot \left(-1 + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - m\right) \cdot \left(-1 - \frac{m \cdot m}{v}\right)\\
\end{array}
\end{array}
if m < 1Initial program 100.0%
Taylor expanded in m around 0 97.0%
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 inf 97.8%
neg-mul-197.8%
distribute-neg-frac297.8%
Simplified97.8%
*-commutative97.8%
distribute-frac-neg297.8%
distribute-frac-neg97.8%
associate-*l/97.9%
Applied egg-rr97.9%
Final simplification97.5%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (* (- 1.0 m) (+ -1.0 (/ m v))) (* m (/ (+ 1.0 m) v))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (1.0 - m) * (-1.0 + (m / v));
} else {
tmp = 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 <= 1.0d0) then
tmp = (1.0d0 - m) * ((-1.0d0) + (m / v))
else
tmp = m * ((1.0d0 + m) / v)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (1.0 - m) * (-1.0 + (m / v));
} else {
tmp = m * ((1.0 + m) / v);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (1.0 - m) * (-1.0 + (m / v)) else: tmp = m * ((1.0 + m) / v) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(Float64(1.0 - m) * Float64(-1.0 + Float64(m / v))); else tmp = Float64(m * Float64(Float64(1.0 + m) / v)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = (1.0 - m) * (-1.0 + (m / v)); else tmp = m * ((1.0 + m) / v); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(1.0 - m), $MachinePrecision] * N[(-1.0 + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(m * N[(N[(1.0 + m), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;\left(1 - m\right) \cdot \left(-1 + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;m \cdot \frac{1 + m}{v}\\
\end{array}
\end{array}
if m < 1Initial program 100.0%
Taylor expanded in m around 0 97.0%
if 1 < m Initial program 99.9%
Taylor expanded in m around 0 0.1%
*-commutative0.1%
sub-neg0.1%
metadata-eval0.1%
distribute-rgt-in0.1%
*-commutative0.1%
add-sqr-sqrt0.0%
sqrt-unprod77.9%
sqr-neg77.9%
sqrt-unprod77.9%
add-sqr-sqrt77.9%
neg-sub077.9%
associate--r-77.9%
metadata-eval77.9%
neg-mul-177.9%
neg-sub077.9%
associate--r-77.9%
metadata-eval77.9%
Applied egg-rr77.9%
*-commutative77.9%
distribute-lft1-in77.9%
+-commutative77.9%
Simplified77.9%
Taylor expanded in v around 0 77.9%
sub-neg77.9%
metadata-eval77.9%
+-commutative77.9%
associate-*r/77.9%
Simplified77.9%
Applied egg-rr77.9%
/-rgt-identity77.9%
associate-*r/77.9%
hypot-undefine77.9%
hypot-undefine77.9%
rem-square-sqrt77.9%
metadata-eval77.9%
rem-square-sqrt77.9%
*-rgt-identity77.9%
distribute-rgt1-in77.9%
distribute-lft1-in77.9%
*-rgt-identity77.9%
Simplified77.9%
Final simplification87.5%
(FPCore (m v) :precision binary64 (* (+ m -1.0) (- (* m (/ (+ m -1.0) v)) -1.0)))
double code(double m, double v) {
return (m + -1.0) * ((m * ((m + -1.0) / v)) - -1.0);
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = (m + (-1.0d0)) * ((m * ((m + (-1.0d0)) / v)) - (-1.0d0))
end function
public static double code(double m, double v) {
return (m + -1.0) * ((m * ((m + -1.0) / v)) - -1.0);
}
def code(m, v): return (m + -1.0) * ((m * ((m + -1.0) / v)) - -1.0)
function code(m, v) return Float64(Float64(m + -1.0) * Float64(Float64(m * Float64(Float64(m + -1.0) / v)) - -1.0)) end
function tmp = code(m, v) tmp = (m + -1.0) * ((m * ((m + -1.0) / v)) - -1.0); end
code[m_, v_] := N[(N[(m + -1.0), $MachinePrecision] * N[(N[(m * N[(N[(m + -1.0), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(m + -1\right) \cdot \left(m \cdot \frac{m + -1}{v} - -1\right)
\end{array}
Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (m v) :precision binary64 (if (<= m 0.28) (+ (/ m v) (+ m -1.0)) (* m (/ m v))))
double code(double m, double v) {
double tmp;
if (m <= 0.28) {
tmp = (m / v) + (m + -1.0);
} 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 <= 0.28d0) then
tmp = (m / v) + (m + (-1.0d0))
else
tmp = m * (m / v)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 0.28) {
tmp = (m / v) + (m + -1.0);
} else {
tmp = m * (m / v);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 0.28: tmp = (m / v) + (m + -1.0) else: tmp = m * (m / v) return tmp
function code(m, v) tmp = 0.0 if (m <= 0.28) tmp = Float64(Float64(m / v) + Float64(m + -1.0)); else tmp = Float64(m * Float64(m / v)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 0.28) tmp = (m / v) + (m + -1.0); else tmp = m * (m / v); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 0.28], N[(N[(m / v), $MachinePrecision] + N[(m + -1.0), $MachinePrecision]), $MachinePrecision], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.28:\\
\;\;\;\;\frac{m}{v} + \left(m + -1\right)\\
\mathbf{else}:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\end{array}
\end{array}
if m < 0.28000000000000003Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*99.7%
metadata-eval99.7%
Simplified99.7%
distribute-lft-in99.7%
fma-define99.7%
*-commutative99.7%
neg-mul-199.7%
fmm-undef99.7%
associate-*r/100.0%
clear-num99.7%
un-div-inv99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Taylor expanded in m around 0 97.6%
if 0.28000000000000003 < m Initial program 99.9%
Taylor expanded in m around 0 0.3%
*-commutative0.3%
sub-neg0.3%
metadata-eval0.3%
distribute-rgt-in0.3%
*-commutative0.3%
add-sqr-sqrt0.2%
sqrt-unprod77.4%
sqr-neg77.4%
sqrt-unprod77.3%
add-sqr-sqrt77.3%
neg-sub077.3%
associate--r-77.3%
metadata-eval77.3%
neg-mul-177.3%
neg-sub077.3%
associate--r-77.3%
metadata-eval77.3%
Applied egg-rr77.3%
*-commutative77.3%
distribute-lft1-in77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in v around 0 77.3%
sub-neg77.3%
metadata-eval77.3%
+-commutative77.3%
associate-*r/77.3%
Simplified77.3%
Taylor expanded in m around inf 77.4%
Final simplification87.4%
(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%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in v around inf 27.8%
neg-mul-127.8%
sub-neg27.8%
+-commutative27.8%
distribute-neg-in27.8%
remove-double-neg27.8%
metadata-eval27.8%
Simplified27.8%
Final simplification27.8%
(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%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in m around 0 25.3%
Final simplification25.3%
herbie shell --seed 2024112
(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)))