
(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 9 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.1%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Final simplification98.1%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -340000000000.0) (not (<= M 4.8e+67))) (* (cos M) (exp (- (pow M 2.0)))) (exp (- (- (fabs (- m n)) l) (* 0.25 (pow (+ m n) 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -340000000000.0) || !(M <= 4.8e+67)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = exp(((fabs((m - n)) - l) - (0.25 * pow((m + n), 2.0))));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((m_1 <= (-340000000000.0d0)) .or. (.not. (m_1 <= 4.8d+67))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp(((abs((m - n)) - l) - (0.25d0 * ((m + n) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -340000000000.0) || !(M <= 4.8e+67)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp(((Math.abs((m - n)) - l) - (0.25 * Math.pow((m + n), 2.0))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -340000000000.0) or not (M <= 4.8e+67): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp(((math.fabs((m - n)) - l) - (0.25 * math.pow((m + n), 2.0)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -340000000000.0) || !(M <= 4.8e+67)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(0.25 * (Float64(m + n) ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -340000000000.0) || ~((M <= 4.8e+67))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = exp(((abs((m - n)) - l) - (0.25 * ((m + n) ^ 2.0)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -340000000000.0], N[Not[LessEqual[M, 4.8e+67]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -340000000000 \lor \neg \left(M \leq 4.8 \cdot 10^{+67}\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\left|m - n\right| - \ell\right) - 0.25 \cdot {\left(m + n\right)}^{2}}\\
\end{array}
\end{array}
if M < -3.4e11 or 4.80000000000000004e67 < M Initial program 84.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 98.2%
mul-1-neg98.2%
Simplified98.2%
if -3.4e11 < M < 4.80000000000000004e67Initial program 72.8%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Taylor expanded in M around 0 94.7%
fabs-sub94.7%
associate--r+94.7%
Simplified94.7%
Final simplification96.2%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -27.0) (not (<= M 27.0))) (* (cos M) (exp (- (pow M 2.0)))) (exp (- (- n m) (* 0.25 (* (+ m n) (+ m n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -27.0) || !(M <= 27.0)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = exp(((n - m) - (0.25 * ((m + n) * (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 <= (-27.0d0)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp(((n - m) - (0.25d0 * ((m + n) * (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 <= -27.0) || !(M <= 27.0)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp(((n - m) - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -27.0) or not (M <= 27.0): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp(((n - m) - (0.25 * ((m + n) * (m + n))))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -27.0) || !(M <= 27.0)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(Float64(n - m) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -27.0) || ~((M <= 27.0))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = exp(((n - m) - (0.25 * ((m + n) * (m + n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -27.0], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(n - m), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -27 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n - m\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\end{array}
\end{array}
if M < -27 or 27 < M Initial program 81.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 96.3%
mul-1-neg96.3%
Simplified96.3%
if -27 < M < 27Initial program 74.1%
Taylor expanded in K around 0 96.1%
cos-neg96.1%
Simplified96.1%
Taylor expanded in M around 0 96.1%
fabs-sub96.1%
associate--r+96.1%
Simplified96.1%
Taylor expanded in l around 0 82.0%
rem-square-sqrt39.1%
fabs-sqr39.1%
rem-square-sqrt81.5%
Simplified81.5%
unpow281.5%
+-commutative81.5%
+-commutative81.5%
Applied egg-rr81.5%
Final simplification89.1%
(FPCore (K m n M l) :precision binary64 (if (<= l 700.0) (exp (- (- n m) (* 0.25 (* (+ m n) (+ m n))))) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 700.0) {
tmp = exp(((n - m) - (0.25 * ((m + n) * (m + n)))));
} 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 <= 700.0d0) then
tmp = exp(((n - m) - (0.25d0 * ((m + n) * (m + n)))))
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 <= 700.0) {
tmp = Math.exp(((n - m) - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 700.0: tmp = math.exp(((n - m) - (0.25 * ((m + n) * (m + n))))) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 700.0) tmp = exp(Float64(Float64(n - m) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 700.0) tmp = exp(((n - m) - (0.25 * ((m + n) * (m + n))))); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 700.0], N[Exp[N[(N[(n - m), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 700:\\
\;\;\;\;e^{\left(n - m\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if l < 700Initial program 78.4%
Taylor expanded in K around 0 97.8%
cos-neg97.8%
Simplified97.8%
Taylor expanded in M around 0 81.7%
fabs-sub81.7%
associate--r+81.7%
Simplified81.7%
Taylor expanded in l around 0 75.9%
rem-square-sqrt37.5%
fabs-sqr37.5%
rem-square-sqrt75.6%
Simplified75.6%
unpow275.6%
+-commutative75.6%
+-commutative75.6%
Applied egg-rr75.6%
if 700 < l Initial program 76.7%
Taylor expanded in l around inf 76.7%
mul-1-neg76.7%
Simplified76.7%
clear-num76.7%
inv-pow76.7%
*-commutative76.7%
Applied egg-rr76.7%
unpow-176.7%
Simplified76.7%
exp-neg76.7%
Applied egg-rr76.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Final simplification79.7%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -8e-113) (not (<= n 300000.0))) (exp (- (- n m) (* 0.25 (* n (+ n (* m 2.0)))))) (* (cos (- M)) (+ 1.0 (* l (+ (* l 0.5) -1.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -8e-113) || !(n <= 300000.0)) {
tmp = exp(((n - m) - (0.25 * (n * (n + (m * 2.0))))));
} else {
tmp = cos(-M) * (1.0 + (l * ((l * 0.5) + -1.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 <= (-8d-113)) .or. (.not. (n <= 300000.0d0))) then
tmp = exp(((n - m) - (0.25d0 * (n * (n + (m * 2.0d0))))))
else
tmp = cos(-m_1) * (1.0d0 + (l * ((l * 0.5d0) + (-1.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 <= -8e-113) || !(n <= 300000.0)) {
tmp = Math.exp(((n - m) - (0.25 * (n * (n + (m * 2.0))))));
} else {
tmp = Math.cos(-M) * (1.0 + (l * ((l * 0.5) + -1.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -8e-113) or not (n <= 300000.0): tmp = math.exp(((n - m) - (0.25 * (n * (n + (m * 2.0)))))) else: tmp = math.cos(-M) * (1.0 + (l * ((l * 0.5) + -1.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -8e-113) || !(n <= 300000.0)) tmp = exp(Float64(Float64(n - m) - Float64(0.25 * Float64(n * Float64(n + Float64(m * 2.0)))))); else tmp = Float64(cos(Float64(-M)) * Float64(1.0 + Float64(l * Float64(Float64(l * 0.5) + -1.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -8e-113) || ~((n <= 300000.0))) tmp = exp(((n - m) - (0.25 * (n * (n + (m * 2.0)))))); else tmp = cos(-M) * (1.0 + (l * ((l * 0.5) + -1.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -8e-113], N[Not[LessEqual[n, 300000.0]], $MachinePrecision]], N[Exp[N[(N[(n - m), $MachinePrecision] - N[(0.25 * N[(n * N[(n + N[(m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[(-M)], $MachinePrecision] * N[(1.0 + N[(l * N[(N[(l * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8 \cdot 10^{-113} \lor \neg \left(n \leq 300000\right):\\
\;\;\;\;e^{\left(n - m\right) - 0.25 \cdot \left(n \cdot \left(n + m \cdot 2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(-M\right) \cdot \left(1 + \ell \cdot \left(\ell \cdot 0.5 + -1\right)\right)\\
\end{array}
\end{array}
if n < -7.99999999999999983e-113 or 3e5 < n Initial program 73.2%
Taylor expanded in K around 0 99.3%
cos-neg99.3%
Simplified99.3%
Taylor expanded in M around 0 94.5%
fabs-sub94.5%
associate--r+94.5%
Simplified94.5%
Taylor expanded in l around 0 90.4%
rem-square-sqrt40.2%
fabs-sqr40.2%
rem-square-sqrt90.0%
Simplified90.0%
Taylor expanded in m around 0 76.0%
+-commutative76.0%
unpow276.0%
associate-*r*76.0%
distribute-rgt-in79.6%
*-commutative79.6%
Simplified79.6%
if -7.99999999999999983e-113 < n < 3e5Initial program 84.1%
Taylor expanded in l around inf 35.5%
mul-1-neg35.5%
Simplified35.5%
clear-num36.4%
inv-pow36.4%
*-commutative36.4%
Applied egg-rr36.4%
unpow-136.4%
Simplified36.4%
Taylor expanded in l around 0 21.0%
Taylor expanded in K around 0 20.7%
Final simplification53.3%
(FPCore (K m n M l) :precision binary64 (exp (- (- n m) (* 0.25 (* (+ m n) (+ m n))))))
double code(double K, double m, double n, double M, double l) {
return exp(((n - m) - (0.25 * ((m + n) * (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(((n - m) - (0.25d0 * ((m + n) * (m + n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((n - m) - (0.25 * ((m + n) * (m + n)))));
}
def code(K, m, n, M, l): return math.exp(((n - m) - (0.25 * ((m + n) * (m + n)))))
function code(K, m, n, M, l) return exp(Float64(Float64(n - m) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))) end
function tmp = code(K, m, n, M, l) tmp = exp(((n - m) - (0.25 * ((m + n) * (m + n))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(n - m), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(n - m\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}
\end{array}
Initial program 78.1%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in M around 0 84.8%
fabs-sub84.8%
associate--r+84.8%
Simplified84.8%
Taylor expanded in l around 0 76.5%
rem-square-sqrt37.5%
fabs-sqr37.5%
rem-square-sqrt76.3%
Simplified76.3%
unpow276.3%
+-commutative76.3%
+-commutative76.3%
Applied egg-rr76.3%
Final simplification76.3%
(FPCore (K m n M l) :precision binary64 (* (cos (- M)) (+ 1.0 (* l (+ (* l 0.5) -1.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(-M) * (1.0 + (l * ((l * 0.5) + -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 = cos(-m_1) * (1.0d0 + (l * ((l * 0.5d0) + (-1.0d0))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(-M) * (1.0 + (l * ((l * 0.5) + -1.0)));
}
def code(K, m, n, M, l): return math.cos(-M) * (1.0 + (l * ((l * 0.5) + -1.0)))
function code(K, m, n, M, l) return Float64(cos(Float64(-M)) * Float64(1.0 + Float64(l * Float64(Float64(l * 0.5) + -1.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(-M) * (1.0 + (l * ((l * 0.5) + -1.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[(-M)], $MachinePrecision] * N[(1.0 + N[(l * N[(N[(l * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(-M\right) \cdot \left(1 + \ell \cdot \left(\ell \cdot 0.5 + -1\right)\right)
\end{array}
Initial program 78.1%
Taylor expanded in l around inf 26.9%
mul-1-neg26.9%
Simplified26.9%
clear-num27.3%
inv-pow27.3%
*-commutative27.3%
Applied egg-rr27.3%
unpow-127.3%
Simplified27.3%
Taylor expanded in l around 0 13.6%
Taylor expanded in K around 0 14.2%
Final simplification14.2%
(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 78.1%
Taylor expanded in l around inf 26.9%
mul-1-neg26.9%
Simplified26.9%
Taylor expanded in l around 0 8.6%
*-commutative8.6%
*-commutative8.6%
*-commutative8.6%
associate-*r*8.6%
fmm-undef8.6%
fmm-undef8.6%
associate-*r*8.6%
*-commutative8.6%
associate-*l*8.6%
*-commutative8.6%
Simplified8.6%
Taylor expanded in K around 0 9.0%
cos-neg9.0%
Simplified9.0%
(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 78.1%
Taylor expanded in l around inf 26.9%
mul-1-neg26.9%
Simplified26.9%
Taylor expanded in l around 0 8.6%
*-commutative8.6%
*-commutative8.6%
*-commutative8.6%
associate-*r*8.6%
fmm-undef8.6%
fmm-undef8.6%
associate-*r*8.6%
*-commutative8.6%
associate-*l*8.6%
*-commutative8.6%
Simplified8.6%
Taylor expanded in K around 0 9.0%
cos-neg9.0%
Simplified9.0%
Taylor expanded in M around 0 9.0%
herbie shell --seed 2024170
(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)))))))