
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_0) INFINITY)
(* (cos (- (/ K (/ 2.0 (+ m n))) M)) t_0)
t_0)))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_0) <= ((double) INFINITY)) {
tmp = cos(((K / (2.0 / (m + n))) - M)) * t_0;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((Math.cos((((K * (m + n)) / 2.0) - M)) * t_0) <= Double.POSITIVE_INFINITY) {
tmp = Math.cos(((K / (2.0 / (m + n))) - M)) * t_0;
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0))) tmp = 0 if (math.cos((((K * (m + n)) / 2.0) - M)) * t_0) <= math.inf: tmp = math.cos(((K / (2.0 / (m + n))) - M)) * t_0 else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_0) <= Inf) tmp = Float64(cos(Float64(Float64(K / Float64(2.0 / Float64(m + n))) - M)) * t_0); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); tmp = 0.0; if ((cos((((K * (m + n)) / 2.0) - M)) * t_0) <= Inf) tmp = cos(((K / (2.0 / (m + n))) - M)) * t_0; else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], Infinity], N[(N[Cos[N[(N[(K / N[(2.0 / N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t\_0 \leq \infty:\\
\;\;\;\;\cos \left(\frac{K}{\frac{2}{m + n}} - M\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 97.1%
associate-/l*97.7%
+-commutative97.7%
fabs-sub97.7%
+-commutative97.7%
Simplified97.7%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
associate-/l*0.0%
+-commutative0.0%
fabs-sub0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Final simplification98.2%
(FPCore (K m n M l) :precision binary64 (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0))))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 77.0%
associate-/l*77.5%
+-commutative77.5%
fabs-sub77.5%
+-commutative77.5%
Simplified77.5%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in M around 0 96.3%
Final simplification96.3%
(FPCore (K m n M l) :precision binary64 (if (<= m -58.0) (exp (* -0.25 (pow m 2.0))) (exp (+ (* (+ m (- (* n 0.5) M)) (- M (* n 0.5))) (- (fabs (- m n)) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -58.0) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else {
tmp = exp((((m + ((n * 0.5) - M)) * (M - (n * 0.5))) + (fabs((m - n)) - l)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-58.0d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = exp((((m + ((n * 0.5d0) - m_1)) * (m_1 - (n * 0.5d0))) + (abs((m - n)) - l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -58.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.exp((((m + ((n * 0.5) - M)) * (M - (n * 0.5))) + (Math.abs((m - n)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -58.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.exp((((m + ((n * 0.5) - M)) * (M - (n * 0.5))) + (math.fabs((m - n)) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -58.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = exp(Float64(Float64(Float64(m + Float64(Float64(n * 0.5) - M)) * Float64(M - Float64(n * 0.5))) + Float64(abs(Float64(m - n)) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -58.0) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = exp((((m + ((n * 0.5) - M)) * (M - (n * 0.5))) + (abs((m - n)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -58.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(N[(m + N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -58:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(m + \left(n \cdot 0.5 - M\right)\right) \cdot \left(M - n \cdot 0.5\right) + \left(\left|m - n\right| - \ell\right)}\\
\end{array}
\end{array}
if m < -58Initial program 66.2%
associate-/l*67.6%
+-commutative67.6%
fabs-sub67.6%
+-commutative67.6%
Simplified67.6%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in m around inf 95.8%
Taylor expanded in M around 0 95.8%
if -58 < m Initial program 81.1%
associate-/l*81.3%
+-commutative81.3%
fabs-sub81.3%
+-commutative81.3%
Simplified81.3%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in M around 0 95.9%
Taylor expanded in m around 0 74.5%
+-commutative74.5%
unpow274.5%
distribute-rgt-out82.6%
*-commutative82.6%
*-commutative82.6%
Simplified82.6%
Final simplification86.3%
(FPCore (K m n M l)
:precision binary64
(if (<= m -55.0)
(exp (* -0.25 (pow m 2.0)))
(if (<= m 1.55e-237)
(exp (+ (* M (- m M)) (- (fabs (- m n)) l)))
(exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 1.55e-237) {
tmp = exp(((M * (m - M)) + (fabs((m - n)) - l)));
} else {
tmp = exp((-0.25 * pow(n, 2.0)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-55.0d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 1.55d-237) then
tmp = exp(((m_1 * (m - m_1)) + (abs((m - n)) - l)))
else
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 1.55e-237) {
tmp = Math.exp(((M * (m - M)) + (Math.abs((m - n)) - l)));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -55.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 1.55e-237: tmp = math.exp(((M * (m - M)) + (math.fabs((m - n)) - l))) else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -55.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 1.55e-237) tmp = exp(Float64(Float64(M * Float64(m - M)) + Float64(abs(Float64(m - n)) - l))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -55.0) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= 1.55e-237) tmp = exp(((M * (m - M)) + (abs((m - n)) - l))); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -55.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 1.55e-237], N[Exp[N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -55:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 1.55 \cdot 10^{-237}:\\
\;\;\;\;e^{M \cdot \left(m - M\right) + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -55Initial program 66.2%
associate-/l*67.6%
+-commutative67.6%
fabs-sub67.6%
+-commutative67.6%
Simplified67.6%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in m around inf 95.8%
Taylor expanded in M around 0 95.8%
if -55 < m < 1.5499999999999999e-237Initial program 90.6%
associate-/l*90.7%
+-commutative90.7%
fabs-sub90.7%
+-commutative90.7%
Simplified90.7%
Taylor expanded in K around 0 95.4%
cos-neg95.4%
Simplified95.4%
Taylor expanded in M around 0 95.4%
Taylor expanded in m around 0 95.4%
+-commutative95.4%
unpow295.4%
distribute-rgt-out95.4%
*-commutative95.4%
*-commutative95.4%
Simplified95.4%
Taylor expanded in n around 0 73.8%
associate--r+73.8%
associate-*r*73.8%
neg-mul-173.8%
cancel-sign-sub73.8%
fabs-sub73.8%
Simplified73.8%
if 1.5499999999999999e-237 < m Initial program 76.1%
associate-/l*76.3%
+-commutative76.3%
fabs-sub76.3%
+-commutative76.3%
Simplified76.3%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Taylor expanded in M around 0 96.2%
Taylor expanded in n around inf 57.0%
Final simplification72.0%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -27.0) (not (<= M 8.5e-23))) (exp (* M (- M))) (exp (* -0.25 (pow m 2.0)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -27.0) || !(M <= 8.5e-23)) {
tmp = exp((M * -M));
} else {
tmp = exp((-0.25 * pow(m, 2.0)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((m_1 <= (-27.0d0)) .or. (.not. (m_1 <= 8.5d-23))) then
tmp = exp((m_1 * -m_1))
else
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -27.0) || !(M <= 8.5e-23)) {
tmp = Math.exp((M * -M));
} else {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -27.0) or not (M <= 8.5e-23): tmp = math.exp((M * -M)) else: tmp = math.exp((-0.25 * math.pow(m, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -27.0) || !(M <= 8.5e-23)) tmp = exp(Float64(M * Float64(-M))); else tmp = exp(Float64(-0.25 * (m ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -27.0) || ~((M <= 8.5e-23))) tmp = exp((M * -M)); else tmp = exp((-0.25 * (m ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -27.0], N[Not[LessEqual[M, 8.5e-23]], $MachinePrecision]], N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -27 \lor \neg \left(M \leq 8.5 \cdot 10^{-23}\right):\\
\;\;\;\;e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\end{array}
\end{array}
if M < -27 or 8.4999999999999996e-23 < M Initial program 77.0%
associate-/l*77.0%
+-commutative77.0%
fabs-sub77.0%
+-commutative77.0%
Simplified77.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Taylor expanded in M around inf 97.7%
mul-1-neg97.7%
Simplified97.7%
unpow297.7%
Applied egg-rr97.7%
if -27 < M < 8.4999999999999996e-23Initial program 77.0%
associate-/l*78.0%
+-commutative78.0%
fabs-sub78.0%
+-commutative78.0%
Simplified78.0%
Taylor expanded in K around 0 92.6%
cos-neg92.6%
Simplified92.6%
Taylor expanded in m around inf 58.2%
Taylor expanded in M around 0 58.2%
Final simplification77.6%
(FPCore (K m n M l) :precision binary64 (if (<= m -55.0) (exp (* -0.25 (pow m 2.0))) (if (<= m 6.5e-242) (exp (* M (- M))) (exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 6.5e-242) {
tmp = exp((M * -M));
} else {
tmp = exp((-0.25 * pow(n, 2.0)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-55.0d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 6.5d-242) then
tmp = exp((m_1 * -m_1))
else
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 6.5e-242) {
tmp = Math.exp((M * -M));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -55.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 6.5e-242: tmp = math.exp((M * -M)) else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -55.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 6.5e-242) tmp = exp(Float64(M * Float64(-M))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -55.0) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= 6.5e-242) tmp = exp((M * -M)); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -55.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 6.5e-242], N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -55:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 6.5 \cdot 10^{-242}:\\
\;\;\;\;e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -55Initial program 66.2%
associate-/l*67.6%
+-commutative67.6%
fabs-sub67.6%
+-commutative67.6%
Simplified67.6%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in m around inf 95.8%
Taylor expanded in M around 0 95.8%
if -55 < m < 6.4999999999999998e-242Initial program 90.6%
associate-/l*90.7%
+-commutative90.7%
fabs-sub90.7%
+-commutative90.7%
Simplified90.7%
Taylor expanded in K around 0 95.4%
cos-neg95.4%
Simplified95.4%
Taylor expanded in M around 0 95.4%
Taylor expanded in M around inf 57.1%
mul-1-neg57.1%
Simplified57.1%
unpow257.1%
Applied egg-rr57.1%
if 6.4999999999999998e-242 < m Initial program 76.1%
associate-/l*76.3%
+-commutative76.3%
fabs-sub76.3%
+-commutative76.3%
Simplified76.3%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Taylor expanded in M around 0 96.2%
Taylor expanded in n around inf 57.0%
Final simplification67.8%
(FPCore (K m n M l) :precision binary64 (if (<= l -740.0) (* (cos M) (exp l)) (if (<= l 720.0) (exp (* M (- M))) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -740.0) {
tmp = cos(M) * exp(l);
} else if (l <= 720.0) {
tmp = exp((M * -M));
} else {
tmp = exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (l <= (-740.0d0)) then
tmp = cos(m_1) * exp(l)
else if (l <= 720.0d0) then
tmp = exp((m_1 * -m_1))
else
tmp = exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -740.0) {
tmp = Math.cos(M) * Math.exp(l);
} else if (l <= 720.0) {
tmp = Math.exp((M * -M));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -740.0: tmp = math.cos(M) * math.exp(l) elif l <= 720.0: tmp = math.exp((M * -M)) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -740.0) tmp = Float64(cos(M) * exp(l)); elseif (l <= 720.0) tmp = exp(Float64(M * Float64(-M))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -740.0) tmp = cos(M) * exp(l); elseif (l <= 720.0) tmp = exp((M * -M)); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -740.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 720.0], N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -740:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{elif}\;\ell \leq 720:\\
\;\;\;\;e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < -740Initial program 69.6%
associate-/l*71.4%
+-commutative71.4%
fabs-sub71.4%
+-commutative71.4%
Simplified71.4%
Taylor expanded in K around 0 91.1%
cos-neg91.1%
Simplified91.1%
Taylor expanded in l around inf 15.5%
mul-1-neg15.5%
Simplified15.5%
expm1-log1p-u15.1%
expm1-udef15.1%
add-sqr-sqrt15.1%
sqrt-unprod15.1%
sqr-neg15.1%
sqrt-unprod0.0%
add-sqr-sqrt77.1%
Applied egg-rr77.1%
expm1-def77.1%
expm1-log1p77.1%
Simplified77.1%
if -740 < l < 720Initial program 75.4%
associate-/l*75.7%
+-commutative75.7%
fabs-sub75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in K around 0 96.5%
cos-neg96.5%
Simplified96.5%
Taylor expanded in M around 0 96.5%
Taylor expanded in M around inf 55.3%
mul-1-neg55.3%
Simplified55.3%
unpow255.3%
Applied egg-rr55.3%
if 720 < l Initial program 85.7%
associate-/l*85.7%
+-commutative85.7%
fabs-sub85.7%
+-commutative85.7%
Simplified85.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Final simplification72.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* M (- M)))))
(if (<= M -0.028)
t_0
(if (<= M 1.1e-205)
(exp (- l))
(if (<= M 27.0) (exp (* m (- M (* n 0.5)))) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((M * -M));
double tmp;
if (M <= -0.028) {
tmp = t_0;
} else if (M <= 1.1e-205) {
tmp = exp(-l);
} else if (M <= 27.0) {
tmp = exp((m * (M - (n * 0.5))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = exp((m_1 * -m_1))
if (m_1 <= (-0.028d0)) then
tmp = t_0
else if (m_1 <= 1.1d-205) then
tmp = exp(-l)
else if (m_1 <= 27.0d0) then
tmp = exp((m * (m_1 - (n * 0.5d0))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((M * -M));
double tmp;
if (M <= -0.028) {
tmp = t_0;
} else if (M <= 1.1e-205) {
tmp = Math.exp(-l);
} else if (M <= 27.0) {
tmp = Math.exp((m * (M - (n * 0.5))));
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((M * -M)) tmp = 0 if M <= -0.028: tmp = t_0 elif M <= 1.1e-205: tmp = math.exp(-l) elif M <= 27.0: tmp = math.exp((m * (M - (n * 0.5)))) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(M * Float64(-M))) tmp = 0.0 if (M <= -0.028) tmp = t_0; elseif (M <= 1.1e-205) tmp = exp(Float64(-l)); elseif (M <= 27.0) tmp = exp(Float64(m * Float64(M - Float64(n * 0.5)))); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((M * -M)); tmp = 0.0; if (M <= -0.028) tmp = t_0; elseif (M <= 1.1e-205) tmp = exp(-l); elseif (M <= 27.0) tmp = exp((m * (M - (n * 0.5)))); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -0.028], t$95$0, If[LessEqual[M, 1.1e-205], N[Exp[(-l)], $MachinePrecision], If[LessEqual[M, 27.0], N[Exp[N[(m * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -0.028:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 1.1 \cdot 10^{-205}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{elif}\;M \leq 27:\\
\;\;\;\;e^{m \cdot \left(M - n \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -0.0280000000000000006 or 27 < M Initial program 76.8%
associate-/l*76.8%
+-commutative76.8%
fabs-sub76.8%
+-commutative76.8%
Simplified76.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Taylor expanded in M around inf 98.4%
mul-1-neg98.4%
Simplified98.4%
unpow298.4%
Applied egg-rr98.4%
if -0.0280000000000000006 < M < 1.10000000000000005e-205Initial program 76.8%
associate-/l*77.2%
+-commutative77.2%
fabs-sub77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in K around 0 91.6%
cos-neg91.6%
Simplified91.6%
Taylor expanded in l around inf 47.9%
mul-1-neg47.9%
Simplified47.9%
Taylor expanded in M around 0 47.9%
if 1.10000000000000005e-205 < M < 27Initial program 77.7%
associate-/l*79.5%
+-commutative79.5%
fabs-sub79.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in K around 0 94.4%
cos-neg94.4%
Simplified94.4%
Taylor expanded in M around 0 94.4%
Taylor expanded in m around 0 59.1%
+-commutative59.1%
unpow259.1%
distribute-rgt-out60.9%
*-commutative60.9%
*-commutative60.9%
Simplified60.9%
Taylor expanded in m around inf 34.9%
Final simplification69.9%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -0.028) (not (<= M 27.0))) (exp (* M (- M))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -0.028) || !(M <= 27.0)) {
tmp = exp((M * -M));
} else {
tmp = exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((m_1 <= (-0.028d0)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = exp((m_1 * -m_1))
else
tmp = exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -0.028) || !(M <= 27.0)) {
tmp = Math.exp((M * -M));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -0.028) or not (M <= 27.0): tmp = math.exp((M * -M)) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -0.028) || !(M <= 27.0)) tmp = exp(Float64(M * Float64(-M))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -0.028) || ~((M <= 27.0))) tmp = exp((M * -M)); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -0.028], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -0.028 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if M < -0.0280000000000000006 or 27 < M Initial program 76.8%
associate-/l*76.8%
+-commutative76.8%
fabs-sub76.8%
+-commutative76.8%
Simplified76.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Taylor expanded in M around inf 98.4%
mul-1-neg98.4%
Simplified98.4%
unpow298.4%
Applied egg-rr98.4%
if -0.0280000000000000006 < M < 27Initial program 77.1%
associate-/l*78.2%
+-commutative78.2%
fabs-sub78.2%
+-commutative78.2%
Simplified78.2%
Taylor expanded in K around 0 92.7%
cos-neg92.7%
Simplified92.7%
Taylor expanded in l around inf 42.0%
mul-1-neg42.0%
Simplified42.0%
Taylor expanded in M around 0 42.0%
Final simplification69.6%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 77.0%
associate-/l*77.5%
+-commutative77.5%
fabs-sub77.5%
+-commutative77.5%
Simplified77.5%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in l around inf 35.7%
mul-1-neg35.7%
Simplified35.7%
Taylor expanded in M around 0 35.7%
Final simplification35.7%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 77.0%
associate-/l*77.5%
+-commutative77.5%
fabs-sub77.5%
+-commutative77.5%
Simplified77.5%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in l around inf 35.7%
mul-1-neg35.7%
Simplified35.7%
Taylor expanded in l around 0 6.5%
Final simplification6.5%
herbie shell --seed 2024026
(FPCore (K m n M l)
:name "Maksimov and Kolovsky, Equation (32)"
:precision binary64
(* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))