
(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 10 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 (* m (+ (* (/ m v) (- 1.0 m)) -1.0)))
double code(double m, double v) {
return m * (((m / v) * (1.0 - m)) + -1.0);
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = m * (((m / v) * (1.0d0 - m)) + (-1.0d0))
end function
public static double code(double m, double v) {
return m * (((m / v) * (1.0 - m)) + -1.0);
}
def code(m, v): return m * (((m / v) * (1.0 - m)) + -1.0)
function code(m, v) return Float64(m * Float64(Float64(Float64(m / v) * Float64(1.0 - m)) + -1.0)) end
function tmp = code(m, v) tmp = m * (((m / v) * (1.0 - m)) + -1.0); end
code[m_, v_] := N[(m * N[(N[(N[(m / v), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + -1\right)
\end{array}
Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in99.8%
*-commutative99.8%
associate-*l/94.1%
associate-*r/99.8%
*-lft-identity99.8%
associate-*l/99.8%
associate-*r*99.8%
*-commutative99.8%
distribute-rgt-out99.8%
associate-*r/99.8%
associate-/l*99.8%
/-rgt-identity99.8%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (m v)
:precision binary64
(if (<= m 2.7e-154)
(- m)
(if (<= m 2.8e-128)
(* m (/ m v))
(if (<= m 1.95e-118)
(- m)
(if (<= m 1.0) (/ m (/ v m)) (* (/ m v) (- m)))))))
double code(double m, double v) {
double tmp;
if (m <= 2.7e-154) {
tmp = -m;
} else if (m <= 2.8e-128) {
tmp = m * (m / v);
} else if (m <= 1.95e-118) {
tmp = -m;
} else if (m <= 1.0) {
tmp = m / (v / m);
} else {
tmp = (m / v) * -m;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 2.7d-154) then
tmp = -m
else if (m <= 2.8d-128) then
tmp = m * (m / v)
else if (m <= 1.95d-118) then
tmp = -m
else if (m <= 1.0d0) then
tmp = m / (v / m)
else
tmp = (m / v) * -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 2.7e-154) {
tmp = -m;
} else if (m <= 2.8e-128) {
tmp = m * (m / v);
} else if (m <= 1.95e-118) {
tmp = -m;
} else if (m <= 1.0) {
tmp = m / (v / m);
} else {
tmp = (m / v) * -m;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 2.7e-154: tmp = -m elif m <= 2.8e-128: tmp = m * (m / v) elif m <= 1.95e-118: tmp = -m elif m <= 1.0: tmp = m / (v / m) else: tmp = (m / v) * -m return tmp
function code(m, v) tmp = 0.0 if (m <= 2.7e-154) tmp = Float64(-m); elseif (m <= 2.8e-128) tmp = Float64(m * Float64(m / v)); elseif (m <= 1.95e-118) tmp = Float64(-m); elseif (m <= 1.0) tmp = Float64(m / Float64(v / m)); else tmp = Float64(Float64(m / v) * Float64(-m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 2.7e-154) tmp = -m; elseif (m <= 2.8e-128) tmp = m * (m / v); elseif (m <= 1.95e-118) tmp = -m; elseif (m <= 1.0) tmp = m / (v / m); else tmp = (m / v) * -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 2.7e-154], (-m), If[LessEqual[m, 2.8e-128], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.95e-118], (-m), If[LessEqual[m, 1.0], N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * (-m)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.7 \cdot 10^{-154}:\\
\;\;\;\;-m\\
\mathbf{elif}\;m \leq 2.8 \cdot 10^{-128}:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\mathbf{elif}\;m \leq 1.95 \cdot 10^{-118}:\\
\;\;\;\;-m\\
\mathbf{elif}\;m \leq 1:\\
\;\;\;\;\frac{m}{\frac{v}{m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(-m\right)\\
\end{array}
\end{array}
if m < 2.69999999999999989e-154 or 2.7999999999999998e-128 < m < 1.95e-118Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/80.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.8%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 78.1%
neg-mul-178.1%
Simplified78.1%
if 2.69999999999999989e-154 < m < 2.7999999999999998e-128Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in99.8%
*-commutative99.8%
associate-*l/99.7%
associate-*r/99.8%
*-lft-identity99.8%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.8%
associate-/l*99.8%
/-rgt-identity99.8%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in v around 0 68.9%
unpow268.9%
sqr-neg68.9%
associate-/l*68.9%
sqr-neg68.9%
Simplified68.9%
Taylor expanded in m around 0 68.9%
unpow268.9%
associate-*r/69.0%
Simplified69.0%
if 1.95e-118 < m < 1Initial program 99.5%
*-commutative99.5%
sub-neg99.5%
distribute-lft-in99.5%
*-commutative99.5%
associate-*l/99.7%
associate-*r/99.4%
*-lft-identity99.4%
associate-*l/99.5%
associate-*r*99.5%
*-commutative99.5%
distribute-rgt-out99.5%
associate-*r/99.5%
associate-/l*99.5%
/-rgt-identity99.5%
associate-*l/99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in v around 0 78.4%
unpow278.4%
sqr-neg78.4%
associate-/l*78.4%
sqr-neg78.4%
Simplified78.4%
Taylor expanded in m around 0 73.3%
unpow273.3%
associate-*r/73.1%
Simplified73.1%
clear-num73.2%
div-inv73.4%
Applied egg-rr73.4%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in v around 0 99.9%
unpow299.9%
sqr-neg99.9%
associate-/l*99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in m around 0 0.1%
unpow20.1%
associate-*r/0.1%
Simplified0.1%
clear-num0.1%
div-inv0.1%
Applied egg-rr0.1%
associate-/l*0.1%
frac-2neg0.1%
distribute-frac-neg0.1%
add-sqr-sqrt0.0%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-unprod74.2%
add-sqr-sqrt74.2%
associate-*l/74.2%
*-commutative74.2%
Applied egg-rr74.2%
Final simplification75.0%
(FPCore (m v) :precision binary64 (if (<= m 2.55e-14) (- (/ m (/ v m)) m) (* m (/ m (/ v (- 1.0 m))))))
double code(double m, double v) {
double tmp;
if (m <= 2.55e-14) {
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 <= 2.55d-14) 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 <= 2.55e-14) {
tmp = (m / (v / m)) - m;
} else {
tmp = m * (m / (v / (1.0 - m)));
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 2.55e-14: tmp = (m / (v / m)) - m else: tmp = m * (m / (v / (1.0 - m))) return tmp
function code(m, v) tmp = 0.0 if (m <= 2.55e-14) tmp = Float64(Float64(m / Float64(v / m)) - m); else tmp = Float64(m * Float64(m / Float64(v / Float64(1.0 - m)))); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 2.55e-14) tmp = (m / (v / m)) - m; else tmp = m * (m / (v / (1.0 - m))); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 2.55e-14], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m * N[(m / N[(v / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.55 \cdot 10^{-14}:\\
\;\;\;\;\frac{m}{\frac{v}{m}} - m\\
\mathbf{else}:\\
\;\;\;\;m \cdot \frac{m}{\frac{v}{1 - m}}\\
\end{array}
\end{array}
if m < 2.5499999999999999e-14Initial program 99.7%
associate-*r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in m around 0 88.4%
mul-1-neg88.4%
+-commutative88.4%
unpow288.4%
associate-*r/99.8%
unsub-neg99.8%
Simplified99.8%
clear-num42.4%
div-inv42.5%
Applied egg-rr99.8%
if 2.5499999999999999e-14 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
associate-*r/99.9%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
metadata-eval99.9%
fma-neg99.9%
associate-*r/99.9%
*-commutative99.9%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in m around inf 30.9%
+-commutative30.9%
unpow230.9%
associate-/l*30.9%
mul-1-neg30.9%
unsub-neg30.9%
associate-/l*30.9%
*-lft-identity30.9%
associate-*l/30.9%
associate-/r/30.9%
cube-mult30.9%
associate-/l*30.9%
div-sub99.1%
associate-/l*99.1%
*-commutative99.1%
associate-*l*99.1%
associate-*r/99.1%
associate-/l*99.1%
Simplified99.1%
Final simplification99.5%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (- (/ m (/ v m)) m) (/ (* m m) (/ (- v) m))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m / (v / m)) - m;
} else {
tmp = (m * m) / (-v / m);
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.0d0) then
tmp = (m / (v / m)) - m
else
tmp = (m * m) / (-v / m)
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m / (v / m)) - m;
} else {
tmp = (m * m) / (-v / m);
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (m / (v / m)) - m else: tmp = (m * m) / (-v / m) return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(Float64(m / Float64(v / m)) - m); else tmp = Float64(Float64(m * m) / Float64(Float64(-v) / m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = (m / (v / m)) - m; else tmp = (m * m) / (-v / m); end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(N[(m * m), $MachinePrecision] / N[((-v) / m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;\frac{m}{\frac{v}{m}} - m\\
\mathbf{else}:\\
\;\;\;\;\frac{m \cdot m}{\frac{-v}{m}}\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
associate-*r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in m around 0 87.0%
mul-1-neg87.0%
+-commutative87.0%
unpow287.0%
associate-*r/97.8%
unsub-neg97.8%
Simplified97.8%
clear-num42.5%
div-inv42.6%
Applied egg-rr97.9%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in v around 0 99.9%
unpow299.9%
sqr-neg99.9%
associate-/l*99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in m around inf 98.2%
associate-*r/98.2%
neg-mul-198.2%
Simplified98.2%
Final simplification98.0%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (* m (+ (/ m v) -1.0)) (* (/ m v) (- m))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = m * ((m / v) + -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 (m <= 1.0d0) then
tmp = m * ((m / v) + (-1.0d0))
else
tmp = (m / v) * -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = m * ((m / v) + -1.0);
} else {
tmp = (m / v) * -m;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = m * ((m / v) + -1.0) else: tmp = (m / v) * -m return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(m * Float64(Float64(m / v) + -1.0)); else tmp = Float64(Float64(m / v) * Float64(-m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = m * ((m / v) + -1.0); else tmp = (m / v) * -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(m * N[(N[(m / v), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * (-m)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(-m\right)\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
associate-*r/99.7%
fma-def99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in m around 0 97.8%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in v around 0 99.9%
unpow299.9%
sqr-neg99.9%
associate-/l*99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in m around 0 0.1%
unpow20.1%
associate-*r/0.1%
Simplified0.1%
clear-num0.1%
div-inv0.1%
Applied egg-rr0.1%
associate-/l*0.1%
frac-2neg0.1%
distribute-frac-neg0.1%
add-sqr-sqrt0.0%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-unprod74.2%
add-sqr-sqrt74.2%
associate-*l/74.2%
*-commutative74.2%
Applied egg-rr74.2%
Final simplification86.7%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (- (* m (/ m v)) m) (* (/ m v) (- m))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m * (m / v)) - m;
} else {
tmp = (m / v) * -m;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.0d0) then
tmp = (m * (m / v)) - m
else
tmp = (m / v) * -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m * (m / v)) - m;
} else {
tmp = (m / v) * -m;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (m * (m / v)) - m else: tmp = (m / v) * -m return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(Float64(m * Float64(m / v)) - m); else tmp = Float64(Float64(m / v) * Float64(-m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = (m * (m / v)) - m; else tmp = (m / v) * -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * (-m)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(-m\right)\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
associate-*r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in m around 0 87.0%
mul-1-neg87.0%
+-commutative87.0%
unpow287.0%
associate-*r/97.8%
unsub-neg97.8%
Simplified97.8%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in v around 0 99.9%
unpow299.9%
sqr-neg99.9%
associate-/l*99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in m around 0 0.1%
unpow20.1%
associate-*r/0.1%
Simplified0.1%
clear-num0.1%
div-inv0.1%
Applied egg-rr0.1%
associate-/l*0.1%
frac-2neg0.1%
distribute-frac-neg0.1%
add-sqr-sqrt0.0%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-unprod74.2%
add-sqr-sqrt74.2%
associate-*l/74.2%
*-commutative74.2%
Applied egg-rr74.2%
Final simplification86.7%
(FPCore (m v) :precision binary64 (if (<= m 1.0) (- (/ m (/ v m)) m) (* (/ m v) (- m))))
double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m / (v / m)) - m;
} else {
tmp = (m / v) * -m;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (m <= 1.0d0) then
tmp = (m / (v / m)) - m
else
tmp = (m / v) * -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (m <= 1.0) {
tmp = (m / (v / m)) - m;
} else {
tmp = (m / v) * -m;
}
return tmp;
}
def code(m, v): tmp = 0 if m <= 1.0: tmp = (m / (v / m)) - m else: tmp = (m / v) * -m return tmp
function code(m, v) tmp = 0.0 if (m <= 1.0) tmp = Float64(Float64(m / Float64(v / m)) - m); else tmp = Float64(Float64(m / v) * Float64(-m)); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (m <= 1.0) tmp = (m / (v / m)) - m; else tmp = (m / v) * -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(N[(m / v), $MachinePrecision] * (-m)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;\frac{m}{\frac{v}{m}} - m\\
\mathbf{else}:\\
\;\;\;\;\frac{m}{v} \cdot \left(-m\right)\\
\end{array}
\end{array}
if m < 1Initial program 99.7%
associate-*r/99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in m around 0 87.0%
mul-1-neg87.0%
+-commutative87.0%
unpow287.0%
associate-*r/97.8%
unsub-neg97.8%
Simplified97.8%
clear-num42.5%
div-inv42.6%
Applied egg-rr97.9%
if 1 < m Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/99.9%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in v around 0 99.9%
unpow299.9%
sqr-neg99.9%
associate-/l*99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in m around 0 0.1%
unpow20.1%
associate-*r/0.1%
Simplified0.1%
clear-num0.1%
div-inv0.1%
Applied egg-rr0.1%
associate-/l*0.1%
frac-2neg0.1%
distribute-frac-neg0.1%
add-sqr-sqrt0.0%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-unprod74.2%
add-sqr-sqrt74.2%
associate-*l/74.2%
*-commutative74.2%
Applied egg-rr74.2%
Final simplification86.8%
(FPCore (m v) :precision binary64 (if (<= v 6.6e-198) (* m (/ m v)) (- m)))
double code(double m, double v) {
double tmp;
if (v <= 6.6e-198) {
tmp = m * (m / v);
} else {
tmp = -m;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (v <= 6.6d-198) then
tmp = m * (m / v)
else
tmp = -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (v <= 6.6e-198) {
tmp = m * (m / v);
} else {
tmp = -m;
}
return tmp;
}
def code(m, v): tmp = 0 if v <= 6.6e-198: tmp = m * (m / v) else: tmp = -m return tmp
function code(m, v) tmp = 0.0 if (v <= 6.6e-198) tmp = Float64(m * Float64(m / v)); else tmp = Float64(-m); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (v <= 6.6e-198) tmp = m * (m / v); else tmp = -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[v, 6.6e-198], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision], (-m)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 6.6 \cdot 10^{-198}:\\
\;\;\;\;m \cdot \frac{m}{v}\\
\mathbf{else}:\\
\;\;\;\;-m\\
\end{array}
\end{array}
if v < 6.6000000000000001e-198Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
distribute-lft-in99.7%
*-commutative99.7%
associate-*l/86.9%
associate-*r/99.7%
*-lft-identity99.7%
associate-*l/99.7%
associate-*r*99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r/99.7%
associate-/l*99.7%
/-rgt-identity99.7%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in v around 0 83.1%
unpow283.1%
sqr-neg83.1%
associate-/l*83.1%
sqr-neg83.1%
Simplified83.1%
Taylor expanded in m around 0 34.4%
unpow234.4%
associate-*r/43.0%
Simplified43.0%
if 6.6000000000000001e-198 < v Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/98.2%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 44.5%
neg-mul-144.5%
Simplified44.5%
Final simplification44.0%
(FPCore (m v) :precision binary64 (if (<= v 2.2e-196) (/ m (/ v m)) (- m)))
double code(double m, double v) {
double tmp;
if (v <= 2.2e-196) {
tmp = m / (v / m);
} else {
tmp = -m;
}
return tmp;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
real(8) :: tmp
if (v <= 2.2d-196) then
tmp = m / (v / m)
else
tmp = -m
end if
code = tmp
end function
public static double code(double m, double v) {
double tmp;
if (v <= 2.2e-196) {
tmp = m / (v / m);
} else {
tmp = -m;
}
return tmp;
}
def code(m, v): tmp = 0 if v <= 2.2e-196: tmp = m / (v / m) else: tmp = -m return tmp
function code(m, v) tmp = 0.0 if (v <= 2.2e-196) tmp = Float64(m / Float64(v / m)); else tmp = Float64(-m); end return tmp end
function tmp_2 = code(m, v) tmp = 0.0; if (v <= 2.2e-196) tmp = m / (v / m); else tmp = -m; end tmp_2 = tmp; end
code[m_, v_] := If[LessEqual[v, 2.2e-196], N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision], (-m)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 2.2 \cdot 10^{-196}:\\
\;\;\;\;\frac{m}{\frac{v}{m}}\\
\mathbf{else}:\\
\;\;\;\;-m\\
\end{array}
\end{array}
if v < 2.20000000000000015e-196Initial program 99.7%
*-commutative99.7%
sub-neg99.7%
distribute-lft-in99.7%
*-commutative99.7%
associate-*l/86.9%
associate-*r/99.7%
*-lft-identity99.7%
associate-*l/99.7%
associate-*r*99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r/99.7%
associate-/l*99.7%
/-rgt-identity99.7%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in v around 0 83.1%
unpow283.1%
sqr-neg83.1%
associate-/l*83.1%
sqr-neg83.1%
Simplified83.1%
Taylor expanded in m around 0 34.4%
unpow234.4%
associate-*r/43.0%
Simplified43.0%
clear-num43.0%
div-inv43.1%
Applied egg-rr43.1%
if 2.20000000000000015e-196 < v Initial program 99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
associate-*l/98.2%
associate-*r/99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
associate-*r/99.9%
associate-/l*99.9%
/-rgt-identity99.9%
associate-*l/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in m around 0 44.5%
neg-mul-144.5%
Simplified44.5%
Final simplification44.0%
(FPCore (m v) :precision binary64 (- m))
double code(double m, double v) {
return -m;
}
real(8) function code(m, v)
real(8), intent (in) :: m
real(8), intent (in) :: v
code = -m
end function
public static double code(double m, double v) {
return -m;
}
def code(m, v): return -m
function code(m, v) return Float64(-m) end
function tmp = code(m, v) tmp = -m; end
code[m_, v_] := (-m)
\begin{array}{l}
\\
-m
\end{array}
Initial program 99.8%
*-commutative99.8%
sub-neg99.8%
distribute-lft-in99.8%
*-commutative99.8%
associate-*l/94.1%
associate-*r/99.8%
*-lft-identity99.8%
associate-*l/99.8%
associate-*r*99.8%
*-commutative99.8%
distribute-rgt-out99.8%
associate-*r/99.8%
associate-/l*99.8%
/-rgt-identity99.8%
associate-*l/99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in m around 0 31.1%
neg-mul-131.1%
Simplified31.1%
Final simplification31.1%
herbie shell --seed 2023229
(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))