I am trying to evaluate a function, that I've now reduced to its minimum (not) working example. Unless I am doing something very wrong, it appears that NIntegrate
is not agreeing with the result from Integrate
.
The integral I am trying to evaluate is the following:
$$ \int_0^{2\pi} t e^{-a \cos(b + t) } \sin(b+t)\ dt $$
To do so, I am using the code:
Integrate[
t Exp[-a Cos[b + t]] Sin[t + b],
{t, 0, 2 \[Pi]}
]
The result found by Mathematica is the following
$$ \fbox{$-\frac{2 \pi (\sinh (a)-\cosh (a)+I_0(a))}{a}\text{ if }\Re(a)>0$} $$
The condition is fulfilled for my purposes. However, this solution does not agree with the numerical evaluation of the integral. For instance, the line:
NIntegrate[
t Exp[-a Cos[b + t ]] Sin[ t + b] /. a -> 0.5 /. b -> 0.5,
{t, 0, 2 \[Pi]}
]
yields -5.26114
, whereas
Integrate[
t Exp[-a Cos[b + t ]] Sin[ t + b],
{t, 0, 2 \[Pi]}
]/. a -> 0.5 /. b -> 0.5
yields -5.74224
. These two values are considerably different. Another strange outcome is that replacing the values analytically inside the integral makes the integral uncomputable, even though the values chosen satisfy the required condition Re[a]>0
:
Integrate[
t Exp[-a Cos[b + t ]] Sin[ t + b] /. a -> 0.5 /. b -> 0.5,
{t, 0, 2 \[Pi]}
]
the return of this line is simply the inputted form of the integral.
What is going on here? Am I doing anything incorrectly? Is there a problematic discrepancy between the symbolic and numerical solvers?
Thanks in advance for the help!
Any recommendations for better practices regarding writing up these commands is very welcome too :)
Integrate
. The output is totally independent ofb
which obviously should not. $\endgroup$