
(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 8 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 78.8%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (K m n M l)
:precision binary64
(if (<= m -1560.0)
(exp (* -0.25 (pow m 2.0)))
(if (<= m 5.5e-216)
(* (cos M) (exp (- (* M (- m M)) l)))
(* (cos M) (exp (- (* 0.5 (* n (- (* n (- 0.5)) m))) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1560.0) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 5.5e-216) {
tmp = cos(M) * exp(((M * (m - M)) - l));
} else {
tmp = cos(M) * exp(((0.5 * (n * ((n * -0.5) - m))) - 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 <= (-1560.0d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 5.5d-216) then
tmp = cos(m_1) * exp(((m_1 * (m - m_1)) - l))
else
tmp = cos(m_1) * exp(((0.5d0 * (n * ((n * -0.5d0) - m))) - 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 <= -1560.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 5.5e-216) {
tmp = Math.cos(M) * Math.exp(((M * (m - M)) - l));
} else {
tmp = Math.cos(M) * Math.exp(((0.5 * (n * ((n * -0.5) - m))) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1560.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 5.5e-216: tmp = math.cos(M) * math.exp(((M * (m - M)) - l)) else: tmp = math.cos(M) * math.exp(((0.5 * (n * ((n * -0.5) - m))) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1560.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 5.5e-216) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(m - M)) - l))); else tmp = Float64(cos(M) * exp(Float64(Float64(0.5 * Float64(n * Float64(Float64(n * Float64(-0.5)) - m))) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1560.0) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= 5.5e-216) tmp = cos(M) * exp(((M * (m - M)) - l)); else tmp = cos(M) * exp(((0.5 * (n * ((n * -0.5) - m))) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1560.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 5.5e-216], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(0.5 * N[(n * N[(N[(n * (-0.5)), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1560:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 5.5 \cdot 10^{-216}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(m - M\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{0.5 \cdot \left(n \cdot \left(n \cdot \left(-0.5\right) - m\right)\right) - \ell}\\
\end{array}
\end{array}
if m < -1560Initial program 71.0%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in m around inf 98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in M around 0 98.6%
if -1560 < m < 5.49999999999999991e-216Initial program 87.3%
Taylor expanded in m around 0 87.3%
+-commutative87.3%
unpow287.3%
distribute-rgt-out87.3%
*-commutative87.3%
*-commutative87.3%
Simplified87.3%
Taylor expanded in l around inf 87.1%
Taylor expanded in K around 0 96.3%
cos-neg96.5%
Simplified96.3%
Taylor expanded in n around 0 80.7%
mul-1-neg80.7%
mul-1-neg80.7%
unsub-neg80.7%
Simplified80.7%
if 5.49999999999999991e-216 < m Initial program 77.4%
Taylor expanded in m around 0 67.1%
+-commutative67.1%
unpow267.1%
distribute-rgt-out67.1%
*-commutative67.1%
*-commutative67.1%
Simplified67.1%
Taylor expanded in l around inf 68.1%
Taylor expanded in K around 0 82.3%
cos-neg98.1%
Simplified82.3%
Taylor expanded in M around 0 74.1%
*-commutative74.1%
Simplified74.1%
Final simplification82.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* n 0.5))))
(if (<= m -5e+17)
(exp (* -0.25 (pow m 2.0)))
(* (cos M) (exp (- (* (- m t_0) t_0) l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = M - (n * 0.5);
double tmp;
if (m <= -5e+17) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp((((m - t_0) * 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_1 - (n * 0.5d0)
if (m <= (-5d+17)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp((((m - t_0) * 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 - (n * 0.5);
double tmp;
if (m <= -5e+17) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp((((m - t_0) * t_0) - l));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = M - (n * 0.5) tmp = 0 if m <= -5e+17: tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp((((m - t_0) * t_0) - l)) return tmp
function code(K, m, n, M, l) t_0 = Float64(M - Float64(n * 0.5)) tmp = 0.0 if (m <= -5e+17) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(m - t_0) * t_0) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = M - (n * 0.5); tmp = 0.0; if (m <= -5e+17) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp((((m - t_0) * t_0) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -5e+17], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m - t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M - n \cdot 0.5\\
\mathbf{if}\;m \leq -5 \cdot 10^{+17}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - t\_0\right) \cdot t\_0 - \ell}\\
\end{array}
\end{array}
if m < -5e17Initial program 70.6%
Taylor expanded in K around 0 98.5%
cos-neg98.5%
Simplified98.5%
Taylor expanded in m around inf 98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in M around 0 98.6%
if -5e17 < m Initial program 81.8%
Taylor expanded in m around 0 76.0%
+-commutative76.0%
unpow276.0%
distribute-rgt-out76.0%
*-commutative76.0%
*-commutative76.0%
Simplified76.0%
Taylor expanded in l around inf 76.4%
Taylor expanded in K around 0 88.5%
cos-neg97.4%
Simplified88.5%
Final simplification91.1%
(FPCore (K m n M l)
:precision binary64
(if (<= m -2.9)
(exp (* -0.25 (pow m 2.0)))
(if (<= m 8e-179)
(* (cos M) (exp (- l)))
(* (cos M) (exp (* m (- M (* n 0.5))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.9) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 8e-179) {
tmp = cos(M) * exp(-l);
} else {
tmp = cos(M) * exp((m * (M - (n * 0.5))));
}
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 <= (-2.9d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 8d-179) then
tmp = cos(m_1) * exp(-l)
else
tmp = cos(m_1) * exp((m * (m_1 - (n * 0.5d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.9) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 8e-179) {
tmp = Math.cos(M) * Math.exp(-l);
} else {
tmp = Math.cos(M) * Math.exp((m * (M - (n * 0.5))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -2.9: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 8e-179: tmp = math.cos(M) * math.exp(-l) else: tmp = math.cos(M) * math.exp((m * (M - (n * 0.5)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -2.9) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 8e-179) tmp = Float64(cos(M) * exp(Float64(-l))); else tmp = Float64(cos(M) * exp(Float64(m * Float64(M - Float64(n * 0.5))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -2.9) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= 8e-179) tmp = cos(M) * exp(-l); else tmp = cos(M) * exp((m * (M - (n * 0.5)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -2.9], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 8e-179], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.9:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 8 \cdot 10^{-179}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(M - n \cdot 0.5\right)}\\
\end{array}
\end{array}
if m < -2.89999999999999991Initial program 71.0%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in m around inf 98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in M around 0 98.6%
if -2.89999999999999991 < m < 8.0000000000000002e-179Initial program 88.4%
Taylor expanded in K around 0 96.9%
cos-neg96.9%
Simplified96.9%
Taylor expanded in l around inf 48.6%
mul-1-neg45.7%
Simplified48.6%
if 8.0000000000000002e-179 < m Initial program 75.5%
Taylor expanded in m around 0 64.4%
+-commutative64.4%
unpow264.4%
distribute-rgt-out64.5%
*-commutative64.5%
*-commutative64.5%
Simplified64.5%
Taylor expanded in l around inf 65.5%
Taylor expanded in K around 0 80.9%
cos-neg98.0%
Simplified80.9%
Taylor expanded in m around inf 52.0%
*-commutative52.0%
Simplified52.0%
Final simplification63.4%
(FPCore (K m n M l)
:precision binary64
(if (<= m -1560.0)
(exp (* -0.25 (pow m 2.0)))
(if (<= m 1.25e-6)
(* (cos M) (exp (- (* M (- m M)) l)))
(* (cos M) (exp (* m (- M (* n 0.5))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1560.0) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 1.25e-6) {
tmp = cos(M) * exp(((M * (m - M)) - l));
} else {
tmp = cos(M) * exp((m * (M - (n * 0.5))));
}
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 <= (-1560.0d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 1.25d-6) then
tmp = cos(m_1) * exp(((m_1 * (m - m_1)) - l))
else
tmp = cos(m_1) * exp((m * (m_1 - (n * 0.5d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1560.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 1.25e-6) {
tmp = Math.cos(M) * Math.exp(((M * (m - M)) - l));
} else {
tmp = Math.cos(M) * Math.exp((m * (M - (n * 0.5))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1560.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 1.25e-6: tmp = math.cos(M) * math.exp(((M * (m - M)) - l)) else: tmp = math.cos(M) * math.exp((m * (M - (n * 0.5)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1560.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 1.25e-6) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(m - M)) - l))); else tmp = Float64(cos(M) * exp(Float64(m * Float64(M - Float64(n * 0.5))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1560.0) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= 1.25e-6) tmp = cos(M) * exp(((M * (m - M)) - l)); else tmp = cos(M) * exp((m * (M - (n * 0.5)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1560.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 1.25e-6], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1560:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 1.25 \cdot 10^{-6}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(m - M\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(M - n \cdot 0.5\right)}\\
\end{array}
\end{array}
if m < -1560Initial program 71.0%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in m around inf 98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in M around 0 98.6%
if -1560 < m < 1.2500000000000001e-6Initial program 87.9%
Taylor expanded in m around 0 87.9%
+-commutative87.9%
unpow287.9%
distribute-rgt-out87.9%
*-commutative87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in l around inf 87.7%
Taylor expanded in K around 0 96.1%
cos-neg96.2%
Simplified96.1%
Taylor expanded in n around 0 80.6%
mul-1-neg80.6%
mul-1-neg80.6%
unsub-neg80.6%
Simplified80.6%
if 1.2500000000000001e-6 < m Initial program 68.9%
Taylor expanded in m around 0 51.1%
+-commutative51.1%
unpow251.1%
distribute-rgt-out51.1%
*-commutative51.1%
*-commutative51.1%
Simplified51.1%
Taylor expanded in l around inf 52.7%
Taylor expanded in K around 0 72.6%
cos-neg100.0%
Simplified72.6%
Taylor expanded in m around inf 58.1%
*-commutative58.1%
Simplified58.1%
Final simplification80.1%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -2.9) (not (<= m 47.0))) (exp (* -0.25 (pow m 2.0))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -2.9) || !(m <= 47.0)) {
tmp = exp((-0.25 * pow(m, 2.0)));
} 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 <= (-2.9d0)) .or. (.not. (m <= 47.0d0))) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
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 <= -2.9) || !(m <= 47.0)) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -2.9) or not (m <= 47.0): tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -2.9) || !(m <= 47.0)) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -2.9) || ~((m <= 47.0))) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -2.9], N[Not[LessEqual[m, 47.0]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.9 \lor \neg \left(m \leq 47\right):\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if m < -2.89999999999999991 or 47 < m Initial program 69.8%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in m around inf 97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in M around 0 97.8%
if -2.89999999999999991 < m < 47Initial program 87.9%
Taylor expanded in l around inf 45.7%
mul-1-neg45.7%
Simplified45.7%
Taylor expanded in M around 0 44.9%
*-commutative44.9%
associate-*r*44.9%
Simplified44.9%
Taylor expanded in K around 0 47.1%
Final simplification72.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -2.9) (not (<= m 47.0))) (exp (* -0.25 (pow m 2.0))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -2.9) || !(m <= 47.0)) {
tmp = exp((-0.25 * pow(m, 2.0)));
} 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 ((m <= (-2.9d0)) .or. (.not. (m <= 47.0d0))) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
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 ((m <= -2.9) || !(m <= 47.0)) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -2.9) or not (m <= 47.0): tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -2.9) || !(m <= 47.0)) tmp = exp(Float64(-0.25 * (m ^ 2.0))); 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 ((m <= -2.9) || ~((m <= 47.0))) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -2.9], N[Not[LessEqual[m, 47.0]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.9 \lor \neg \left(m \leq 47\right):\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -2.89999999999999991 or 47 < m Initial program 69.8%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in m around inf 97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in M around 0 97.8%
if -2.89999999999999991 < m < 47Initial program 87.9%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Taylor expanded in l around inf 47.9%
mul-1-neg45.7%
Simplified47.9%
Final simplification73.0%
(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 78.8%
Taylor expanded in l around inf 32.0%
mul-1-neg32.0%
Simplified32.0%
Taylor expanded in M around 0 31.2%
*-commutative31.2%
associate-*r*31.2%
Simplified31.2%
Taylor expanded in K around 0 36.5%
Final simplification36.5%
herbie shell --seed 2024031
(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)))))))