
(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 12 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) (+ (* (- 1.0 m) (/ m v)) -1.0)))
double code(double m, double v) {
return (1.0 - m) * (((1.0 - m) * (m / v)) + -1.0);
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = (1.0d0 - m) * (((1.0d0 - m) * (m / v)) + (-1.0d0))
end function
public static double code(double m, double v) {
return (1.0 - m) * (((1.0 - m) * (m / v)) + -1.0);
}
def code(m, v): return (1.0 - m) * (((1.0 - m) * (m / v)) + -1.0)
function code(m, v) return Float64(Float64(1.0 - m) * Float64(Float64(Float64(1.0 - m) * Float64(m / v)) + -1.0)) end
function tmp = code(m, v) tmp = (1.0 - m) * (((1.0 - m) * (m / v)) + -1.0); end
code[m_, v_] := N[(N[(1.0 - m), $MachinePrecision] * N[(N[(N[(1.0 - m), $MachinePrecision] * N[(m / v), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - m\right) \cdot \left(\left(1 - m\right) \cdot \frac{m}{v} + -1\right)
\end{array}
Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (m v) :precision binary64 (if (<= m 1.6) (+ (/ m (/ v (- 1.0 m))) (+ m -1.0)) (* (* m (/ m v)) (+ m -2.0))))
double code(double m, double v) {
double tmp;
if (m <= 1.6) {
tmp = (m / (v / (1.0 - m))) + (m + -1.0);
} else {
tmp = (m * (m / v)) * (m + -2.0);
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.6d0) then
tmp = (m / (v / (1.0d0 - m))) + (m + (-1.0d0))
else
tmp = (m * (m / v)) * (m + (-2.0d0))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.6) {
tmp = (m / (v / (1.0 - m))) + (m + -1.0);
} else {
tmp = (m * (m / v)) * (m + -2.0);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.6: tmp = (m / (v / (1.0 - m))) + (m + -1.0) else: tmp = (m * (m / v)) * (m + -2.0) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.6) tmp = Float64(Float64(m / Float64(v / Float64(1.0 - m))) + Float64(m + -1.0)); else tmp = Float64(Float64(m * Float64(m / v)) * Float64(m + -2.0)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.6) tmp = (m / (v / (1.0 - m))) + (m + -1.0); else tmp = (m * (m / v)) * (m + -2.0); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.6], N[(N[(m / N[(v / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(m + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] * N[(m + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.6:\\
\;\;\;\;\frac{m}{\frac{v}{1 - m}} + \left(m + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(m \cdot \frac{m}{v}\right) \cdot \left(m + -2\right)\\
\end{array}
\end{array}
if m < 1.6000000000000001Initial program 100.0%
Taylor expanded in m around 0 98.3%
Taylor expanded in v around 0 98.3%
+-commutative98.3%
mul-1-neg98.3%
unsub-neg98.3%
associate-/l*98.3%
Simplified98.3%
if 1.6000000000000001 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
sub-neg99.9%
distribute-lft-in49.5%
*-commutative49.5%
*-un-lft-identity49.5%
frac-2neg49.5%
div-inv49.5%
fma-def99.9%
Applied egg-rr99.9%
fma-udef49.5%
*-commutative49.5%
distribute-lft-out99.9%
neg-mul-199.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 100.0%
associate-/l*99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
associate-*r/99.9%
neg-mul-199.9%
distribute-neg-in99.9%
metadata-eval99.9%
sub-neg99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in m around inf 23.5%
*-commutative23.5%
unpow223.5%
unpow323.5%
associate-*l/23.5%
distribute-lft-out99.1%
associate-*r/99.1%
Simplified99.1%
Final simplification98.7%
(FPCore (m v) :precision binary64 (if (<= m 4.2e-18) (+ -1.0 (+ m (/ m v))) (/ (- 1.0 m) (/ (/ v m) (- 1.0 m)))))
double code(double m, double v) {
double tmp;
if (m <= 4.2e-18) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = (1.0 - 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 <= 4.2d-18) then
tmp = (-1.0d0) + (m + (m / v))
else
tmp = (1.0d0 - m) / ((v / m) / (1.0d0 - m))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 4.2e-18) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = (1.0 - m) / ((v / m) / (1.0 - m));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 4.2e-18: tmp = -1.0 + (m + (m / v)) else: tmp = (1.0 - m) / ((v / m) / (1.0 - m)) return tmp
function code(m, v) tmp = 0.0 if (m <= 4.2e-18) tmp = Float64(-1.0 + Float64(m + Float64(m / v))); else tmp = Float64(Float64(1.0 - m) / Float64(Float64(v / m) / Float64(1.0 - m))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 4.2e-18) tmp = -1.0 + (m + (m / v)); else tmp = (1.0 - m) / ((v / m) / (1.0 - m)); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 4.2e-18], N[(-1.0 + N[(m + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - m), $MachinePrecision] / N[(N[(v / m), $MachinePrecision] / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 4.2 \cdot 10^{-18}:\\
\;\;\;\;-1 + \left(m + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - m}{\frac{\frac{v}{m}}{1 - m}}\\
\end{array}
\end{array}
if m < 4.19999999999999999e-18Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in m around 0 99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
*-commutative99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
if 4.19999999999999999e-18 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
sub-neg99.9%
distribute-lft-in52.3%
*-commutative52.3%
*-un-lft-identity52.3%
frac-2neg52.3%
div-inv52.3%
fma-def99.9%
Applied egg-rr99.9%
fma-udef52.3%
*-commutative52.3%
distribute-lft-out99.9%
neg-mul-199.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 99.8%
associate-/l*99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
associate-*r/99.7%
neg-mul-199.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
associate-/r*99.7%
Simplified99.7%
Final simplification99.9%
(FPCore (m v) :precision binary64 (if (<= m 2.9e-31) (+ -1.0 (+ m (/ m v))) (/ (* (- 1.0 m) (* m (- 1.0 m))) v)))
double code(double m, double v) {
double tmp;
if (m <= 2.9e-31) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = ((1.0 - 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-31) then
tmp = (-1.0d0) + (m + (m / v))
else
tmp = ((1.0d0 - 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-31) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = ((1.0 - m) * (m * (1.0 - m))) / v;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 2.9e-31: tmp = -1.0 + (m + (m / v)) else: tmp = ((1.0 - m) * (m * (1.0 - m))) / v return tmp
function code(m, v) tmp = 0.0 if (m <= 2.9e-31) tmp = Float64(-1.0 + Float64(m + Float64(m / v))); else tmp = Float64(Float64(Float64(1.0 - m) * Float64(m * Float64(1.0 - m))) / v); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 2.9e-31) tmp = -1.0 + (m + (m / v)); else tmp = ((1.0 - m) * (m * (1.0 - m))) / v; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 2.9e-31], N[(-1.0 + N[(m + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - m), $MachinePrecision] * N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.9 \cdot 10^{-31}:\\
\;\;\;\;-1 + \left(m + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - m\right) \cdot \left(m \cdot \left(1 - m\right)\right)}{v}\\
\end{array}
\end{array}
if m < 2.9000000000000001e-31Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in m around 0 99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
*-commutative99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
if 2.9000000000000001e-31 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
sub-neg99.9%
distribute-lft-in54.8%
*-commutative54.8%
*-un-lft-identity54.8%
frac-2neg54.8%
div-inv54.7%
fma-def99.9%
Applied egg-rr99.9%
fma-udef54.7%
*-commutative54.7%
distribute-lft-out99.9%
neg-mul-199.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 99.8%
mul-1-neg99.8%
associate-*r*99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
*-commutative99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (m v) :precision binary64 (if (<= m 4.05e-165) -1.0 (if (<= m 0.38) (/ m v) (* (/ m v) (* m m)))))
double code(double m, double v) {
double tmp;
if (m <= 4.05e-165) {
tmp = -1.0;
} else if (m <= 0.38) {
tmp = m / v;
} else {
tmp = (m / v) * (m * m);
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 4.05d-165) then
tmp = -1.0d0
else if (m <= 0.38d0) then
tmp = m / v
else
tmp = (m / v) * (m * m)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 4.05e-165) {
tmp = -1.0;
} else if (m <= 0.38) {
tmp = m / v;
} else {
tmp = (m / v) * (m * m);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 4.05e-165: tmp = -1.0 elif m <= 0.38: tmp = m / v else: tmp = (m / v) * (m * m) return tmp
function code(m, v) tmp = 0.0 if (m <= 4.05e-165) tmp = -1.0; elseif (m <= 0.38) tmp = Float64(m / v); else tmp = Float64(Float64(m / v) * Float64(m * m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 4.05e-165) tmp = -1.0; elseif (m <= 0.38) tmp = m / v; else tmp = (m / v) * (m * m); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 4.05e-165], -1.0, If[LessEqual[m, 0.38], N[(m / v), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * N[(m * m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 4.05 \cdot 10^{-165}:\\
\;\;\;\;-1\\
\mathbf{elif}\;m \leq 0.38:\\
\;\;\;\;\frac{m}{v}\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(m \cdot m\right)\\
\end{array}
\end{array}
if m < 4.05000000000000012e-165Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in m around 0 75.6%
if 4.05000000000000012e-165 < m < 0.38Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
*-un-lft-identity99.9%
frac-2neg99.9%
div-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
fma-udef99.5%
*-commutative99.5%
distribute-lft-out99.6%
neg-mul-199.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in v around 0 80.7%
associate-/l*80.4%
sub-neg80.4%
metadata-eval80.4%
+-commutative80.4%
associate-*r/80.4%
neg-mul-180.4%
distribute-neg-in80.4%
metadata-eval80.4%
sub-neg80.4%
associate-/r*80.4%
Simplified80.4%
Taylor expanded in m around 0 77.5%
if 0.38 < 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 98.7%
mul-1-neg98.7%
unpow298.7%
associate-*l/98.7%
distribute-rgt-neg-out98.7%
Simplified98.7%
Taylor expanded in v around 0 98.7%
mul-1-neg98.7%
unpow298.7%
associate-/l*98.7%
distribute-neg-frac98.7%
Simplified98.7%
Taylor expanded in m around inf 98.7%
associate-*r/98.7%
neg-mul-198.7%
Simplified98.7%
div-inv98.6%
add-sqr-sqrt0.0%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.1%
add-sqr-sqrt0.1%
add-sqr-sqrt0.0%
sqrt-unprod96.2%
sqr-neg96.2%
sqrt-unprod98.6%
add-sqr-sqrt98.6%
clear-num98.7%
Applied egg-rr98.7%
Final simplification86.8%
(FPCore (m v) :precision binary64 (if (<= m 2.5) (+ -1.0 (+ m (/ m v))) (* (* m (/ m v)) (+ m -2.0))))
double code(double m, double v) {
double tmp;
if (m <= 2.5) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = (m * (m / v)) * (m + -2.0);
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 2.5d0) then
tmp = (-1.0d0) + (m + (m / v))
else
tmp = (m * (m / v)) * (m + (-2.0d0))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 2.5) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = (m * (m / v)) * (m + -2.0);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 2.5: tmp = -1.0 + (m + (m / v)) else: tmp = (m * (m / v)) * (m + -2.0) return tmp
function code(m, v) tmp = 0.0 if (m <= 2.5) tmp = Float64(-1.0 + Float64(m + Float64(m / v))); else tmp = Float64(Float64(m * Float64(m / v)) * Float64(m + -2.0)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 2.5) tmp = -1.0 + (m + (m / v)); else tmp = (m * (m / v)) * (m + -2.0); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 2.5], N[(-1.0 + N[(m + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] * N[(m + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.5:\\
\;\;\;\;-1 + \left(m + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(m \cdot \frac{m}{v}\right) \cdot \left(m + -2\right)\\
\end{array}
\end{array}
if m < 2.5Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in m around 0 98.0%
sub-neg98.0%
metadata-eval98.0%
+-commutative98.0%
*-commutative98.0%
distribute-lft-in98.0%
*-rgt-identity98.0%
associate-*r/98.2%
*-rgt-identity98.2%
Simplified98.2%
if 2.5 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
sub-neg99.9%
distribute-lft-in49.5%
*-commutative49.5%
*-un-lft-identity49.5%
frac-2neg49.5%
div-inv49.5%
fma-def99.9%
Applied egg-rr99.9%
fma-udef49.5%
*-commutative49.5%
distribute-lft-out99.9%
neg-mul-199.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 100.0%
associate-/l*99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
associate-*r/99.9%
neg-mul-199.9%
distribute-neg-in99.9%
metadata-eval99.9%
sub-neg99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in m around inf 23.5%
*-commutative23.5%
unpow223.5%
unpow323.5%
associate-*l/23.5%
distribute-lft-out99.1%
associate-*r/99.1%
Simplified99.1%
Final simplification98.6%
(FPCore (m v) :precision binary64 (if (<= m 1.6) (* (- 1.0 m) (+ (/ m v) -1.0)) (* (* m (/ m v)) (+ m -2.0))))
double code(double m, double v) {
double tmp;
if (m <= 1.6) {
tmp = (1.0 - m) * ((m / v) + -1.0);
} else {
tmp = (m * (m / v)) * (m + -2.0);
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.6d0) then
tmp = (1.0d0 - m) * ((m / v) + (-1.0d0))
else
tmp = (m * (m / v)) * (m + (-2.0d0))
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.6) {
tmp = (1.0 - m) * ((m / v) + -1.0);
} else {
tmp = (m * (m / v)) * (m + -2.0);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.6: tmp = (1.0 - m) * ((m / v) + -1.0) else: tmp = (m * (m / v)) * (m + -2.0) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.6) tmp = Float64(Float64(1.0 - m) * Float64(Float64(m / v) + -1.0)); else tmp = Float64(Float64(m * Float64(m / v)) * Float64(m + -2.0)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.6) tmp = (1.0 - m) * ((m / v) + -1.0); else tmp = (m * (m / v)) * (m + -2.0); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.6], N[(N[(1.0 - m), $MachinePrecision] * N[(N[(m / v), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] * N[(m + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.6:\\
\;\;\;\;\left(1 - m\right) \cdot \left(\frac{m}{v} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(m \cdot \frac{m}{v}\right) \cdot \left(m + -2\right)\\
\end{array}
\end{array}
if m < 1.6000000000000001Initial program 100.0%
Taylor expanded in m around 0 98.3%
if 1.6000000000000001 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
sub-neg99.9%
distribute-lft-in49.5%
*-commutative49.5%
*-un-lft-identity49.5%
frac-2neg49.5%
div-inv49.5%
fma-def99.9%
Applied egg-rr99.9%
fma-udef49.5%
*-commutative49.5%
distribute-lft-out99.9%
neg-mul-199.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around 0 100.0%
associate-/l*99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
associate-*r/99.9%
neg-mul-199.9%
distribute-neg-in99.9%
metadata-eval99.9%
sub-neg99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in m around inf 23.5%
*-commutative23.5%
unpow223.5%
unpow323.5%
associate-*l/23.5%
distribute-lft-out99.1%
associate-*r/99.1%
Simplified99.1%
Final simplification98.7%
(FPCore (m v) :precision binary64 (if (<= m 1.95e-164) -1.0 (if (<= m 0.28) (/ m v) (* m (/ m v)))))
double code(double m, double v) {
double tmp;
if (m <= 1.95e-164) {
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.95d-164) 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.95e-164) {
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.95e-164: 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.95e-164) 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.95e-164) 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.95e-164], -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.95 \cdot 10^{-164}:\\
\;\;\;\;-1\\
\mathbf{elif}\;m \leq 0.28:\\
\;\;\;\;\frac{m}{v}\\
\mathbf{else}:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\end{array}
\end{array}
if m < 1.9499999999999999e-164Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in m around 0 75.6%
if 1.9499999999999999e-164 < m < 0.28000000000000003Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
*-un-lft-identity99.9%
frac-2neg99.9%
div-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
fma-udef99.5%
*-commutative99.5%
distribute-lft-out99.6%
neg-mul-199.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in v around 0 80.7%
associate-/l*80.4%
sub-neg80.4%
metadata-eval80.4%
+-commutative80.4%
associate-*r/80.4%
neg-mul-180.4%
distribute-neg-in80.4%
metadata-eval80.4%
sub-neg80.4%
associate-/r*80.4%
Simplified80.4%
Taylor expanded in m around 0 77.5%
if 0.28000000000000003 < m Initial program 99.9%
Taylor expanded in m around 0 0.1%
sub-neg0.1%
distribute-lft-in0.1%
*-commutative0.1%
*-un-lft-identity0.1%
sub-neg0.1%
metadata-eval0.1%
sub-neg0.1%
metadata-eval0.1%
add-sqr-sqrt0.0%
sqrt-unprod77.9%
sqr-neg77.9%
sqrt-unprod77.9%
add-sqr-sqrt77.9%
Applied egg-rr77.9%
*-commutative77.9%
distribute-rgt1-in77.9%
Simplified77.9%
Taylor expanded in m around inf 77.9%
unpow277.9%
associate-*r/77.9%
Simplified77.9%
Final simplification77.1%
(FPCore (m v) :precision binary64 (if (<= m 0.38) (+ -1.0 (+ m (/ m v))) (* (/ m v) (* m m))))
double code(double m, double v) {
double tmp;
if (m <= 0.38) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = (m / v) * (m * m);
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 0.38d0) then
tmp = (-1.0d0) + (m + (m / v))
else
tmp = (m / v) * (m * m)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 0.38) {
tmp = -1.0 + (m + (m / v));
} else {
tmp = (m / v) * (m * m);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 0.38: tmp = -1.0 + (m + (m / v)) else: tmp = (m / v) * (m * m) return tmp
function code(m, v) tmp = 0.0 if (m <= 0.38) tmp = Float64(-1.0 + Float64(m + Float64(m / v))); else tmp = Float64(Float64(m / v) * Float64(m * m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 0.38) tmp = -1.0 + (m + (m / v)); else tmp = (m / v) * (m * m); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 0.38], N[(-1.0 + N[(m + N[(m / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * N[(m * m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.38:\\
\;\;\;\;-1 + \left(m + \frac{m}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(m \cdot m\right)\\
\end{array}
\end{array}
if m < 0.38Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in m around 0 98.0%
sub-neg98.0%
metadata-eval98.0%
+-commutative98.0%
*-commutative98.0%
distribute-lft-in98.0%
*-rgt-identity98.0%
associate-*r/98.2%
*-rgt-identity98.2%
Simplified98.2%
if 0.38 < 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 98.7%
mul-1-neg98.7%
unpow298.7%
associate-*l/98.7%
distribute-rgt-neg-out98.7%
Simplified98.7%
Taylor expanded in v around 0 98.7%
mul-1-neg98.7%
unpow298.7%
associate-/l*98.7%
distribute-neg-frac98.7%
Simplified98.7%
Taylor expanded in m around inf 98.7%
associate-*r/98.7%
neg-mul-198.7%
Simplified98.7%
div-inv98.6%
add-sqr-sqrt0.0%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.1%
add-sqr-sqrt0.1%
add-sqr-sqrt0.0%
sqrt-unprod96.2%
sqr-neg96.2%
sqrt-unprod98.6%
add-sqr-sqrt98.6%
clear-num98.7%
Applied egg-rr98.7%
Final simplification98.4%
(FPCore (m v) :precision binary64 (if (<= m 9e-164) -1.0 (/ m v)))
double code(double m, double v) {
double tmp;
if (m <= 9e-164) {
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 (m <= 9d-164) 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 (m <= 9e-164) {
tmp = -1.0;
} else {
tmp = m / v;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 9e-164: tmp = -1.0 else: tmp = m / v return tmp
function code(m, v) tmp = 0.0 if (m <= 9e-164) tmp = -1.0; else tmp = Float64(m / v); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 9e-164) tmp = -1.0; else tmp = m / v; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 9e-164], -1.0, N[(m / v), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 9 \cdot 10^{-164}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v}\\
\end{array}
\end{array}
if m < 8.9999999999999995e-164Initial program 100.0%
*-commutative100.0%
sub-neg100.0%
associate-/l*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in m around 0 75.6%
if 8.9999999999999995e-164 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
associate-/r/99.9%
sub-neg99.9%
distribute-lft-in68.0%
*-commutative68.0%
*-un-lft-identity68.0%
frac-2neg68.0%
div-inv67.9%
fma-def99.8%
Applied egg-rr99.8%
fma-udef67.9%
*-commutative67.9%
distribute-lft-out99.8%
neg-mul-199.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in v around 0 92.9%
associate-/l*92.8%
sub-neg92.8%
metadata-eval92.8%
+-commutative92.8%
associate-*r/92.8%
neg-mul-192.8%
distribute-neg-in92.8%
metadata-eval92.8%
sub-neg92.8%
associate-/r*92.8%
Simplified92.8%
Taylor expanded in m around 0 62.6%
Final simplification66.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%
*-commutative99.9%
sub-neg99.9%
associate-/l*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in v around inf 26.8%
neg-mul-126.8%
neg-sub026.8%
associate--r-26.8%
metadata-eval26.8%
Simplified26.8%
Final simplification26.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.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 24.6%
Final simplification24.6%
herbie shell --seed 2023268
(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)))