
(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 10 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 (- n m)) 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((n - m)) - 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((n - m)) - 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((n - m)) - 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((n - m)) - 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(n - m)) - 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((n - m)) - 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[(n - m), $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|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 79.5%
associate-/l*79.9%
+-commutative79.9%
fabs-sub79.9%
+-commutative79.9%
Simplified79.9%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Final simplification96.4%
(FPCore (K m n M l)
:precision binary64
(if (<= n 56.0)
(*
(cos M)
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- (fabs (- n m)) l))))
(* (cos M) (exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 56.0) {
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (fabs((n - m)) - l)));
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.0)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (n <= 56.0d0) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (abs((n - m)) - l)))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 56.0) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (Math.abs((n - m)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 56.0: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (math.fabs((n - m)) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 56.0) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(abs(Float64(n - m)) - l)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 56.0) tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (abs((n - m)) - l))); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 56.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 56:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(\left|n - m\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 56Initial program 80.4%
associate-/l*81.0%
+-commutative81.0%
fabs-sub81.0%
+-commutative81.0%
Simplified81.0%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
Simplified95.1%
Taylor expanded in n around 0 83.0%
+-commutative83.0%
unpow283.0%
distribute-rgt-out87.3%
*-commutative87.3%
*-commutative87.3%
Simplified87.3%
if 56 < n Initial program 76.8%
associate-/l*76.8%
+-commutative76.8%
fabs-sub76.8%
+-commutative76.8%
Simplified76.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
pow-prod-up100.0%
div-inv100.0%
fma-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in n around inf 98.6%
*-commutative98.6%
Simplified98.6%
Final simplification90.3%
(FPCore (K m n M l)
:precision binary64
(if (<= m -8e+52)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(*
(cos M)
(exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) (- (fabs (- n m)) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -8e+52) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (fabs((n - 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 <= (-8d+52)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + (abs((n - 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 <= -8e+52) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (Math.abs((n - m)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -8e+52: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (math.fabs((n - m)) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -8e+52) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + Float64(abs(Float64(n - m)) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -8e+52) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); else tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (abs((n - m)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -8e+52], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -8 \cdot 10^{+52}:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + \left(\left|n - m\right| - \ell\right)}\\
\end{array}
\end{array}
if m < -7.9999999999999999e52Initial program 74.5%
associate-/l*74.5%
+-commutative74.5%
fabs-sub74.5%
+-commutative74.5%
Simplified74.5%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
add-sqr-sqrt97.9%
sqrt-unprod97.9%
pow-prod-up97.9%
div-inv97.9%
fma-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
Applied egg-rr97.9%
Taylor expanded in m around inf 97.9%
*-commutative97.9%
Simplified97.9%
if -7.9999999999999999e52 < m Initial program 80.6%
associate-/l*81.1%
+-commutative81.1%
fabs-sub81.1%
+-commutative81.1%
Simplified81.1%
Taylor expanded in K around 0 96.1%
cos-neg96.1%
Simplified96.1%
Taylor expanded in m around 0 79.5%
+-commutative79.5%
unpow279.5%
distribute-rgt-out84.8%
*-commutative84.8%
*-commutative84.8%
Simplified84.8%
Final simplification87.2%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- (fabs (- n m)) (+ l (* (* m 0.5) (+ n (* m 0.5))))))))
(if (<= n -1.7e-158)
t_0
(if (<= n -6.4e-211)
(* (cos M) (exp (- (pow M 2.0))))
(if (<= n 4.4) t_0 (* (cos M) (exp (* -0.25 (pow n 2.0)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((fabs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5))))));
double tmp;
if (n <= -1.7e-158) {
tmp = t_0;
} else if (n <= -6.4e-211) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else if (n <= 4.4) {
tmp = t_0;
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.0)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = exp((abs((n - m)) - (l + ((m * 0.5d0) * (n + (m * 0.5d0))))))
if (n <= (-1.7d-158)) then
tmp = t_0
else if (n <= (-6.4d-211)) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else if (n <= 4.4d0) then
tmp = t_0
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((Math.abs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5))))));
double tmp;
if (n <= -1.7e-158) {
tmp = t_0;
} else if (n <= -6.4e-211) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else if (n <= 4.4) {
tmp = t_0;
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((math.fabs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5)))))) tmp = 0 if n <= -1.7e-158: tmp = t_0 elif n <= -6.4e-211: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) elif n <= 4.4: tmp = t_0 else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(Float64(m * 0.5) * Float64(n + Float64(m * 0.5)))))) tmp = 0.0 if (n <= -1.7e-158) tmp = t_0; elseif (n <= -6.4e-211) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); elseif (n <= 4.4) tmp = t_0; else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((abs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5)))))); tmp = 0.0; if (n <= -1.7e-158) tmp = t_0; elseif (n <= -6.4e-211) tmp = cos(M) * exp(-(M ^ 2.0)); elseif (n <= 4.4) tmp = t_0; else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(N[(m * 0.5), $MachinePrecision] * N[(n + N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -1.7e-158], t$95$0, If[LessEqual[n, -6.4e-211], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.4], t$95$0, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left|n - m\right| - \left(\ell + \left(m \cdot 0.5\right) \cdot \left(n + m \cdot 0.5\right)\right)}\\
\mathbf{if}\;n \leq -1.7 \cdot 10^{-158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -6.4 \cdot 10^{-211}:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{elif}\;n \leq 4.4:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -1.7e-158 or -6.39999999999999971e-211 < n < 4.4000000000000004Initial program 79.7%
associate-/l*80.2%
+-commutative80.2%
fabs-sub80.2%
+-commutative80.2%
Simplified80.2%
Taylor expanded in K around 0 95.2%
cos-neg95.2%
Simplified95.2%
Taylor expanded in n around 0 81.9%
+-commutative81.9%
unpow281.9%
distribute-rgt-out86.6%
*-commutative86.6%
*-commutative86.6%
Simplified86.6%
Taylor expanded in M around 0 70.1%
associate-*r*70.1%
Simplified70.1%
if -1.7e-158 < n < -6.39999999999999971e-211Initial program 93.8%
associate-/l*93.8%
+-commutative93.8%
fabs-sub93.8%
+-commutative93.8%
Simplified93.8%
Taylor expanded in K around 0 93.8%
cos-neg93.8%
Simplified93.8%
add-sqr-sqrt93.8%
sqrt-unprod93.8%
pow-prod-up93.8%
div-inv93.8%
fma-neg93.8%
metadata-eval93.8%
metadata-eval93.8%
Applied egg-rr93.8%
Taylor expanded in M around inf 82.6%
mul-1-neg82.6%
Simplified82.6%
if 4.4000000000000004 < n Initial program 75.7%
associate-/l*75.7%
+-commutative75.7%
fabs-sub75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
pow-prod-up100.0%
div-inv100.0%
fma-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in n around inf 97.3%
*-commutative97.3%
Simplified97.3%
Final simplification78.3%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -22000.0) (not (<= M 0.122))) (* (cos M) (exp (- (pow M 2.0)))) (exp (- (fabs (- n m)) (+ l (* (* m 0.5) (+ n (* m 0.5))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -22000.0) || !(M <= 0.122)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = exp((fabs((n - m)) - (l + ((m * 0.5) * (n + (m * 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_1 <= (-22000.0d0)) .or. (.not. (m_1 <= 0.122d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp((abs((n - m)) - (l + ((m * 0.5d0) * (n + (m * 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 <= -22000.0) || !(M <= 0.122)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp((Math.abs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5))))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -22000.0) or not (M <= 0.122): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp((math.fabs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5)))))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -22000.0) || !(M <= 0.122)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(Float64(m * 0.5) * Float64(n + Float64(m * 0.5)))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -22000.0) || ~((M <= 0.122))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = exp((abs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5)))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -22000.0], N[Not[LessEqual[M, 0.122]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(N[(m * 0.5), $MachinePrecision] * N[(n + N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -22000 \lor \neg \left(M \leq 0.122\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left|n - m\right| - \left(\ell + \left(m \cdot 0.5\right) \cdot \left(n + m \cdot 0.5\right)\right)}\\
\end{array}
\end{array}
if M < -22000 or 0.122 < M Initial program 78.4%
associate-/l*78.4%
+-commutative78.4%
fabs-sub78.4%
+-commutative78.4%
Simplified78.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod98.5%
pow-prod-up98.5%
div-inv98.5%
fma-neg98.5%
metadata-eval98.5%
metadata-eval98.5%
Applied egg-rr98.5%
Taylor expanded in M around inf 97.7%
mul-1-neg97.7%
Simplified97.7%
if -22000 < M < 0.122Initial program 80.5%
associate-/l*81.3%
+-commutative81.3%
fabs-sub81.3%
+-commutative81.3%
Simplified81.3%
Taylor expanded in K around 0 92.7%
cos-neg92.7%
Simplified92.7%
Taylor expanded in n around 0 65.5%
+-commutative65.5%
unpow265.5%
distribute-rgt-out68.7%
*-commutative68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in M around 0 68.7%
associate-*r*68.7%
Simplified68.7%
Final simplification83.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (+ n (* m 0.5))))
(if (or (<= M -8.2e+77) (not (<= M 0.122)))
(* (cos M) (exp (* M (- (- t_0 (* m -0.5)) M))))
(exp (- (fabs (- n m)) (+ l (* (* m 0.5) t_0)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = n + (m * 0.5);
double tmp;
if ((M <= -8.2e+77) || !(M <= 0.122)) {
tmp = cos(M) * exp((M * ((t_0 - (m * -0.5)) - M)));
} else {
tmp = exp((fabs((n - m)) - (l + ((m * 0.5) * t_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) :: t_0
real(8) :: tmp
t_0 = n + (m * 0.5d0)
if ((m_1 <= (-8.2d+77)) .or. (.not. (m_1 <= 0.122d0))) then
tmp = cos(m_1) * exp((m_1 * ((t_0 - (m * (-0.5d0))) - m_1)))
else
tmp = exp((abs((n - m)) - (l + ((m * 0.5d0) * t_0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = n + (m * 0.5);
double tmp;
if ((M <= -8.2e+77) || !(M <= 0.122)) {
tmp = Math.cos(M) * Math.exp((M * ((t_0 - (m * -0.5)) - M)));
} else {
tmp = Math.exp((Math.abs((n - m)) - (l + ((m * 0.5) * t_0))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = n + (m * 0.5) tmp = 0 if (M <= -8.2e+77) or not (M <= 0.122): tmp = math.cos(M) * math.exp((M * ((t_0 - (m * -0.5)) - M))) else: tmp = math.exp((math.fabs((n - m)) - (l + ((m * 0.5) * t_0)))) return tmp
function code(K, m, n, M, l) t_0 = Float64(n + Float64(m * 0.5)) tmp = 0.0 if ((M <= -8.2e+77) || !(M <= 0.122)) tmp = Float64(cos(M) * exp(Float64(M * Float64(Float64(t_0 - Float64(m * -0.5)) - M)))); else tmp = exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(Float64(m * 0.5) * t_0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = n + (m * 0.5); tmp = 0.0; if ((M <= -8.2e+77) || ~((M <= 0.122))) tmp = cos(M) * exp((M * ((t_0 - (m * -0.5)) - M))); else tmp = exp((abs((n - m)) - (l + ((m * 0.5) * t_0)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(n + N[(m * 0.5), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[M, -8.2e+77], N[Not[LessEqual[M, 0.122]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * N[(N[(t$95$0 - N[(m * -0.5), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(N[(m * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n + m \cdot 0.5\\
\mathbf{if}\;M \leq -8.2 \cdot 10^{+77} \lor \neg \left(M \leq 0.122\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(\left(t_0 - m \cdot -0.5\right) - M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\left|n - m\right| - \left(\ell + \left(m \cdot 0.5\right) \cdot t_0\right)}\\
\end{array}
\end{array}
if M < -8.2000000000000002e77 or 0.122 < M Initial program 77.4%
associate-/l*77.4%
+-commutative77.4%
fabs-sub77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 80.1%
+-commutative80.1%
unpow280.1%
distribute-rgt-out89.7%
*-commutative89.7%
*-commutative89.7%
Simplified89.7%
Taylor expanded in M around inf 72.4%
distribute-lft-out72.4%
mul-1-neg72.4%
+-commutative72.4%
unpow272.4%
distribute-lft-out79.4%
+-commutative79.4%
mul-1-neg79.4%
unsub-neg79.4%
*-commutative79.4%
Simplified79.4%
if -8.2000000000000002e77 < M < 0.122Initial program 81.2%
associate-/l*81.9%
+-commutative81.9%
fabs-sub81.9%
+-commutative81.9%
Simplified81.9%
Taylor expanded in K around 0 93.5%
cos-neg93.5%
Simplified93.5%
Taylor expanded in n around 0 67.0%
+-commutative67.0%
unpow267.0%
distribute-rgt-out69.9%
*-commutative69.9%
*-commutative69.9%
Simplified69.9%
Taylor expanded in M around 0 68.5%
associate-*r*68.5%
Simplified68.5%
Final simplification73.4%
(FPCore (K m n M l) :precision binary64 (if (<= n 1.26e+171) (exp (- (fabs (- n m)) (+ l (* (* m 0.5) (+ n (* m 0.5)))))) (* (cos M) (exp (* n (- M (* m 0.5)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.26e+171) {
tmp = exp((fabs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5))))));
} else {
tmp = cos(M) * exp((n * (M - (m * 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 (n <= 1.26d+171) then
tmp = exp((abs((n - m)) - (l + ((m * 0.5d0) * (n + (m * 0.5d0))))))
else
tmp = cos(m_1) * exp((n * (m_1 - (m * 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 (n <= 1.26e+171) {
tmp = Math.exp((Math.abs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5))))));
} else {
tmp = Math.cos(M) * Math.exp((n * (M - (m * 0.5))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 1.26e+171: tmp = math.exp((math.fabs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5)))))) else: tmp = math.cos(M) * math.exp((n * (M - (m * 0.5)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 1.26e+171) tmp = exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(Float64(m * 0.5) * Float64(n + Float64(m * 0.5)))))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(M - Float64(m * 0.5))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 1.26e+171) tmp = exp((abs((n - m)) - (l + ((m * 0.5) * (n + (m * 0.5)))))); else tmp = cos(M) * exp((n * (M - (m * 0.5)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1.26e+171], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(N[(m * 0.5), $MachinePrecision] * N[(n + N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.26 \cdot 10^{+171}:\\
\;\;\;\;e^{\left|n - m\right| - \left(\ell + \left(m \cdot 0.5\right) \cdot \left(n + m \cdot 0.5\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\end{array}
\end{array}
if n < 1.26000000000000004e171Initial program 80.9%
associate-/l*81.4%
+-commutative81.4%
fabs-sub81.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in n around 0 80.0%
+-commutative80.0%
unpow280.0%
distribute-rgt-out85.5%
*-commutative85.5%
*-commutative85.5%
Simplified85.5%
Taylor expanded in M around 0 65.9%
associate-*r*65.9%
Simplified65.9%
if 1.26000000000000004e171 < n Initial program 71.1%
associate-/l*71.1%
+-commutative71.1%
fabs-sub71.1%
+-commutative71.1%
Simplified71.1%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 32.3%
+-commutative32.3%
unpow232.3%
distribute-rgt-out40.4%
*-commutative40.4%
*-commutative40.4%
Simplified40.4%
Taylor expanded in n around inf 43.1%
Final simplification62.5%
(FPCore (K m n M l) :precision binary64 (if (<= l 4e-9) (* (cos M) (exp (* n (- M (* m 0.5))))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 4e-9) {
tmp = cos(M) * exp((n * (M - (m * 0.5))));
} 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 <= 4d-9) then
tmp = cos(m_1) * exp((n * (m_1 - (m * 0.5d0))))
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 <= 4e-9) {
tmp = Math.cos(M) * Math.exp((n * (M - (m * 0.5))));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 4e-9: tmp = math.cos(M) * math.exp((n * (M - (m * 0.5)))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 4e-9) tmp = Float64(cos(M) * exp(Float64(n * Float64(M - Float64(m * 0.5))))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 4e-9) tmp = cos(M) * exp((n * (M - (m * 0.5)))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 4e-9], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $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 4 \cdot 10^{-9}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 4.00000000000000025e-9Initial program 77.0%
associate-/l*77.5%
+-commutative77.5%
fabs-sub77.5%
+-commutative77.5%
Simplified77.5%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Taylor expanded in n around 0 67.3%
+-commutative67.3%
unpow267.3%
distribute-rgt-out74.9%
*-commutative74.9%
*-commutative74.9%
Simplified74.9%
Taylor expanded in n around inf 33.5%
if 4.00000000000000025e-9 < l Initial program 85.9%
associate-/l*85.9%
+-commutative85.9%
fabs-sub85.9%
+-commutative85.9%
Simplified85.9%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
add-sqr-sqrt98.6%
sqrt-unprod98.6%
pow-prod-up98.6%
div-inv98.6%
fma-neg98.6%
metadata-eval98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Taylor expanded in l around inf 94.5%
mul-1-neg94.5%
Simplified94.5%
Final simplification50.4%
(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 79.5%
associate-/l*79.9%
+-commutative79.9%
fabs-sub79.9%
+-commutative79.9%
Simplified79.9%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
add-sqr-sqrt96.4%
sqrt-unprod95.7%
pow-prod-up95.7%
div-inv95.7%
fma-neg95.7%
metadata-eval95.7%
metadata-eval95.7%
Applied egg-rr95.7%
Taylor expanded in l around inf 36.1%
mul-1-neg36.1%
Simplified36.1%
Final simplification36.1%
(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 79.5%
associate-/l*79.9%
+-commutative79.9%
fabs-sub79.9%
+-commutative79.9%
Simplified79.9%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
add-sqr-sqrt96.4%
sqrt-unprod95.7%
pow-prod-up95.7%
div-inv95.7%
fma-neg95.7%
metadata-eval95.7%
metadata-eval95.7%
Applied egg-rr95.7%
Taylor expanded in m around inf 50.8%
*-commutative50.8%
Simplified50.8%
Taylor expanded in m around 0 7.7%
Final simplification7.7%
herbie shell --seed 2024017
(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)))))))