
(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 77.6%
*-commutative77.6%
associate-*r/77.6%
associate--r-77.6%
+-commutative77.6%
associate-+r-77.6%
unsub-neg77.6%
associate--r+77.6%
+-commutative77.6%
associate--r+77.6%
Simplified77.6%
Taylor expanded in K around 0 94.6%
cos-neg94.6%
Simplified94.6%
Final simplification94.6%
(FPCore (K m n M l)
:precision binary64
(if (<= m -50.0)
(* (cos M) (exp (* m (* m -0.25))))
(if (<= m 1.95e-179)
(* (cos M) (exp (- (fabs (- m n)) (+ l (* M M)))))
(* (cos M) (exp (* n (* n -0.25)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -50.0) {
tmp = cos(M) * exp((m * (m * -0.25)));
} else if (m <= 1.95e-179) {
tmp = cos(M) * exp((fabs((m - n)) - (l + (M * M))));
} else {
tmp = cos(M) * exp((n * (n * -0.25)));
}
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 <= (-50.0d0)) then
tmp = cos(m_1) * exp((m * (m * (-0.25d0))))
else if (m <= 1.95d-179) then
tmp = cos(m_1) * exp((abs((m - n)) - (l + (m_1 * m_1))))
else
tmp = cos(m_1) * exp((n * (n * (-0.25d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -50.0) {
tmp = Math.cos(M) * Math.exp((m * (m * -0.25)));
} else if (m <= 1.95e-179) {
tmp = Math.cos(M) * Math.exp((Math.abs((m - n)) - (l + (M * M))));
} else {
tmp = Math.cos(M) * Math.exp((n * (n * -0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -50.0: tmp = math.cos(M) * math.exp((m * (m * -0.25))) elif m <= 1.95e-179: tmp = math.cos(M) * math.exp((math.fabs((m - n)) - (l + (M * M)))) else: tmp = math.cos(M) * math.exp((n * (n * -0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -50.0) tmp = Float64(cos(M) * exp(Float64(m * Float64(m * -0.25)))); elseif (m <= 1.95e-179) tmp = Float64(cos(M) * exp(Float64(abs(Float64(m - n)) - Float64(l + Float64(M * M))))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(n * -0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -50.0) tmp = cos(M) * exp((m * (m * -0.25))); elseif (m <= 1.95e-179) tmp = cos(M) * exp((abs((m - n)) - (l + (M * M)))); else tmp = cos(M) * exp((n * (n * -0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -50.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.95e-179], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -50:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 1.95 \cdot 10^{-179}:\\
\;\;\;\;\cos M \cdot e^{\left|m - n\right| - \left(\ell + M \cdot M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if m < -50Initial program 67.5%
*-commutative67.5%
associate-*r/67.5%
associate--r-67.5%
+-commutative67.5%
associate-+r-67.5%
unsub-neg67.5%
associate--r+67.5%
+-commutative67.5%
associate--r+67.5%
Simplified67.5%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in m around inf 95.1%
*-commutative95.1%
unpow295.1%
associate-*l*95.1%
Simplified95.1%
if -50 < m < 1.9500000000000001e-179Initial program 83.6%
*-commutative83.6%
associate-*r/83.6%
associate--r-83.6%
+-commutative83.6%
associate-+r-83.6%
unsub-neg83.6%
associate--r+83.6%
+-commutative83.6%
associate--r+83.6%
Simplified83.6%
Taylor expanded in M around inf 69.3%
unpow269.3%
Simplified69.3%
Taylor expanded in K around 0 74.7%
*-commutative74.7%
fabs-sub74.7%
unpow274.7%
cos-neg74.7%
Simplified74.7%
if 1.9500000000000001e-179 < m Initial program 76.7%
*-commutative76.7%
associate-*r/76.7%
associate--r-76.7%
+-commutative76.7%
associate-+r-76.7%
unsub-neg76.7%
associate--r+76.7%
+-commutative76.7%
associate--r+76.7%
Simplified76.7%
Taylor expanded in K around 0 92.6%
cos-neg92.6%
Simplified92.6%
Taylor expanded in n around inf 41.8%
*-commutative41.8%
unpow241.8%
associate-*l*41.8%
Simplified41.8%
Final simplification68.2%
(FPCore (K m n M l)
:precision binary64
(if (<= n 3.1e-228)
(* (cos M) (exp (- (- (fabs (- m n)) l) (* (* m m) 0.25))))
(if (<= n 3.8e-13)
(* (cos (- (* (+ m n) (/ K 2.0)) M)) (exp (- (- l) (* M M))))
(* (cos M) (exp (* n (* n -0.25)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 3.1e-228) {
tmp = cos(M) * exp(((fabs((m - n)) - l) - ((m * m) * 0.25)));
} else if (n <= 3.8e-13) {
tmp = cos((((m + n) * (K / 2.0)) - M)) * exp((-l - (M * M)));
} else {
tmp = cos(M) * exp((n * (n * -0.25)));
}
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.1d-228) then
tmp = cos(m_1) * exp(((abs((m - n)) - l) - ((m * m) * 0.25d0)))
else if (n <= 3.8d-13) then
tmp = cos((((m + n) * (k / 2.0d0)) - m_1)) * exp((-l - (m_1 * m_1)))
else
tmp = cos(m_1) * exp((n * (n * (-0.25d0))))
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.1e-228) {
tmp = Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - ((m * m) * 0.25)));
} else if (n <= 3.8e-13) {
tmp = Math.cos((((m + n) * (K / 2.0)) - M)) * Math.exp((-l - (M * M)));
} else {
tmp = Math.cos(M) * Math.exp((n * (n * -0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 3.1e-228: tmp = math.cos(M) * math.exp(((math.fabs((m - n)) - l) - ((m * m) * 0.25))) elif n <= 3.8e-13: tmp = math.cos((((m + n) * (K / 2.0)) - M)) * math.exp((-l - (M * M))) else: tmp = math.cos(M) * math.exp((n * (n * -0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 3.1e-228) tmp = Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(Float64(m * m) * 0.25)))); elseif (n <= 3.8e-13) tmp = Float64(cos(Float64(Float64(Float64(m + n) * Float64(K / 2.0)) - M)) * exp(Float64(Float64(-l) - Float64(M * M)))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(n * -0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 3.1e-228) tmp = cos(M) * exp(((abs((m - n)) - l) - ((m * m) * 0.25))); elseif (n <= 3.8e-13) tmp = cos((((m + n) * (K / 2.0)) - M)) * exp((-l - (M * M))); else tmp = cos(M) * exp((n * (n * -0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 3.1e-228], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.8e-13], N[(N[Cos[N[(N[(N[(m + n), $MachinePrecision] * N[(K / 2.0), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-l) - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.1 \cdot 10^{-228}:\\
\;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - \left(m \cdot m\right) \cdot 0.25}\\
\mathbf{elif}\;n \leq 3.8 \cdot 10^{-13}:\\
\;\;\;\;\cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right) \cdot e^{\left(-\ell\right) - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if n < 3.0999999999999998e-228Initial program 77.5%
*-commutative77.5%
associate-*r/77.5%
associate--r-77.5%
+-commutative77.5%
associate-+r-77.5%
unsub-neg77.5%
associate--r+77.5%
+-commutative77.5%
associate--r+77.5%
Simplified77.5%
Taylor expanded in K around 0 94.1%
cos-neg94.1%
Simplified94.1%
Taylor expanded in m around inf 59.2%
*-commutative59.2%
unpow259.2%
Simplified59.2%
if 3.0999999999999998e-228 < n < 3.8e-13Initial program 87.6%
*-commutative87.6%
associate-*r/87.6%
associate--r-87.6%
+-commutative87.6%
associate-+r-87.6%
unsub-neg87.6%
associate--r+87.6%
+-commutative87.6%
associate--r+87.6%
Simplified87.6%
Taylor expanded in M around inf 70.3%
unpow270.3%
Simplified70.3%
Taylor expanded in l around inf 77.4%
neg-mul-177.4%
Simplified77.4%
if 3.8e-13 < n Initial program 67.3%
*-commutative67.3%
associate-*r/67.3%
associate--r-67.3%
+-commutative67.3%
associate-+r-67.3%
unsub-neg67.3%
associate--r+67.3%
+-commutative67.3%
associate--r+67.3%
Simplified67.3%
Taylor expanded in K around 0 98.2%
cos-neg98.2%
Simplified98.2%
Taylor expanded in n around inf 96.4%
*-commutative96.4%
unpow296.4%
associate-*l*96.4%
Simplified96.4%
Final simplification71.2%
(FPCore (K m n M l)
:precision binary64
(if (<= m -50.0)
(* (cos M) (exp (* m (* m -0.25))))
(if (<= m 1.9e-95)
(* (cos (- (* (+ m n) (/ K 2.0)) M)) (exp (- (- l) (* M M))))
(* (cos M) (exp (* n (* n -0.25)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -50.0) {
tmp = cos(M) * exp((m * (m * -0.25)));
} else if (m <= 1.9e-95) {
tmp = cos((((m + n) * (K / 2.0)) - M)) * exp((-l - (M * M)));
} else {
tmp = cos(M) * exp((n * (n * -0.25)));
}
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 <= (-50.0d0)) then
tmp = cos(m_1) * exp((m * (m * (-0.25d0))))
else if (m <= 1.9d-95) then
tmp = cos((((m + n) * (k / 2.0d0)) - m_1)) * exp((-l - (m_1 * m_1)))
else
tmp = cos(m_1) * exp((n * (n * (-0.25d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -50.0) {
tmp = Math.cos(M) * Math.exp((m * (m * -0.25)));
} else if (m <= 1.9e-95) {
tmp = Math.cos((((m + n) * (K / 2.0)) - M)) * Math.exp((-l - (M * M)));
} else {
tmp = Math.cos(M) * Math.exp((n * (n * -0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -50.0: tmp = math.cos(M) * math.exp((m * (m * -0.25))) elif m <= 1.9e-95: tmp = math.cos((((m + n) * (K / 2.0)) - M)) * math.exp((-l - (M * M))) else: tmp = math.cos(M) * math.exp((n * (n * -0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -50.0) tmp = Float64(cos(M) * exp(Float64(m * Float64(m * -0.25)))); elseif (m <= 1.9e-95) tmp = Float64(cos(Float64(Float64(Float64(m + n) * Float64(K / 2.0)) - M)) * exp(Float64(Float64(-l) - Float64(M * M)))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(n * -0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -50.0) tmp = cos(M) * exp((m * (m * -0.25))); elseif (m <= 1.9e-95) tmp = cos((((m + n) * (K / 2.0)) - M)) * exp((-l - (M * M))); else tmp = cos(M) * exp((n * (n * -0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -50.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.9e-95], N[(N[Cos[N[(N[(N[(m + n), $MachinePrecision] * N[(K / 2.0), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-l) - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -50:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 1.9 \cdot 10^{-95}:\\
\;\;\;\;\cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right) \cdot e^{\left(-\ell\right) - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if m < -50Initial program 67.5%
*-commutative67.5%
associate-*r/67.5%
associate--r-67.5%
+-commutative67.5%
associate-+r-67.5%
unsub-neg67.5%
associate--r+67.5%
+-commutative67.5%
associate--r+67.5%
Simplified67.5%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in m around inf 95.1%
*-commutative95.1%
unpow295.1%
associate-*l*95.1%
Simplified95.1%
if -50 < m < 1.8999999999999999e-95Initial program 83.0%
*-commutative83.0%
associate-*r/83.0%
associate--r-83.0%
+-commutative83.0%
associate-+r-83.0%
unsub-neg83.0%
associate--r+83.0%
+-commutative83.0%
associate--r+83.0%
Simplified83.0%
Taylor expanded in M around inf 69.2%
unpow269.2%
Simplified69.2%
Taylor expanded in l around inf 74.6%
neg-mul-174.6%
Simplified74.6%
if 1.8999999999999999e-95 < m Initial program 76.1%
*-commutative76.1%
associate-*r/76.1%
associate--r-76.1%
+-commutative76.1%
associate-+r-76.1%
unsub-neg76.1%
associate--r+76.1%
+-commutative76.1%
associate--r+76.1%
Simplified76.1%
Taylor expanded in K around 0 92.0%
cos-neg92.0%
Simplified92.0%
Taylor expanded in n around inf 40.7%
*-commutative40.7%
unpow240.7%
associate-*l*40.7%
Simplified40.7%
Final simplification70.2%
(FPCore (K m n M l)
:precision binary64
(if (<= m -0.0225)
(* (cos M) (exp (* m (* m -0.25))))
(if (<= m 1.35e-100)
(* (cos M) (exp (* M (- M))))
(* (cos M) (exp (* n (* n -0.25)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.0225) {
tmp = cos(M) * exp((m * (m * -0.25)));
} else if (m <= 1.35e-100) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = cos(M) * exp((n * (n * -0.25)));
}
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 <= (-0.0225d0)) then
tmp = cos(m_1) * exp((m * (m * (-0.25d0))))
else if (m <= 1.35d-100) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp((n * (n * (-0.25d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.0225) {
tmp = Math.cos(M) * Math.exp((m * (m * -0.25)));
} else if (m <= 1.35e-100) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp((n * (n * -0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -0.0225: tmp = math.cos(M) * math.exp((m * (m * -0.25))) elif m <= 1.35e-100: tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp((n * (n * -0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -0.0225) tmp = Float64(cos(M) * exp(Float64(m * Float64(m * -0.25)))); elseif (m <= 1.35e-100) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(n * -0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -0.0225) tmp = cos(M) * exp((m * (m * -0.25))); elseif (m <= 1.35e-100) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp((n * (n * -0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.0225], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.35e-100], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.0225:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 1.35 \cdot 10^{-100}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if m < -0.022499999999999999Initial program 68.1%
*-commutative68.1%
associate-*r/68.1%
associate--r-68.1%
+-commutative68.1%
associate-+r-68.1%
unsub-neg68.1%
associate--r+68.1%
+-commutative68.1%
associate--r+68.1%
Simplified68.1%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in m around inf 93.6%
*-commutative93.6%
unpow293.6%
associate-*l*93.6%
Simplified93.6%
if -0.022499999999999999 < m < 1.35000000000000008e-100Initial program 82.7%
*-commutative82.7%
associate-*r/82.7%
associate--r-82.7%
+-commutative82.7%
associate-+r-82.7%
unsub-neg82.7%
associate--r+82.7%
+-commutative82.7%
associate--r+82.7%
Simplified82.7%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
Simplified95.1%
Taylor expanded in M around inf 58.2%
mul-1-neg58.2%
unpow258.2%
distribute-rgt-neg-in58.2%
Simplified58.2%
if 1.35000000000000008e-100 < m Initial program 76.4%
*-commutative76.4%
associate-*r/76.4%
associate--r-76.4%
+-commutative76.4%
associate-+r-76.4%
unsub-neg76.4%
associate--r+76.4%
+-commutative76.4%
associate--r+76.4%
Simplified76.4%
Taylor expanded in K around 0 92.2%
cos-neg92.2%
Simplified92.2%
Taylor expanded in n around inf 41.6%
*-commutative41.6%
unpow241.6%
associate-*l*41.6%
Simplified41.6%
Final simplification61.9%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -15.0) (not (<= M 25.5))) (* (cos M) (exp (* M (- M)))) (exp (- (fabs (- m n)) l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -15.0) || !(M <= 25.5)) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = exp((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_1 <= (-15.0d0)) .or. (.not. (m_1 <= 25.5d0))) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = exp((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 <= -15.0) || !(M <= 25.5)) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.exp((Math.abs((m - n)) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -15.0) or not (M <= 25.5): tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.exp((math.fabs((m - n)) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -15.0) || !(M <= 25.5)) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = exp(Float64(abs(Float64(m - n)) - l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -15.0) || ~((M <= 25.5))) tmp = cos(M) * exp((M * -M)); else tmp = exp((abs((m - n)) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -15.0], N[Not[LessEqual[M, 25.5]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -15 \lor \neg \left(M \leq 25.5\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\left|m - n\right| - \ell}\\
\end{array}
\end{array}
if M < -15 or 25.5 < M Initial program 82.9%
*-commutative82.9%
associate-*r/82.9%
associate--r-82.9%
+-commutative82.9%
associate-+r-82.9%
unsub-neg82.9%
associate--r+82.9%
+-commutative82.9%
associate--r+82.9%
Simplified82.9%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in M around inf 96.8%
mul-1-neg96.8%
unpow296.8%
distribute-rgt-neg-in96.8%
Simplified96.8%
if -15 < M < 25.5Initial program 72.6%
*-commutative72.6%
associate-*r/72.6%
associate--r-72.6%
+-commutative72.6%
associate-+r-72.6%
unsub-neg72.6%
associate--r+72.6%
+-commutative72.6%
associate--r+72.6%
Simplified72.6%
Taylor expanded in M around inf 37.0%
unpow237.0%
Simplified37.0%
Taylor expanded in M around 0 37.0%
exp-diff30.1%
fabs-sub30.1%
exp-diff37.0%
Simplified37.0%
Taylor expanded in K around 0 39.9%
Final simplification67.3%
(FPCore (K m n M l) :precision binary64 (if (<= m -0.0225) (* (cos M) (exp (* m (* m -0.25)))) (* (cos M) (exp (* M (- M))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.0225) {
tmp = cos(M) * exp((m * (m * -0.25)));
} else {
tmp = cos(M) * exp((M * -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 <= (-0.0225d0)) then
tmp = cos(m_1) * exp((m * (m * (-0.25d0))))
else
tmp = cos(m_1) * exp((m_1 * -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 <= -0.0225) {
tmp = Math.cos(M) * Math.exp((m * (m * -0.25)));
} else {
tmp = Math.cos(M) * Math.exp((M * -M));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -0.0225: tmp = math.cos(M) * math.exp((m * (m * -0.25))) else: tmp = math.cos(M) * math.exp((M * -M)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -0.0225) tmp = Float64(cos(M) * exp(Float64(m * Float64(m * -0.25)))); else tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -0.0225) tmp = cos(M) * exp((m * (m * -0.25))); else tmp = cos(M) * exp((M * -M)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.0225], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.0225:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\end{array}
\end{array}
if m < -0.022499999999999999Initial program 68.1%
*-commutative68.1%
associate-*r/68.1%
associate--r-68.1%
+-commutative68.1%
associate-+r-68.1%
unsub-neg68.1%
associate--r+68.1%
+-commutative68.1%
associate--r+68.1%
Simplified68.1%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in m around inf 93.6%
*-commutative93.6%
unpow293.6%
associate-*l*93.6%
Simplified93.6%
if -0.022499999999999999 < m Initial program 80.5%
*-commutative80.5%
associate-*r/80.5%
associate--r-80.5%
+-commutative80.5%
associate-+r-80.5%
unsub-neg80.5%
associate--r+80.5%
+-commutative80.5%
associate--r+80.5%
Simplified80.5%
Taylor expanded in K around 0 94.0%
cos-neg94.0%
Simplified94.0%
Taylor expanded in M around inf 55.7%
mul-1-neg55.7%
unpow255.7%
distribute-rgt-neg-in55.7%
Simplified55.7%
Final simplification64.6%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- m n)) l)))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((m - 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((abs((m - n)) - l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((m - n)) - l));
}
def code(K, m, n, M, l): return math.exp((math.fabs((m - n)) - l))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(m - n)) - l)) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((m - n)) - l)); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|m - n\right| - \ell}
\end{array}
Initial program 77.6%
*-commutative77.6%
associate-*r/77.6%
associate--r-77.6%
+-commutative77.6%
associate-+r-77.6%
unsub-neg77.6%
associate--r+77.6%
+-commutative77.6%
associate--r+77.6%
Simplified77.6%
Taylor expanded in M around inf 52.1%
unpow252.1%
Simplified52.1%
Taylor expanded in M around 0 25.7%
exp-diff19.4%
fabs-sub19.4%
exp-diff25.7%
Simplified25.7%
Taylor expanded in K around 0 28.2%
Final simplification28.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 77.6%
*-commutative77.6%
associate-*r/77.6%
associate--r-77.6%
+-commutative77.6%
associate-+r-77.6%
unsub-neg77.6%
associate--r+77.6%
+-commutative77.6%
associate--r+77.6%
Simplified77.6%
Taylor expanded in K around 0 94.6%
cos-neg94.6%
Simplified94.6%
Taylor expanded in M around inf 54.3%
mul-1-neg54.3%
unpow254.3%
distribute-rgt-neg-in54.3%
Simplified54.3%
Taylor expanded in M around 0 9.3%
Final simplification9.3%
herbie shell --seed 2023178
(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)))))))