Consider the function $\csc(t)\sin(3t)$ on the interval $[0,\pi]$. This is a perfectly well-behaved smooth function, as can be seen when plotting it:
Plot[2 Csc[t] Sin[3 t], {t, 0, π}]
so why cannot I not numerically integrate it by running the following?
NIntegrate[2 Csc[t] Sin[3 t], {t, 0, π}]
Instead I get the error message "NIntegrate::errprec: Catastrophic loss of precision in the global error estimate due to insufficient WorkingPrecision or divergent integral". FYI I expect the answer to be $2\pi$, as can be seen by running
Integrate[2 Csc[t] Sin[3 t], {t, 0, π}]
Thanks in advance for any help.
Csc[t]
). Following the advice in the error message, try it wthWorkingPrecision -> 16
. $\endgroup$NIntegrate[2 Csc[t] Sin[3 t] // TrigExpand, {t, 0, \[Pi]}]
$\endgroup$NIntegrate
selects a bad rule (Clenshaw-Curtis osciilatory). TryNIntegrate[2 Csc[t] Sin[3 t], {t, 0, \[Pi]}, Method -> "GaussKronrodRule"]
$\endgroup$Integrate
rather thanNIntegrate
$\endgroup$NIntegrate[2 ChebyshevU[2, Cos[t]], {t, 0, π}]
$\endgroup$