
(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 13 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 n) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * 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 = cos(m_1) * 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.cos(M) * 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.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * 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 = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 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[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 76.2%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Final simplification96.4%
(FPCore (K m n M l)
:precision binary64
(if (<= n 72.0)
(*
(cos M)
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- (fabs (- m n)) l))))
(* (cos M) (exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 72.0) {
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (fabs((m - n)) - l)));
} else {
tmp = cos(M) * 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 (n <= 72.0d0) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (abs((m - n)) - l)))
else
tmp = cos(m_1) * 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 (n <= 72.0) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (Math.abs((m - n)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 72.0: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (math.fabs((m - n)) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 72.0) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(abs(Float64(m - n)) - l)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 72.0) tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (abs((m - n)) - l))); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 72.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 72:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 72Initial program 78.8%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in n around 0 82.0%
+-commutative82.0%
unpow282.0%
distribute-rgt-out84.6%
*-commutative84.6%
*-commutative84.6%
Simplified84.6%
if 72 < n Initial program 68.3%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in n around inf 95.3%
Final simplification87.2%
(FPCore (K m n M l) :precision binary64 (if (<= n 3.8e+50) (* (cos M) (exp (- (* (- (* m 0.5) M) (- M (* m 0.5))) l))) (* (cos M) (exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 3.8e+50) {
tmp = cos(M) * exp(((((m * 0.5) - M) * (M - (m * 0.5))) - l));
} else {
tmp = cos(M) * 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 (n <= 3.8d+50) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * (m_1 - (m * 0.5d0))) - l))
else
tmp = cos(m_1) * 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 (n <= 3.8e+50) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * (M - (m * 0.5))) - l));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 3.8e+50: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * (M - (m * 0.5))) - l)) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 3.8e+50) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(M - Float64(m * 0.5))) - l))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 3.8e+50) tmp = cos(M) * exp(((((m * 0.5) - M) * (M - (m * 0.5))) - l)); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 3.8e+50], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.8 \cdot 10^{+50}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(M - m \cdot 0.5\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 3.79999999999999987e50Initial program 78.5%
Taylor expanded in K around 0 96.0%
cos-neg96.0%
Simplified96.0%
Taylor expanded in n around 0 81.0%
+-commutative81.0%
unpow281.0%
distribute-rgt-out83.9%
*-commutative83.9%
*-commutative83.9%
Simplified83.9%
Taylor expanded in l around inf 85.7%
Taylor expanded in n around 0 87.7%
if 3.79999999999999987e50 < n Initial program 67.3%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in n around inf 98.1%
Final simplification89.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* m 0.5))) (t_1 (- (* m 0.5) M)))
(if (<= M -1.55e-222)
(exp (- (* t_1 (- t_0 n)) l))
(if (<= M 0.00095)
(* (cos M) (exp (- (* (* m 0.5) t_0) l)))
(* (cos M) (exp (- (* M t_1) l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = M - (m * 0.5);
double t_1 = (m * 0.5) - M;
double tmp;
if (M <= -1.55e-222) {
tmp = exp(((t_1 * (t_0 - n)) - l));
} else if (M <= 0.00095) {
tmp = cos(M) * exp((((m * 0.5) * t_0) - l));
} else {
tmp = cos(M) * exp(((M * t_1) - 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) :: t_1
real(8) :: tmp
t_0 = m_1 - (m * 0.5d0)
t_1 = (m * 0.5d0) - m_1
if (m_1 <= (-1.55d-222)) then
tmp = exp(((t_1 * (t_0 - n)) - l))
else if (m_1 <= 0.00095d0) then
tmp = cos(m_1) * exp((((m * 0.5d0) * t_0) - l))
else
tmp = cos(m_1) * exp(((m_1 * t_1) - 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 - (m * 0.5);
double t_1 = (m * 0.5) - M;
double tmp;
if (M <= -1.55e-222) {
tmp = Math.exp(((t_1 * (t_0 - n)) - l));
} else if (M <= 0.00095) {
tmp = Math.cos(M) * Math.exp((((m * 0.5) * t_0) - l));
} else {
tmp = Math.cos(M) * Math.exp(((M * t_1) - l));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = M - (m * 0.5) t_1 = (m * 0.5) - M tmp = 0 if M <= -1.55e-222: tmp = math.exp(((t_1 * (t_0 - n)) - l)) elif M <= 0.00095: tmp = math.cos(M) * math.exp((((m * 0.5) * t_0) - l)) else: tmp = math.cos(M) * math.exp(((M * t_1) - l)) return tmp
function code(K, m, n, M, l) t_0 = Float64(M - Float64(m * 0.5)) t_1 = Float64(Float64(m * 0.5) - M) tmp = 0.0 if (M <= -1.55e-222) tmp = exp(Float64(Float64(t_1 * Float64(t_0 - n)) - l)); elseif (M <= 0.00095) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(m * 0.5) * t_0) - l))); else tmp = Float64(cos(M) * exp(Float64(Float64(M * t_1) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = M - (m * 0.5); t_1 = (m * 0.5) - M; tmp = 0.0; if (M <= -1.55e-222) tmp = exp(((t_1 * (t_0 - n)) - l)); elseif (M <= 0.00095) tmp = cos(M) * exp((((m * 0.5) * t_0) - l)); else tmp = cos(M) * exp(((M * t_1) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[M, -1.55e-222], N[Exp[N[(N[(t$95$1 * N[(t$95$0 - n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision], If[LessEqual[M, 0.00095], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * t$95$1), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M - m \cdot 0.5\\
t_1 := m \cdot 0.5 - M\\
\mathbf{if}\;M \leq -1.55 \cdot 10^{-222}:\\
\;\;\;\;e^{t\_1 \cdot \left(t\_0 - n\right) - \ell}\\
\mathbf{elif}\;M \leq 0.00095:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5\right) \cdot t\_0 - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot t\_1 - \ell}\\
\end{array}
\end{array}
if M < -1.5499999999999999e-222Initial program 76.8%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Taylor expanded in n around 0 73.3%
+-commutative73.3%
unpow273.3%
distribute-rgt-out77.0%
*-commutative77.0%
*-commutative77.0%
Simplified77.0%
Taylor expanded in l around inf 82.1%
Taylor expanded in M around 0 82.0%
if -1.5499999999999999e-222 < M < 9.49999999999999998e-4Initial program 70.8%
Taylor expanded in K around 0 92.5%
cos-neg92.5%
Simplified92.5%
Taylor expanded in n around 0 62.7%
+-commutative62.7%
unpow262.7%
distribute-rgt-out65.5%
*-commutative65.5%
*-commutative65.5%
Simplified65.5%
Taylor expanded in l around inf 71.0%
Taylor expanded in m around inf 72.4%
if 9.49999999999999998e-4 < M Initial program 80.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 80.9%
+-commutative80.9%
unpow280.9%
distribute-rgt-out96.0%
*-commutative96.0%
*-commutative96.0%
Simplified96.0%
Taylor expanded in l around inf 96.0%
Taylor expanded in M around inf 85.2%
neg-mul-185.2%
Simplified85.2%
Final simplification80.2%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* m 0.5))) (t_1 (- (* m 0.5) M)))
(if (<= m -2.6e-197)
(* (cos M) (exp (- (* t_1 t_0) l)))
(exp (- (* t_1 (- t_0 n)) l)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = M - (m * 0.5);
double t_1 = (m * 0.5) - M;
double tmp;
if (m <= -2.6e-197) {
tmp = cos(M) * exp(((t_1 * t_0) - l));
} else {
tmp = exp(((t_1 * (t_0 - 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = m_1 - (m * 0.5d0)
t_1 = (m * 0.5d0) - m_1
if (m <= (-2.6d-197)) then
tmp = cos(m_1) * exp(((t_1 * t_0) - l))
else
tmp = exp(((t_1 * (t_0 - n)) - 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 - (m * 0.5);
double t_1 = (m * 0.5) - M;
double tmp;
if (m <= -2.6e-197) {
tmp = Math.cos(M) * Math.exp(((t_1 * t_0) - l));
} else {
tmp = Math.exp(((t_1 * (t_0 - n)) - l));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = M - (m * 0.5) t_1 = (m * 0.5) - M tmp = 0 if m <= -2.6e-197: tmp = math.cos(M) * math.exp(((t_1 * t_0) - l)) else: tmp = math.exp(((t_1 * (t_0 - n)) - l)) return tmp
function code(K, m, n, M, l) t_0 = Float64(M - Float64(m * 0.5)) t_1 = Float64(Float64(m * 0.5) - M) tmp = 0.0 if (m <= -2.6e-197) tmp = Float64(cos(M) * exp(Float64(Float64(t_1 * t_0) - l))); else tmp = exp(Float64(Float64(t_1 * Float64(t_0 - n)) - l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = M - (m * 0.5); t_1 = (m * 0.5) - M; tmp = 0.0; if (m <= -2.6e-197) tmp = cos(M) * exp(((t_1 * t_0) - l)); else tmp = exp(((t_1 * (t_0 - n)) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[m, -2.6e-197], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(t$95$1 * t$95$0), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(t$95$1 * N[(t$95$0 - n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M - m \cdot 0.5\\
t_1 := m \cdot 0.5 - M\\
\mathbf{if}\;m \leq -2.6 \cdot 10^{-197}:\\
\;\;\;\;\cos M \cdot e^{t\_1 \cdot t\_0 - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_1 \cdot \left(t\_0 - n\right) - \ell}\\
\end{array}
\end{array}
if m < -2.6000000000000001e-197Initial program 77.6%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in n around 0 72.5%
+-commutative72.5%
unpow272.5%
distribute-rgt-out79.6%
*-commutative79.6%
*-commutative79.6%
Simplified79.6%
Taylor expanded in l around inf 81.0%
Taylor expanded in n around 0 84.5%
if -2.6000000000000001e-197 < m Initial program 75.1%
Taylor expanded in K around 0 96.1%
cos-neg96.1%
Simplified96.1%
Taylor expanded in n around 0 72.4%
+-commutative72.4%
unpow272.4%
distribute-rgt-out78.8%
*-commutative78.8%
*-commutative78.8%
Simplified78.8%
Taylor expanded in l around inf 84.4%
Taylor expanded in M around 0 84.4%
Final simplification84.5%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (* m 0.5) M)))
(if (<= M 1.1e-49)
(exp (- (* t_0 (- (- M (* m 0.5)) n)) l))
(* (cos M) (exp (- (* M t_0) l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m * 0.5) - M;
double tmp;
if (M <= 1.1e-49) {
tmp = exp(((t_0 * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = cos(M) * exp(((M * t_0) - 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 * 0.5d0) - m_1
if (m_1 <= 1.1d-49) then
tmp = exp(((t_0 * ((m_1 - (m * 0.5d0)) - n)) - l))
else
tmp = cos(m_1) * exp(((m_1 * t_0) - 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 (M <= 1.1e-49) {
tmp = Math.exp(((t_0 * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = Math.cos(M) * Math.exp(((M * t_0) - l));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (m * 0.5) - M tmp = 0 if M <= 1.1e-49: tmp = math.exp(((t_0 * ((M - (m * 0.5)) - n)) - l)) else: tmp = math.cos(M) * math.exp(((M * t_0) - l)) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(m * 0.5) - M) tmp = 0.0 if (M <= 1.1e-49) tmp = exp(Float64(Float64(t_0 * Float64(Float64(M - Float64(m * 0.5)) - n)) - l)); else tmp = Float64(cos(M) * exp(Float64(Float64(M * t_0) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (m * 0.5) - M; tmp = 0.0; if (M <= 1.1e-49) tmp = exp(((t_0 * ((M - (m * 0.5)) - n)) - l)); else tmp = cos(M) * exp(((M * t_0) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[M, 1.1e-49], N[Exp[N[(N[(t$95$0 * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * t$95$0), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := m \cdot 0.5 - M\\
\mathbf{if}\;M \leq 1.1 \cdot 10^{-49}:\\
\;\;\;\;e^{t\_0 \cdot \left(\left(M - m \cdot 0.5\right) - n\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot t\_0 - \ell}\\
\end{array}
\end{array}
if M < 1.09999999999999995e-49Initial program 76.1%
Taylor expanded in K around 0 95.2%
cos-neg95.2%
Simplified95.2%
Taylor expanded in n around 0 69.2%
+-commutative69.2%
unpow269.2%
distribute-rgt-out72.2%
*-commutative72.2%
*-commutative72.2%
Simplified72.2%
Taylor expanded in l around inf 76.7%
Taylor expanded in M around 0 76.6%
if 1.09999999999999995e-49 < M Initial program 76.5%
Taylor expanded in K around 0 98.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in n around 0 78.9%
+-commutative78.9%
unpow278.9%
distribute-rgt-out93.1%
*-commutative93.1%
*-commutative93.1%
Simplified93.1%
Taylor expanded in l around inf 95.4%
Taylor expanded in M around inf 76.9%
neg-mul-176.9%
Simplified76.9%
Final simplification76.7%
(FPCore (K m n M l) :precision binary64 (if (<= l 740.0) (exp (- (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) l)) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 740.0) {
tmp = exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - 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) :: tmp
if (l <= 740.0d0) then
tmp = exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - 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 tmp;
if (l <= 740.0) {
tmp = Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 740.0: tmp = math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 740.0) tmp = exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) - l)); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 740.0) tmp = exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 740.0], N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 740:\\
\;\;\;\;e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 740Initial program 74.9%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
Taylor expanded in n around 0 68.4%
+-commutative68.4%
unpow268.4%
distribute-rgt-out75.1%
*-commutative75.1%
*-commutative75.1%
Simplified75.1%
Taylor expanded in l around inf 79.0%
Taylor expanded in M around 0 78.0%
if 740 < l Initial program 80.3%
Taylor expanded in l around inf 80.3%
mul-1-neg80.3%
Simplified80.3%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Final simplification83.2%
(FPCore (K m n M l) :precision binary64 (if (<= M 1.45e-19) (exp (- (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) l)) (exp (- (pow M 2.0)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (M <= 1.45e-19) {
tmp = exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = exp(-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 <= 1.45d-19) then
tmp = exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) - l))
else
tmp = exp(-(m_1 ** 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 <= 1.45e-19) {
tmp = Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = Math.exp(-Math.pow(M, 2.0));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if M <= 1.45e-19: tmp = math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)) else: tmp = math.exp(-math.pow(M, 2.0)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (M <= 1.45e-19) tmp = exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) - l)); else tmp = exp(Float64(-(M ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (M <= 1.45e-19) tmp = exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)); else tmp = exp(-(M ^ 2.0)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[M, 1.45e-19], N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.45 \cdot 10^{-19}:\\
\;\;\;\;e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-{M}^{2}}\\
\end{array}
\end{array}
if M < 1.45e-19Initial program 74.7%
Taylor expanded in K around 0 95.0%
cos-neg95.0%
Simplified95.0%
Taylor expanded in n around 0 68.8%
+-commutative68.8%
unpow268.8%
distribute-rgt-out72.1%
*-commutative72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in l around inf 77.4%
Taylor expanded in M around 0 77.4%
if 1.45e-19 < M Initial program 80.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 90.9%
mul-1-neg90.9%
Simplified90.9%
Taylor expanded in M around 0 90.9%
Final simplification81.3%
(FPCore (K m n M l) :precision binary64 (exp (- (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) l)))
double code(double K, double m, double n, double M, double l) {
return exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - 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(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) - l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
}
def code(K, m, n, M, l): return math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l))
function code(K, m, n, M, l) return exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) - l)) end
function tmp = code(K, m, n, M, l) tmp = exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) - \ell}
\end{array}
Initial program 76.2%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in n around 0 72.5%
+-commutative72.5%
unpow272.5%
distribute-rgt-out79.1%
*-commutative79.1%
*-commutative79.1%
Simplified79.1%
Taylor expanded in l around inf 82.9%
Taylor expanded in M around 0 82.1%
Final simplification82.1%
(FPCore (K m n M l) :precision binary64 (if (<= M -5e-222) (exp (* n (- M (* m 0.5)))) (exp (* -0.5 (* m n)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (M <= -5e-222) {
tmp = exp((n * (M - (m * 0.5))));
} else {
tmp = exp((-0.5 * (m * n)));
}
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 <= (-5d-222)) then
tmp = exp((n * (m_1 - (m * 0.5d0))))
else
tmp = exp(((-0.5d0) * (m * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (M <= -5e-222) {
tmp = Math.exp((n * (M - (m * 0.5))));
} else {
tmp = Math.exp((-0.5 * (m * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if M <= -5e-222: tmp = math.exp((n * (M - (m * 0.5)))) else: tmp = math.exp((-0.5 * (m * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (M <= -5e-222) tmp = exp(Float64(n * Float64(M - Float64(m * 0.5)))); else tmp = exp(Float64(-0.5 * Float64(m * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (M <= -5e-222) tmp = exp((n * (M - (m * 0.5)))); else tmp = exp((-0.5 * (m * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[M, -5e-222], N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.5 * N[(m * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -5 \cdot 10^{-222}:\\
\;\;\;\;e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.5 \cdot \left(m \cdot n\right)}\\
\end{array}
\end{array}
if M < -5.00000000000000008e-222Initial program 76.8%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Taylor expanded in n around 0 73.3%
+-commutative73.3%
unpow273.3%
distribute-rgt-out77.0%
*-commutative77.0%
*-commutative77.0%
Simplified77.0%
Taylor expanded in n around inf 45.6%
Taylor expanded in M around 0 45.6%
if -5.00000000000000008e-222 < M Initial program 75.8%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Taylor expanded in n around 0 71.8%
+-commutative71.8%
unpow271.8%
distribute-rgt-out80.7%
*-commutative80.7%
*-commutative80.7%
Simplified80.7%
Taylor expanded in n around inf 43.3%
Taylor expanded in M around 0 34.1%
Final simplification39.1%
(FPCore (K m n M l) :precision binary64 (exp (* -0.5 (* m n))))
double code(double K, double m, double n, double M, double l) {
return exp((-0.5 * (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 = exp(((-0.5d0) * (m * n)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((-0.5 * (m * n)));
}
def code(K, m, n, M, l): return math.exp((-0.5 * (m * n)))
function code(K, m, n, M, l) return exp(Float64(-0.5 * Float64(m * n))) end
function tmp = code(K, m, n, M, l) tmp = exp((-0.5 * (m * n))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(-0.5 * N[(m * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{-0.5 \cdot \left(m \cdot n\right)}
\end{array}
Initial program 76.2%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in n around 0 72.5%
+-commutative72.5%
unpow272.5%
distribute-rgt-out79.1%
*-commutative79.1%
*-commutative79.1%
Simplified79.1%
Taylor expanded in n around inf 44.3%
Taylor expanded in M around 0 34.6%
(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 76.2%
Taylor expanded in l around inf 28.1%
mul-1-neg28.1%
Simplified28.1%
Taylor expanded in l around 0 6.8%
*-commutative6.8%
*-commutative6.8%
associate-*r*6.8%
*-lft-identity6.8%
*-lft-identity6.8%
*-commutative6.8%
Simplified6.8%
Taylor expanded in K around 0 7.3%
cos-neg7.3%
Simplified7.3%
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
return 1.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 = 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
def code(K, m, n, M, l): return 1.0
function code(K, m, n, M, l) return 1.0 end
function tmp = code(K, m, n, M, l) tmp = 1.0; end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 76.2%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in M around inf 53.1%
mul-1-neg53.1%
Simplified53.1%
Taylor expanded in M around 0 7.3%
herbie shell --seed 2024150
(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)))))))