
(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 (let* ((t_0 (cbrt (- (* (+ m n) 0.5) M)))) (* (cos M) (exp (- (- (fabs (- m n)) l) (* (pow t_0 4.0) (pow t_0 2.0)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cbrt((((m + n) * 0.5) - M));
return cos(M) * exp(((fabs((m - n)) - l) - (pow(t_0, 4.0) * pow(t_0, 2.0))));
}
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.cbrt((((m + n) * 0.5) - M));
return Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - (Math.pow(t_0, 4.0) * Math.pow(t_0, 2.0))));
}
function code(K, m, n, M, l) t_0 = cbrt(Float64(Float64(Float64(m + n) * 0.5) - M)) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64((t_0 ^ 4.0) * (t_0 ^ 2.0))))) end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(N[Power[t$95$0, 4.0], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\left(m + n\right) \cdot 0.5 - M}\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {t_0}^{4} \cdot {t_0}^{2}}
\end{array}
\end{array}
Initial program 69.6%
associate-/l*69.6%
+-commutative69.6%
fabs-sub69.6%
+-commutative69.6%
Simplified69.6%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
add-cube-cbrt95.3%
cbrt-unprod93.7%
pow-prod-up93.7%
div-inv93.7%
fma-neg93.7%
metadata-eval93.7%
metadata-eval93.7%
unpow293.7%
cbrt-prod93.7%
pow293.7%
div-inv93.7%
fma-neg93.7%
metadata-eval93.7%
Applied egg-rr93.7%
fma-neg93.7%
fma-neg93.7%
Simplified93.7%
pow1/393.7%
sqr-pow93.7%
unpow-prod-down95.3%
metadata-eval95.3%
pow295.3%
pow-prod-down48.7%
pow1/348.7%
pow1/395.3%
unpow295.3%
metadata-eval95.3%
pow295.3%
pow-prod-down48.7%
pow1/348.7%
pow1/395.3%
unpow295.3%
Applied egg-rr95.3%
Final simplification95.3%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (- n m) l) (pow (- (* (+ m n) 0.5) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((((n - m) - l) - pow((((m + n) * 0.5) - 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((((n - m) - l) - ((((m + n) * 0.5d0) - 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((((n - m) - l) - Math.pow((((m + n) * 0.5) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((((n - m) - l) - math.pow((((m + n) * 0.5) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(Float64(n - m) - l) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((((n - m) - l) - ((((m + n) * 0.5) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n - m), $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left(n - m\right) - \ell\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 69.6%
associate-/l*69.6%
+-commutative69.6%
fabs-sub69.6%
+-commutative69.6%
Simplified69.6%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
sub-neg95.3%
distribute-neg-out95.3%
div-inv95.3%
fma-neg95.3%
metadata-eval95.3%
add-sqr-sqrt50.8%
fabs-sqr50.8%
add-sqr-sqrt95.2%
Applied egg-rr95.2%
neg-sub095.2%
+-commutative95.2%
associate--r+95.2%
sub-neg95.2%
associate--r+95.2%
neg-sub095.2%
sub-neg95.2%
mul-1-neg95.2%
+-commutative95.2%
distribute-neg-in95.2%
mul-1-neg95.2%
remove-double-neg95.2%
sub-neg95.2%
fma-neg95.2%
Simplified95.2%
Final simplification95.2%
(FPCore (K m n M l)
:precision binary64
(if (<= m -5.2e+108)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(*
(cos M)
(exp (+ (- (- n m) l) (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -5.2e+108) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - 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 <= (-5.2d+108)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp((((n - m) - l) + (((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - 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 <= -5.2e+108) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -5.2e+108: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -5.2e+108) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(n - m) - l) + Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -5.2e+108) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -5.2e+108], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n - m), $MachinePrecision] - l), $MachinePrecision] + N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5.2 \cdot 10^{+108}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(\left(n - m\right) - \ell\right) + \left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right)}\\
\end{array}
\end{array}
if m < -5.2000000000000005e108Initial program 58.1%
associate-/l*58.1%
+-commutative58.1%
fabs-sub58.1%
+-commutative58.1%
Simplified58.1%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -5.2000000000000005e108 < m Initial program 71.9%
associate-/l*71.9%
+-commutative71.9%
fabs-sub71.9%
+-commutative71.9%
Simplified71.9%
Taylor expanded in K around 0 94.3%
cos-neg94.3%
Simplified94.3%
sub-neg94.3%
distribute-neg-out94.3%
div-inv94.3%
fma-neg94.3%
metadata-eval94.3%
add-sqr-sqrt42.3%
fabs-sqr42.3%
add-sqr-sqrt94.3%
Applied egg-rr94.3%
neg-sub094.3%
+-commutative94.3%
associate--r+94.3%
sub-neg94.3%
associate--r+94.3%
neg-sub094.3%
sub-neg94.3%
mul-1-neg94.3%
+-commutative94.3%
distribute-neg-in94.3%
mul-1-neg94.3%
remove-double-neg94.3%
sub-neg94.3%
fma-neg94.3%
Simplified94.3%
Taylor expanded in n around 0 76.6%
+-commutative76.6%
unpow276.6%
distribute-rgt-out81.8%
Simplified81.8%
Final simplification84.8%
(FPCore (K m n M l)
:precision binary64
(if (<= n 6.3e+94)
(*
(cos M)
(exp (+ (- (- n m) l) (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)))))
(* (cos M) (exp (* (pow n 2.0) -0.25)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 6.3e+94) {
tmp = cos(M) * exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n))));
} else {
tmp = cos(M) * exp((pow(n, 2.0) * -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 <= 6.3d+94) then
tmp = cos(m_1) * exp((((n - m) - l) + (((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n))))
else
tmp = cos(m_1) * exp(((n ** 2.0d0) * (-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 <= 6.3e+94) {
tmp = Math.cos(M) * Math.exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n))));
} else {
tmp = Math.cos(M) * Math.exp((Math.pow(n, 2.0) * -0.25));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 6.3e+94: tmp = math.cos(M) * math.exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n)))) else: tmp = math.cos(M) * math.exp((math.pow(n, 2.0) * -0.25)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 6.3e+94) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(n - m) - l) + Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n))))); else tmp = Float64(cos(M) * exp(Float64((n ^ 2.0) * -0.25))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 6.3e+94) tmp = cos(M) * exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n)))); else tmp = cos(M) * exp(((n ^ 2.0) * -0.25)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 6.3e+94], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n - m), $MachinePrecision] - l), $MachinePrecision] + N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[n, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 6.3 \cdot 10^{+94}:\\
\;\;\;\;\cos M \cdot e^{\left(\left(n - m\right) - \ell\right) + \left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{{n}^{2} \cdot -0.25}\\
\end{array}
\end{array}
if n < 6.3000000000000001e94Initial program 70.9%
associate-/l*70.9%
+-commutative70.9%
fabs-sub70.9%
+-commutative70.9%
Simplified70.9%
Taylor expanded in K around 0 94.4%
cos-neg94.4%
Simplified94.4%
sub-neg94.4%
distribute-neg-out94.4%
div-inv94.4%
fma-neg94.4%
metadata-eval94.4%
add-sqr-sqrt42.2%
fabs-sqr42.2%
add-sqr-sqrt94.3%
Applied egg-rr94.3%
neg-sub094.3%
+-commutative94.3%
associate--r+94.3%
sub-neg94.3%
associate--r+94.3%
neg-sub094.3%
sub-neg94.3%
mul-1-neg94.3%
+-commutative94.3%
distribute-neg-in94.3%
mul-1-neg94.3%
remove-double-neg94.3%
sub-neg94.3%
fma-neg94.3%
Simplified94.3%
Taylor expanded in n around 0 82.9%
+-commutative82.9%
unpow282.9%
distribute-rgt-out87.1%
Simplified87.1%
if 6.3000000000000001e94 < n Initial program 62.5%
associate-/l*62.5%
+-commutative62.5%
fabs-sub62.5%
+-commutative62.5%
Simplified62.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification89.1%
(FPCore (K m n M l)
:precision binary64
(if (<= M 2e+14)
(*
(cos M)
(exp (+ (- (- n m) l) (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)))))
(* (cos M) (exp (- (pow M 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (M <= 2e+14) {
tmp = cos(M) * exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n))));
} else {
tmp = cos(M) * 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 <= 2d+14) then
tmp = cos(m_1) * exp((((n - m) - l) + (((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n))))
else
tmp = cos(m_1) * 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 <= 2e+14) {
tmp = Math.cos(M) * Math.exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n))));
} else {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if M <= 2e+14: tmp = math.cos(M) * math.exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n)))) else: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (M <= 2e+14) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(n - m) - l) + Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n))))); else tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (M <= 2e+14) tmp = cos(M) * exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n)))); else tmp = cos(M) * exp(-(M ^ 2.0)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[M, 2e+14], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n - m), $MachinePrecision] - l), $MachinePrecision] + N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2 \cdot 10^{+14}:\\
\;\;\;\;\cos M \cdot e^{\left(\left(n - m\right) - \ell\right) + \left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\end{array}
\end{array}
if M < 2e14Initial program 71.3%
associate-/l*71.3%
+-commutative71.3%
fabs-sub71.3%
+-commutative71.3%
Simplified71.3%
Taylor expanded in K around 0 94.3%
cos-neg94.3%
Simplified94.3%
sub-neg94.3%
distribute-neg-out94.3%
div-inv94.3%
fma-neg94.3%
metadata-eval94.3%
add-sqr-sqrt52.4%
fabs-sqr52.4%
add-sqr-sqrt94.2%
Applied egg-rr94.2%
neg-sub094.2%
+-commutative94.2%
associate--r+94.2%
sub-neg94.2%
associate--r+94.2%
neg-sub094.2%
sub-neg94.2%
mul-1-neg94.2%
+-commutative94.2%
distribute-neg-in94.2%
mul-1-neg94.2%
remove-double-neg94.2%
sub-neg94.2%
fma-neg94.2%
Simplified94.2%
Taylor expanded in n around 0 76.0%
+-commutative76.0%
unpow276.0%
distribute-rgt-out80.3%
Simplified80.3%
if 2e14 < M Initial program 61.4%
associate-/l*61.4%
+-commutative61.4%
fabs-sub61.4%
+-commutative61.4%
Simplified61.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification83.7%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (+ (- (- n m) l) (* (- (* m 0.5) M) (- (- M (* m 0.5)) n))))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - 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(m_1) * exp((((n - m) - l) + (((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n))));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n))))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(Float64(n - m) - l) + Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n))))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((((n - m) - l) + (((m * 0.5) - M) * ((M - (m * 0.5)) - n)))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n - m), $MachinePrecision] - l), $MachinePrecision] + N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left(n - m\right) - \ell\right) + \left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right)}
\end{array}
Initial program 69.6%
associate-/l*69.6%
+-commutative69.6%
fabs-sub69.6%
+-commutative69.6%
Simplified69.6%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
sub-neg95.3%
distribute-neg-out95.3%
div-inv95.3%
fma-neg95.3%
metadata-eval95.3%
add-sqr-sqrt50.8%
fabs-sqr50.8%
add-sqr-sqrt95.2%
Applied egg-rr95.2%
neg-sub095.2%
+-commutative95.2%
associate--r+95.2%
sub-neg95.2%
associate--r+95.2%
neg-sub095.2%
sub-neg95.2%
mul-1-neg95.2%
+-commutative95.2%
distribute-neg-in95.2%
mul-1-neg95.2%
remove-double-neg95.2%
sub-neg95.2%
fma-neg95.2%
Simplified95.2%
Taylor expanded in n around 0 77.0%
+-commutative77.0%
unpow277.0%
distribute-rgt-out82.9%
Simplified82.9%
Final simplification82.9%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(-l);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(-l);
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(-l)
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 69.6%
associate-/l*69.6%
+-commutative69.6%
fabs-sub69.6%
+-commutative69.6%
Simplified69.6%
Taylor expanded in l around inf 28.6%
mul-1-neg28.6%
Simplified28.6%
Taylor expanded in K around 0 35.4%
cos-neg35.4%
Simplified35.4%
Final simplification35.4%
(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 69.6%
associate-/l*69.6%
+-commutative69.6%
fabs-sub69.6%
+-commutative69.6%
Simplified69.6%
Taylor expanded in l around inf 28.6%
mul-1-neg28.6%
Simplified28.6%
Taylor expanded in l around 0 6.1%
Taylor expanded in K around 0 6.9%
cos-neg6.9%
Simplified6.9%
Final simplification6.9%
herbie shell --seed 2023319
(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)))))))