
(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 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (* M (+ (* 0.5 (/ (+ m n) M)) -1.0)) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((m - n)) - l) - pow((M * ((0.5 * ((m + n) / M)) + -1.0)), 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 = cos(m_1) * exp(((abs((m - n)) - l) - ((m_1 * ((0.5d0 * ((m + n) / m_1)) + (-1.0d0))) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - Math.pow((M * ((0.5 * ((m + n) / M)) + -1.0)), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((M * ((0.5 * ((m + n) / M)) + -1.0)), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(M * Float64(Float64(0.5 * Float64(Float64(m + n) / M)) + -1.0)) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((M * ((0.5 * ((m + n) / M)) + -1.0)) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(M * N[(N[(0.5 * N[(N[(m + n), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(M \cdot \left(0.5 \cdot \frac{m + n}{M} + -1\right)\right)}^{2}}
\end{array}
Initial program 79.1%
Taylor expanded in K around 0 96.5%
cos-neg96.5%
Simplified96.5%
Taylor expanded in M around inf 96.5%
Final simplification96.5%
(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 79.1%
Taylor expanded in m around inf 85.7%
*-commutative85.7%
associate-*l*85.7%
Simplified85.7%
Taylor expanded in K around 0 96.5%
Final simplification96.5%
(FPCore (K m n M l) :precision binary64 (if (<= m -5.1e+36) (* (cos M) (exp (* -0.25 (pow m 2.0)))) (exp (+ (* (- (* 0.5 n) M) (- (- M (* 0.5 n)) m)) (- (fabs (- m n)) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -5.1e+36) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else {
tmp = exp(((((0.5 * n) - M) * ((M - (0.5 * n)) - m)) + (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 <= (-5.1d+36)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = exp(((((0.5d0 * n) - m_1) * ((m_1 - (0.5d0 * n)) - m)) + (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 <= -5.1e+36) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.exp(((((0.5 * n) - M) * ((M - (0.5 * n)) - m)) + (Math.abs((m - n)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -5.1e+36: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.exp(((((0.5 * n) - M) * ((M - (0.5 * n)) - m)) + (math.fabs((m - n)) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -5.1e+36) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); else tmp = exp(Float64(Float64(Float64(Float64(0.5 * n) - M) * Float64(Float64(M - Float64(0.5 * n)) - m)) + Float64(abs(Float64(m - n)) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -5.1e+36) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); else tmp = exp(((((0.5 * n) - M) * ((M - (0.5 * n)) - m)) + (abs((m - n)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -5.1e+36], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(N[(N[(0.5 * n), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(0.5 * n), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5.1 \cdot 10^{+36}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(0.5 \cdot n - M\right) \cdot \left(\left(M - 0.5 \cdot n\right) - m\right) + \left(\left|m - n\right| - \ell\right)}\\
\end{array}
\end{array}
if m < -5.09999999999999973e36Initial program 69.4%
Taylor expanded in n around 0 58.1%
+-commutative58.1%
unpow258.1%
distribute-rgt-out64.6%
*-commutative64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in m around inf 69.4%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
if -5.09999999999999973e36 < m Initial program 82.2%
Taylor expanded in m around inf 90.4%
*-commutative90.4%
associate-*l*90.4%
Simplified90.4%
Taylor expanded in K around 0 95.9%
Taylor expanded in m around 0 79.0%
+-commutative79.0%
unpow279.0%
distribute-rgt-out84.2%
*-commutative84.2%
*-commutative84.2%
Simplified84.2%
Final simplification87.7%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -1.8e+17) (not (<= m 0.082))) (exp (- (- (fabs (- m n)) l) (* (* 0.5 m) (+ n (* 0.5 m))))) (* 0.5 (* K (* m (* (exp (- l)) (sin M)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -1.8e+17) || !(m <= 0.082)) {
tmp = exp(((fabs((m - n)) - l) - ((0.5 * m) * (n + (0.5 * m)))));
} else {
tmp = 0.5 * (K * (m * (exp(-l) * sin(M))));
}
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.8d+17)) .or. (.not. (m <= 0.082d0))) then
tmp = exp(((abs((m - n)) - l) - ((0.5d0 * m) * (n + (0.5d0 * m)))))
else
tmp = 0.5d0 * (k * (m * (exp(-l) * sin(m_1))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -1.8e+17) || !(m <= 0.082)) {
tmp = Math.exp(((Math.abs((m - n)) - l) - ((0.5 * m) * (n + (0.5 * m)))));
} else {
tmp = 0.5 * (K * (m * (Math.exp(-l) * Math.sin(M))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -1.8e+17) or not (m <= 0.082): tmp = math.exp(((math.fabs((m - n)) - l) - ((0.5 * m) * (n + (0.5 * m))))) else: tmp = 0.5 * (K * (m * (math.exp(-l) * math.sin(M)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -1.8e+17) || !(m <= 0.082)) tmp = exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(Float64(0.5 * m) * Float64(n + Float64(0.5 * m))))); else tmp = Float64(0.5 * Float64(K * Float64(m * Float64(exp(Float64(-l)) * sin(M))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -1.8e+17) || ~((m <= 0.082))) tmp = exp(((abs((m - n)) - l) - ((0.5 * m) * (n + (0.5 * m))))); else tmp = 0.5 * (K * (m * (exp(-l) * sin(M)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -1.8e+17], N[Not[LessEqual[m, 0.082]], $MachinePrecision]], N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(N[(0.5 * m), $MachinePrecision] * N[(n + N[(0.5 * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(0.5 * N[(K * N[(m * N[(N[Exp[(-l)], $MachinePrecision] * N[Sin[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.8 \cdot 10^{+17} \lor \neg \left(m \leq 0.082\right):\\
\;\;\;\;e^{\left(\left|m - n\right| - \ell\right) - \left(0.5 \cdot m\right) \cdot \left(n + 0.5 \cdot m\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(K \cdot \left(m \cdot \left(e^{-\ell} \cdot \sin M\right)\right)\right)\\
\end{array}
\end{array}
if m < -1.8e17 or 0.0820000000000000034 < m Initial program 72.8%
Taylor expanded in n around 0 61.1%
+-commutative61.1%
unpow261.1%
distribute-rgt-out67.0%
*-commutative67.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in K around 0 73.0%
cos-neg73.0%
associate-*r*73.0%
sin-neg73.0%
Simplified73.0%
Taylor expanded in M around 0 89.1%
associate--r+89.1%
fabs-sub89.1%
associate-*r*89.1%
Simplified89.1%
if -1.8e17 < m < 0.0820000000000000034Initial program 86.2%
Taylor expanded in n around 0 64.8%
+-commutative64.8%
unpow264.8%
distribute-rgt-out68.2%
*-commutative68.2%
*-commutative68.2%
Simplified68.2%
Taylor expanded in K around 0 66.2%
cos-neg66.2%
associate-*r*66.2%
sin-neg66.2%
Simplified66.2%
Taylor expanded in m around inf 63.2%
Taylor expanded in l around inf 48.4%
neg-mul-148.4%
Simplified48.4%
Final simplification70.0%
(FPCore (K m n M l)
:precision binary64
(if (<= m -1.8e+17)
(exp (- (- (fabs (- m n)) l) (* (* 0.5 m) (+ n (* 0.5 m)))))
(if (<= m -1.5e-300)
(* (exp (- l)) (cos (* (* 0.5 m) K)))
(* 0.5 (* K (* m (* (exp (* n (- M (* 0.5 m)))) (sin M))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.8e+17) {
tmp = exp(((fabs((m - n)) - l) - ((0.5 * m) * (n + (0.5 * m)))));
} else if (m <= -1.5e-300) {
tmp = exp(-l) * cos(((0.5 * m) * K));
} else {
tmp = 0.5 * (K * (m * (exp((n * (M - (0.5 * m)))) * sin(M))));
}
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.8d+17)) then
tmp = exp(((abs((m - n)) - l) - ((0.5d0 * m) * (n + (0.5d0 * m)))))
else if (m <= (-1.5d-300)) then
tmp = exp(-l) * cos(((0.5d0 * m) * k))
else
tmp = 0.5d0 * (k * (m * (exp((n * (m_1 - (0.5d0 * m)))) * sin(m_1))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.8e+17) {
tmp = Math.exp(((Math.abs((m - n)) - l) - ((0.5 * m) * (n + (0.5 * m)))));
} else if (m <= -1.5e-300) {
tmp = Math.exp(-l) * Math.cos(((0.5 * m) * K));
} else {
tmp = 0.5 * (K * (m * (Math.exp((n * (M - (0.5 * m)))) * Math.sin(M))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1.8e+17: tmp = math.exp(((math.fabs((m - n)) - l) - ((0.5 * m) * (n + (0.5 * m))))) elif m <= -1.5e-300: tmp = math.exp(-l) * math.cos(((0.5 * m) * K)) else: tmp = 0.5 * (K * (m * (math.exp((n * (M - (0.5 * m)))) * math.sin(M)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1.8e+17) tmp = exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(Float64(0.5 * m) * Float64(n + Float64(0.5 * m))))); elseif (m <= -1.5e-300) tmp = Float64(exp(Float64(-l)) * cos(Float64(Float64(0.5 * m) * K))); else tmp = Float64(0.5 * Float64(K * Float64(m * Float64(exp(Float64(n * Float64(M - Float64(0.5 * m)))) * sin(M))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1.8e+17) tmp = exp(((abs((m - n)) - l) - ((0.5 * m) * (n + (0.5 * m))))); elseif (m <= -1.5e-300) tmp = exp(-l) * cos(((0.5 * m) * K)); else tmp = 0.5 * (K * (m * (exp((n * (M - (0.5 * m)))) * sin(M)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1.8e+17], N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(N[(0.5 * m), $MachinePrecision] * N[(n + N[(0.5 * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -1.5e-300], N[(N[Exp[(-l)], $MachinePrecision] * N[Cos[N[(N[(0.5 * m), $MachinePrecision] * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(K * N[(m * N[(N[Exp[N[(n * N[(M - N[(0.5 * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.8 \cdot 10^{+17}:\\
\;\;\;\;e^{\left(\left|m - n\right| - \ell\right) - \left(0.5 \cdot m\right) \cdot \left(n + 0.5 \cdot m\right)}\\
\mathbf{elif}\;m \leq -1.5 \cdot 10^{-300}:\\
\;\;\;\;e^{-\ell} \cdot \cos \left(\left(0.5 \cdot m\right) \cdot K\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(K \cdot \left(m \cdot \left(e^{n \cdot \left(M - 0.5 \cdot m\right)} \cdot \sin M\right)\right)\right)\\
\end{array}
\end{array}
if m < -1.8e17Initial program 70.0%
Taylor expanded in n around 0 58.6%
+-commutative58.6%
unpow258.6%
distribute-rgt-out64.4%
*-commutative64.4%
*-commutative64.4%
Simplified64.4%
Taylor expanded in K around 0 71.6%
cos-neg71.6%
associate-*r*71.6%
sin-neg71.6%
Simplified71.6%
Taylor expanded in M around 0 91.5%
associate--r+91.5%
fabs-sub91.5%
associate-*r*91.5%
Simplified91.5%
if -1.8e17 < m < -1.50000000000000012e-300Initial program 92.2%
Taylor expanded in n around 0 68.3%
+-commutative68.3%
unpow268.3%
distribute-rgt-out74.8%
*-commutative74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in l around inf 38.9%
mul-1-neg38.9%
Simplified38.9%
Taylor expanded in m around inf 40.6%
*-commutative98.7%
associate-*l*98.7%
Simplified40.6%
if -1.50000000000000012e-300 < m Initial program 77.6%
Taylor expanded in n around 0 62.5%
+-commutative62.5%
unpow262.5%
distribute-rgt-out65.7%
*-commutative65.7%
*-commutative65.7%
Simplified65.7%
Taylor expanded in K around 0 67.3%
cos-neg67.3%
associate-*r*67.3%
sin-neg67.3%
Simplified67.3%
Taylor expanded in m around inf 74.7%
Taylor expanded in n around inf 43.1%
Final simplification55.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (fabs (- m n)) l)))
(if (<= m -4e+84)
(exp (+ (* (- (* 0.5 m) M) (- (- M (* 0.5 m)) n)) t_0))
(exp (+ (* (- (* 0.5 n) M) (- (- M (* 0.5 n)) m)) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n)) - l;
double tmp;
if (m <= -4e+84) {
tmp = exp(((((0.5 * m) - M) * ((M - (0.5 * m)) - n)) + t_0));
} else {
tmp = exp(((((0.5 * n) - M) * ((M - (0.5 * n)) - m)) + 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 = abs((m - n)) - l
if (m <= (-4d+84)) then
tmp = exp(((((0.5d0 * m) - m_1) * ((m_1 - (0.5d0 * m)) - n)) + t_0))
else
tmp = exp(((((0.5d0 * n) - m_1) * ((m_1 - (0.5d0 * n)) - m)) + 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.abs((m - n)) - l;
double tmp;
if (m <= -4e+84) {
tmp = Math.exp(((((0.5 * m) - M) * ((M - (0.5 * m)) - n)) + t_0));
} else {
tmp = Math.exp(((((0.5 * n) - M) * ((M - (0.5 * n)) - m)) + t_0));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) - l tmp = 0 if m <= -4e+84: tmp = math.exp(((((0.5 * m) - M) * ((M - (0.5 * m)) - n)) + t_0)) else: tmp = math.exp(((((0.5 * n) - M) * ((M - (0.5 * n)) - m)) + t_0)) return tmp
function code(K, m, n, M, l) t_0 = Float64(abs(Float64(m - n)) - l) tmp = 0.0 if (m <= -4e+84) tmp = exp(Float64(Float64(Float64(Float64(0.5 * m) - M) * Float64(Float64(M - Float64(0.5 * m)) - n)) + t_0)); else tmp = exp(Float64(Float64(Float64(Float64(0.5 * n) - M) * Float64(Float64(M - Float64(0.5 * n)) - m)) + t_0)); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)) - l; tmp = 0.0; if (m <= -4e+84) tmp = exp(((((0.5 * m) - M) * ((M - (0.5 * m)) - n)) + t_0)); else tmp = exp(((((0.5 * n) - M) * ((M - (0.5 * n)) - m)) + t_0)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[LessEqual[m, -4e+84], N[Exp[N[(N[(N[(N[(0.5 * m), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(0.5 * m), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(N[(N[(0.5 * n), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(0.5 * n), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right| - \ell\\
\mathbf{if}\;m \leq -4 \cdot 10^{+84}:\\
\;\;\;\;e^{\left(0.5 \cdot m - M\right) \cdot \left(\left(M - 0.5 \cdot m\right) - n\right) + t\_0}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(0.5 \cdot n - M\right) \cdot \left(\left(M - 0.5 \cdot n\right) - m\right) + t\_0}\\
\end{array}
\end{array}
if m < -4.00000000000000023e84Initial program 69.4%
Taylor expanded in n around 0 59.2%
+-commutative59.2%
unpow259.2%
distribute-rgt-out67.4%
*-commutative67.4%
*-commutative67.4%
Simplified67.4%
Taylor expanded in K around 0 75.5%
cos-neg75.5%
associate-*r*75.5%
sin-neg75.5%
Simplified75.5%
Taylor expanded in M around 0 98.0%
if -4.00000000000000023e84 < m Initial program 81.4%
Taylor expanded in m around inf 89.6%
*-commutative89.6%
associate-*l*89.6%
Simplified89.6%
Taylor expanded in K around 0 95.7%
Taylor expanded in m around 0 78.0%
+-commutative78.0%
unpow278.0%
distribute-rgt-out83.8%
*-commutative83.8%
*-commutative83.8%
Simplified83.8%
Final simplification86.5%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* 0.5 m))))
(if (<= l 0.000112)
(exp (+ (* (- n t_0) t_0) (- (fabs (- m n)) l)))
(* (cos M) (exp (- l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = M - (0.5 * m);
double tmp;
if (l <= 0.000112) {
tmp = exp((((n - t_0) * t_0) + (fabs((m - n)) - l)));
} else {
tmp = cos(M) * 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) :: t_0
real(8) :: tmp
t_0 = m_1 - (0.5d0 * m)
if (l <= 0.000112d0) then
tmp = exp((((n - t_0) * t_0) + (abs((m - n)) - l)))
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = M - (0.5 * m);
double tmp;
if (l <= 0.000112) {
tmp = Math.exp((((n - t_0) * t_0) + (Math.abs((m - n)) - l)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): t_0 = M - (0.5 * m) tmp = 0 if l <= 0.000112: tmp = math.exp((((n - t_0) * t_0) + (math.fabs((m - n)) - l))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) t_0 = Float64(M - Float64(0.5 * m)) tmp = 0.0 if (l <= 0.000112) tmp = exp(Float64(Float64(Float64(n - t_0) * t_0) + Float64(abs(Float64(m - n)) - l))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = M - (0.5 * m); tmp = 0.0; if (l <= 0.000112) tmp = exp((((n - t_0) * t_0) + (abs((m - n)) - l))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M - N[(0.5 * m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 0.000112], N[Exp[N[(N[(N[(n - t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M - 0.5 \cdot m\\
\mathbf{if}\;\ell \leq 0.000112:\\
\;\;\;\;e^{\left(n - t\_0\right) \cdot t\_0 + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 1.11999999999999998e-4Initial program 78.8%
Taylor expanded in n around 0 60.9%
+-commutative60.9%
unpow260.9%
distribute-rgt-out66.2%
*-commutative66.2%
*-commutative66.2%
Simplified66.2%
Taylor expanded in K around 0 68.2%
cos-neg68.2%
associate-*r*68.2%
sin-neg68.2%
Simplified68.2%
Taylor expanded in M around 0 78.4%
if 1.11999999999999998e-4 < l Initial program 79.7%
Taylor expanded in n around 0 68.2%
+-commutative68.2%
unpow268.2%
distribute-rgt-out71.2%
*-commutative71.2%
*-commutative71.2%
Simplified71.2%
Taylor expanded in l around inf 79.7%
mul-1-neg79.7%
Simplified79.7%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
*-commutative98.6%
Simplified98.6%
Final simplification83.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- l))))
(if (<= l -6.4e-34)
(* t_0 (cos (- (/ 1.0 (/ 2.0 (* (+ m n) K))) M)))
(* 0.5 (* K (* m (* t_0 (sin M))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-l);
double tmp;
if (l <= -6.4e-34) {
tmp = t_0 * cos(((1.0 / (2.0 / ((m + n) * K))) - M));
} else {
tmp = 0.5 * (K * (m * (t_0 * sin(M))));
}
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(-l)
if (l <= (-6.4d-34)) then
tmp = t_0 * cos(((1.0d0 / (2.0d0 / ((m + n) * k))) - m_1))
else
tmp = 0.5d0 * (k * (m * (t_0 * sin(m_1))))
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(-l);
double tmp;
if (l <= -6.4e-34) {
tmp = t_0 * Math.cos(((1.0 / (2.0 / ((m + n) * K))) - M));
} else {
tmp = 0.5 * (K * (m * (t_0 * Math.sin(M))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-l) tmp = 0 if l <= -6.4e-34: tmp = t_0 * math.cos(((1.0 / (2.0 / ((m + n) * K))) - M)) else: tmp = 0.5 * (K * (m * (t_0 * math.sin(M)))) return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-l)) tmp = 0.0 if (l <= -6.4e-34) tmp = Float64(t_0 * cos(Float64(Float64(1.0 / Float64(2.0 / Float64(Float64(m + n) * K))) - M))); else tmp = Float64(0.5 * Float64(K * Float64(m * Float64(t_0 * sin(M))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-l); tmp = 0.0; if (l <= -6.4e-34) tmp = t_0 * cos(((1.0 / (2.0 / ((m + n) * K))) - M)); else tmp = 0.5 * (K * (m * (t_0 * sin(M)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, If[LessEqual[l, -6.4e-34], N[(t$95$0 * N[Cos[N[(N[(1.0 / N[(2.0 / N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(K * N[(m * N[(t$95$0 * N[Sin[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;\ell \leq -6.4 \cdot 10^{-34}:\\
\;\;\;\;t\_0 \cdot \cos \left(\frac{1}{\frac{2}{\left(m + n\right) \cdot K}} - M\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(K \cdot \left(m \cdot \left(t\_0 \cdot \sin M\right)\right)\right)\\
\end{array}
\end{array}
if l < -6.40000000000000005e-34Initial program 73.0%
Taylor expanded in n around 0 60.4%
+-commutative60.4%
unpow260.4%
distribute-rgt-out68.3%
*-commutative68.3%
*-commutative68.3%
Simplified68.3%
Taylor expanded in l around inf 16.8%
mul-1-neg16.8%
Simplified16.8%
clear-num18.4%
inv-pow18.4%
*-commutative18.4%
Applied egg-rr18.4%
unpow-118.4%
Simplified18.4%
if -6.40000000000000005e-34 < l Initial program 81.1%
Taylor expanded in n around 0 63.6%
+-commutative63.6%
unpow263.6%
distribute-rgt-out67.3%
*-commutative67.3%
*-commutative67.3%
Simplified67.3%
Taylor expanded in K around 0 70.3%
cos-neg70.3%
associate-*r*70.3%
sin-neg70.3%
Simplified70.3%
Taylor expanded in m around inf 75.1%
Taylor expanded in l around inf 48.0%
neg-mul-148.0%
Simplified48.0%
Final simplification40.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- l))))
(if (<= l -5e-34)
(* t_0 (cos (* (* 0.5 n) K)))
(* 0.5 (* K (* m (* t_0 (sin M))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-l);
double tmp;
if (l <= -5e-34) {
tmp = t_0 * cos(((0.5 * n) * K));
} else {
tmp = 0.5 * (K * (m * (t_0 * sin(M))));
}
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(-l)
if (l <= (-5d-34)) then
tmp = t_0 * cos(((0.5d0 * n) * k))
else
tmp = 0.5d0 * (k * (m * (t_0 * sin(m_1))))
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(-l);
double tmp;
if (l <= -5e-34) {
tmp = t_0 * Math.cos(((0.5 * n) * K));
} else {
tmp = 0.5 * (K * (m * (t_0 * Math.sin(M))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-l) tmp = 0 if l <= -5e-34: tmp = t_0 * math.cos(((0.5 * n) * K)) else: tmp = 0.5 * (K * (m * (t_0 * math.sin(M)))) return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-l)) tmp = 0.0 if (l <= -5e-34) tmp = Float64(t_0 * cos(Float64(Float64(0.5 * n) * K))); else tmp = Float64(0.5 * Float64(K * Float64(m * Float64(t_0 * sin(M))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-l); tmp = 0.0; if (l <= -5e-34) tmp = t_0 * cos(((0.5 * n) * K)); else tmp = 0.5 * (K * (m * (t_0 * sin(M)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, If[LessEqual[l, -5e-34], N[(t$95$0 * N[Cos[N[(N[(0.5 * n), $MachinePrecision] * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(K * N[(m * N[(t$95$0 * N[Sin[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-34}:\\
\;\;\;\;t\_0 \cdot \cos \left(\left(0.5 \cdot n\right) \cdot K\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(K \cdot \left(m \cdot \left(t\_0 \cdot \sin M\right)\right)\right)\\
\end{array}
\end{array}
if l < -5.0000000000000003e-34Initial program 73.0%
Taylor expanded in n around 0 60.4%
+-commutative60.4%
unpow260.4%
distribute-rgt-out68.3%
*-commutative68.3%
*-commutative68.3%
Simplified68.3%
Taylor expanded in l around inf 16.8%
mul-1-neg16.8%
Simplified16.8%
Taylor expanded in n around inf 18.7%
*-commutative18.7%
associate-*l*18.7%
Simplified18.7%
if -5.0000000000000003e-34 < l Initial program 81.1%
Taylor expanded in n around 0 63.6%
+-commutative63.6%
unpow263.6%
distribute-rgt-out67.3%
*-commutative67.3%
*-commutative67.3%
Simplified67.3%
Taylor expanded in K around 0 70.3%
cos-neg70.3%
associate-*r*70.3%
sin-neg70.3%
Simplified70.3%
Taylor expanded in m around inf 75.1%
Taylor expanded in l around inf 48.0%
neg-mul-148.0%
Simplified48.0%
Final simplification40.8%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * 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 = cos(m_1) * exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(-l);
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(-l)
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 79.1%
Taylor expanded in n around 0 62.8%
+-commutative62.8%
unpow262.8%
distribute-rgt-out67.5%
*-commutative67.5%
*-commutative67.5%
Simplified67.5%
Taylor expanded in l around inf 29.7%
mul-1-neg29.7%
Simplified29.7%
Taylor expanded in K around 0 33.8%
cos-neg33.8%
*-commutative33.8%
Simplified33.8%
Final simplification33.8%
(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 79.1%
Taylor expanded in n around 0 62.8%
+-commutative62.8%
unpow262.8%
distribute-rgt-out67.5%
*-commutative67.5%
*-commutative67.5%
Simplified67.5%
Taylor expanded in l around inf 29.7%
mul-1-neg29.7%
Simplified29.7%
Taylor expanded in l around 0 6.1%
Taylor expanded in K around 0 6.5%
cos-neg6.5%
Simplified6.5%
herbie shell --seed 2024107
(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)))))))