Is there a numerical method to solve the integral of a function containing a constant? Is there a numerical method to solve the integral of a function containing a constant? Such as:
$$\int_0^{\pi} x^2 \cos(tx) e^{a\cos(x)} dx , \qquad t\in\mathbb Z^+, a\in\mathbb R$$
While working on one of the statistical derivations, I encountered integrals as shown in the example, and I tried to solve them analytically, but I did not reach any result even after resorting to modified Bessel function.
I do not have a method other than numerical methods, but I do not have enough experience in it.... I look forward to your experience.
 A: Depending on the application, it could often be useful to choose a range of numerical values for $a$ and $t$, and then solve the integral numerically for each value.
So for example you could take 100 numerical values for $a$ equally spaced in between 0 and 1, and $t$ ranging from 1 to 50, if this gave you enough information about the integral for the problem you're interested in. You may need to sample at more or less points in a given continuous region to capture the key features of the integral in that region. If you wanted to understand for example asymptotic behaviour as $a\rightarrow\infty$, then this method may be less useful.
For your specific example you can find an analytic expression in terms of derivatives of the modified bessel function $I_\nu$ by differentiating under the integral sign. To do this let's start with equation 10.32.3 from https://dlmf.nist.gov/10.32, which is an integral representation for $I_\nu$; $$I_t(a) = \frac{1}{\pi}\int_0^{\pi}\cos(tx) e^{a\cos(x)} dx.$$ Now try differentiating this expression with respect to $t$. The integral is with respect to $x$ so we can take the $t$ derivative inside the integral sign to see that $$\frac{\partial}{\partial t} I_t(a) = -\frac{1}{\pi}\int_0^{\pi}x\sin(tx) e^{a\cos(x)} dx,$$ which is starting to look quite similar to your integral. In fact, we can differentiate with respect to $t$ one more time and multiply by $\pi$ to recover that $$-\pi\frac{\partial^2}{\partial t^2} I_t(a) = \int_0^{\pi}x^2\cos(tx) e^{a\cos(x)} dx,$$ giving a representation for your integral in terms of the second derivative of modified bessel function $I_\nu$ with respect to its parameter. In your case we want to restrict to $t$ integer after taking the derivative.
Edit: Gary points out that there are some identities at https://dlmf.nist.gov/10.38 for first derivatives of $I_\nu$ with respect to $\nu$. You can see that for general (non integer) $\nu$ the functional form is quite complicated, involving $I_\nu$ and also sums of gamma and digamma functions. The restriction to integer $\nu$ after the derivative is taken, which is what you're interested in, simplifies down to an expression in terms of just $I_\nu$ and $K_\nu$ which is quite nice.
Edit: Gary also points out that if you take a look at this paper, https://www.researchgate.net/publication/299999883_Higher_derivatives_of_the_Bessel_functions_with_respect_to_the_order/link/594e58fca6fdccebfa5eb6e8/download, you'll see that equation 7.1 has an expression for second derivative of $I_\nu$ with respect to $\nu$, restricted to $\nu$ integer. Unfortunately the result is a bit of a monster, depending on gamma, digamma, hypergeometric and Meijer G functions as well as $I_\nu$ and $K_\nu$.
